Browse Source

修改了“print.php”、“Film.php”、“Scene.php”三个类文件

master
yuanjiajia 3 years ago
parent
commit
b10a05d057
  1. 21
      examples/print.php
  2. 53
      src/scene/Scene.php
  3. 11
      src/scene/render/Film.php

21
examples/print.php

@ -53,13 +53,17 @@ echo $scene;
//设置打印 “胶片” 配置参数 //设置打印 “胶片” 配置参数
$film = new render\Film();//添加一个胶片, $film = new render\Film();//添加一个胶片,
$film->addImage( new render\Image(['type' => render\Image::TYPE_RGBA ]) ); //为胶片添加一个 RGBA类型 的图片输出
$film->addImage( new render\Image(['type' => render\Image::TYPE_MATERIAL_ID ]) );//为胶片添加一个 MATERIAL_ID类型 的图片输出
$img = new render\Image();
$img->effect = [new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()];
$film->addImage($img);
$img = new render\Image(); //创建一个默认类型的图片输出,
$img->effect = [new render\effect\NoiseReducerOIDN(),new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\AnalogFilmSimulation(),new render\effect\CammaCorrection()]; //为图片添加效果管线处理
$film->addImage(new render\Image(['type' => 'ALBEDO']));
$film->addImage(new render\Image(['type' => 'AVG_SHADING_NORMAL']));
$img = new render\Image();
$img->effect = [new render\effect\NoiseReducerOIDN(),new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()];
$film->addImage($img);
$film->addImage($img); //将这个图片添加到胶片
echo $film; echo $film;
@ -89,17 +93,18 @@ $mix->amount = 0.6; //指定混合系数为 0.6
$obj->material = $mix; //为模型赋予这个混合材质 $obj->material = $mix; //为模型赋予这个混合材质
$scene->addObject($obj); //将模型添加到场景中
$scene->addobjects($obj); //将模型添加到场景中
/*
//添加第二个模型 //添加第二个模型
$obj = new objects\Objects( [ 'ply' => 'mesh-119.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型, $obj = new objects\Objects( [ 'ply' => 'mesh-119.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型,
$obj->material = new materials\Metal( ['fresnel' => "2517393611944Fresnel"] ); //为模型创建一个 金属 类型的材质 $obj->material = new materials\Metal( ['fresnel' => "2517393611944Fresnel"] ); //为模型创建一个 金属 类型的材质
$scene->addObject($obj); //将模型添加到场景中 $scene->addObject($obj); //将模型添加到场景中
*/
echo $scene;
//echo $scene;
?> ?>

53
src/scene/Scene.php

@ -38,6 +38,57 @@ class Scene extends BaseCfg
private $camera = []; private $camera = [];
public function addobjects($obj)
{
$temp = null;
$attributeArr = get_object_vars($obj);
$className = get_class($obj);
$className = array_reverse(explode('\\', $className))[0];
switch($className)
{
case 'Objects':
$temp = sprintf("%014d",count($this->objects)+1);
$this->objects[$temp] = $obj;
break;
case 'MaterialsBase':
$temp = $obj->type.'_'.sprintf("%014d",count($this->materials)+1);
$this->materials[$temp] = $obj;
break;
case 'VolumesBase':
$temp = $obj->type.'_'.sprintf("%014d",count($this->volumes)+1);
$this->volumes[$temp] = $obj;
break;
case 'TextureBase':
$temp = $obj->type.'_'.sprintf("%014d",count($this->textures)+1);
$this->textures[$temp] = $obj;
break;
default:
break;
}
foreach( $attributeArr as $key => $value)
{
if( $value instanceof texture\TextureBase || $value instanceof materials\MaterialsBase || $value instanceof volumes\VolumesBase )
{
$obj->$key = $this->addobjects( $value );
}
}
return $temp;
}
/*
public function addObject( object $object ) public function addObject( object $object )
{ {
$temp = null; $temp = null;
@ -86,6 +137,8 @@ class Scene extends BaseCfg
return $temp; return $temp;
} }
*/
} }
?> ?>

11
src/scene/render/Film.php

@ -62,17 +62,6 @@ class Film extends BaseCfg
$this->noiseEstimation = new NoiseEstimation($config); $this->noiseEstimation = new NoiseEstimation($config);
$this->filter = new Filter($config); $this->filter = new Filter($config);
$img = new Image();
$img->effect = [new effect\Pretreatment(),new effect\ToneMapLinear(),new effect\CammaCorrection()];
$this->addImage($img);
$this->addImage(new Image(['type' => 'ALBEDO']));
$this->addImage(new Image(['type' => 'AVG_SHADING_NORMAL']));
$img = new Image();
$img->effect = [new effect\NoiseReducerOIDN(),new effect\Pretreatment(),new effect\ToneMapLinear(),new effect\CammaCorrection()];
$this->addImage($img);
Base::__construct($config); Base::__construct($config);
} }

Loading…
Cancel
Save