Browse Source

修改了“print.php”、“BaseCfg.php”、“Scene.php”、“Film.php”、“Image.php”五个类文件

master
yuanjiajia 3 years ago
parent
commit
bdb87d2471
  1. 36
      examples/print.php
  2. 15
      src/scene/BaseCfg.php
  3. 4
      src/scene/Scene.php
  4. 43
      src/scene/render/Film.php
  5. 11
      src/scene/render/Image.php

36
examples/print.php

@ -4,13 +4,15 @@
namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\scene\materials\Disney;
use Blobt\Luxcore\scene\objects\Objects;
use Blobt\Luxcore\scene\objects;
use Blobt\Luxcore\scene\render;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>';
echo "\n\n\n\n";
/*
//设置打印 渲染引擎 的配置参数
@ -45,31 +47,39 @@ echo $batch;
$scene = new Scene();
echo $scene;
*/
//设置打印 “胶片” 配置参数
$film = new 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类型 的图片输出
$film->outputs[] = new file\ImageSaver(['type' => file\ImageSaver::TYPE_RGBA ]);
$film->outputs[] = new file\ImageSaver(['type' => file\ImageSaver::TYPE_MATERIAL_ID ]);
$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->outputs[] = new file\ImageSaver(['index' => 5 ]);
$film->imagepipelines[5] = [new effect\NoiseReducerOIDN(),new effect\Pretreatment(),new effect\ToneMapLinear(),new effect\AnalogFilmSimulation(),new effect\CammaCorrection()];
$film->addImage($img); //将这个图片添加到胶片
echo $film;
*/
$scene = new Scene();//创建一个场景,
echo "\n\n\n\n";
echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>场景配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>';
echo "\n\n\n\n";
$scene = new Scene();//创建一个场景,
//添加第一个模型
$obj = new Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型,
$obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型,
$mix = new materials\Mix(); //创建一个 Mix材质,
@ -79,15 +89,15 @@ $mix->amount = 0.6; //指定混合系数为 0.6
$obj->material = $mix; //为模型赋予这个混合材质
$scene->addobject($obj); //将模型添加到场景中
$scene->addObject($obj); //将模型添加到场景中
//添加第二个模型
$obj = new 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"] ); //为模型创建一个 金属 类型的材质
$scene->addobject($obj); //将模型添加到场景中
$scene->addObject($obj); //将模型添加到场景中
echo $scene;

15
src/scene/BaseCfg.php

@ -70,10 +70,7 @@ class BaseCfg extends Base
break;
case 'object':
if($name != 'conn' && $className != 'scene')
{
$ret .= $value->toString($className);
}
$ret .= $value->toString($className);
break;
case 'NULL':
@ -86,15 +83,7 @@ class BaseCfg extends Base
case 'array':
foreach(StringHelper::arrayToString($value) as $value)
{
if( $name == 'imagepipelines' && $className == 'film' )
{
$value = sprintf("%03d", substr($value,0,strpos($value,'.'))).substr($value,strpos($value,'.'));
$ret .= "{$className}.{$name}.{$value}\n";
}
else
{
$ret .= "{$className}.{$name}.{$value}\n";
}
$ret .= "{$className}.{$name}.{$value}\n";
}
break;

4
src/scene/Scene.php

@ -38,7 +38,7 @@ class Scene extends BaseCfg
private $camera = [];
public function addobject( object $object )
public function addObject( object $object )
{
$temp = null;
$attributeArr = get_object_vars($object);
@ -74,7 +74,7 @@ class Scene extends BaseCfg
$this->volumes[$temp] = $object;
}
else;
foreach( $attributeArr as $key => $value)
{

43
src/scene/render/Film.php

@ -2,7 +2,6 @@
namespace Blobt\Luxcore\scene\render;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\file\ImageSaver;
use Blobt\Luxcore\core\Base;
class Film extends BaseCfg
@ -47,12 +46,12 @@ class Film extends BaseCfg
/**
* @var array 渲染图像后期处理配置参数
*/
public $imagepipelines;
public $imagepipelines = [];
/**
* @var array 图像输出的配置参数
*/
public $outputs;
public $outputs = [];
/**
* 实例 NoiseEstimation类、filter类的两个对象,配置渲染器默认的输出参数”;
@ -63,19 +62,41 @@ class Film extends BaseCfg
$this->noiseEstimation = new NoiseEstimation($config);
$this->filter = new Filter($config);
$this->outputs[] = new ImageSaver(['index' => 0]);
$this->imagepipelines[0] = [new effect\Pretreatment(),new effect\ToneMapLinear(),new effect\CammaCorrection()];
$this->outputs[] = new ImageSaver(['type' => 'ALBEDO']);
$this->outputs[] = new ImageSaver(['type' => 'AVG_SHADING_NORMAL']);
$this->outputs[] = new ImageSaver(['index' => 1]);
$this->imagepipelines[1] = [new effect\NoiseReducerOIDN(),new effect\Pretreatment(),new effect\ToneMapLinear(),new effect\CammaCorrection()];
$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);
}
public function addImage( object $object )
{
$i = -1;
if($object->type == Image::TYPE_RGB_IMAGEPIPELINE)
{
foreach($this->outputs as $value)
{
$i = $value->index > $i ? $value->index : $i;
}
$object->index = $i + 1;
if ($object->effect != null)
{
$this->imagepipelines[ sprintf("%03d",$object->index) ] = $object->effect;
$object->effect = null;
}
}
$this->outputs[] = $object;
}
}
?>

src/scene/file/ImageSaver.php → src/scene/render/Image.php

Loading…
Cancel
Save