From 45c172a6c7e31c1597a6b0576fd27dfbc569d5a1 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Sun, 27 Feb 2022 23:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E5=85=B3=E4=BA=8E?= =?UTF-8?q?=E8=B4=B4=E5=9B=BE=E3=80=81=E7=9B=B8=E6=9C=BA=E3=80=81=E7=81=AF?= =?UTF-8?q?=E5=85=89=E3=80=81=E4=BD=93=E7=A7=AF=E6=9D=90=E8=B4=A8=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E6=96=87=E4=BB=B6,=E2=80=9Cscene.php=E2=80=9D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0addobject()=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A8=A1=E5=9E=8B=E3=80=81=E6=9D=90=E8=B4=A8?= =?UTF-8?q?=E3=80=81=E8=B4=B4=E5=9B=BE=E8=87=AA=E5=AF=B9=E5=BA=94=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 38 +++++++-------- src/scene/BaseCfg.php | 4 -- src/scene/Scene.php | 69 +++++++++++++++++++++------ src/scene/camera/Camera.php | 13 +++++ src/scene/light/LigthBase.php | 13 +++++ src/scene/materials/MaterialsBase.php | 12 +---- src/scene/objects/Objects.php | 8 ++-- src/scene/texture/TextureBase.php | 13 +++++ src/scene/volumes/VolumesBase.php | 13 +++++ 9 files changed, 131 insertions(+), 52 deletions(-) create mode 100644 src/scene/camera/Camera.php create mode 100644 src/scene/light/LigthBase.php create mode 100644 src/scene/texture/TextureBase.php create mode 100644 src/scene/volumes/VolumesBase.php diff --git a/examples/print.php b/examples/print.php index a81f6da..435cebe 100644 --- a/examples/print.php +++ b/examples/print.php @@ -4,6 +4,7 @@ namespace Blobt\Luxcore\scene; use Blobt\Luxcore\scene\materials; +use Blobt\Luxcore\scene\materials\Disney; use Blobt\Luxcore\scene\objects\Objects; include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; @@ -58,38 +59,35 @@ $film->imagepipelines[5] = [new effect\NoiseReducerOIDN(),new effect\Pretreatmen echo $film; */ + + + + $scene = new Scene();//创建一个场景, + //添加第一个模型 -$mix = new materials\Mix(); //在场景中创建一个 Mix材质, -$mix->material1 = 'wood1'; //指定混合材质的第一个材质为 wood1 -$mix->material2 = 'wood2'; //指定混合材质的第二个材质为 wood2 -$mix->amount = 0.6; //指定混合系数为 0.6 +$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(); //创建一个的模型, -$obj->material = $mix; //为模型指定一个材质 -$obj->ply = 'mesh-00000.ply'; //为模型指定网格 -$obj->camerainvisible = false; //是否对摄像机隐藏, -$obj->id = 10086; //为模型指定ID -$obj->appliedtransformation = '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1'; //设置模型的位值参数 +$mix = new materials\Mix(); //创建一个 Mix材质, -$scene->objects[] = $obj; //将模型添加到场景中 +$mix->material1 = new materials\Disney();//指定混合材质的第一个材质为 Disney +$mix->material2 = new materials\Metal();//指定混合材质的第一个材质为 Metal +$mix->amount = 0.6; //指定混合系数为 0.6 +$obj->material = $mix; //为模型赋予这个混合材质 +$scene->addobject($obj); //将模型添加到场景中 -//添加第二个模型 -$metal = new materials\Metal(); //创建一个 金属 类型的材质 -$metal->fresnel = "2517393611944Fresnel"; //指定金属材质菲列尔参数为一个颜色类型的贴图 -$obj = new Objects(); //创建一个的模型, -$obj->material = $metal; //为模型指定一个材质 -$obj->ply = 'mesh-119.ply'; //为模型指定网格 -$obj->camerainvisible = false; //是否对摄像机隐藏, -$obj->appliedtransformation = '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1'; //设置模型的位值参数 -$scene->objects[] = $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->material = new materials\Metal( ['fresnel' => "2517393611944Fresnel"] ); //为模型创建一个 金属 类型的材质 +$scene->addobject($obj); //将模型添加到场景中 echo $scene; diff --git a/src/scene/BaseCfg.php b/src/scene/BaseCfg.php index cd23be2..c594307 100644 --- a/src/scene/BaseCfg.php +++ b/src/scene/BaseCfg.php @@ -3,16 +3,12 @@ namespace Blobt\Luxcore\scene; - - - use Blobt\Luxcore\core\Base; use Blobt\Luxcore\utils\StringHelper; - class BaseCfg extends Base { diff --git a/src/scene/Scene.php b/src/scene/Scene.php index be5d940..620065f 100644 --- a/src/scene/Scene.php +++ b/src/scene/Scene.php @@ -1,46 +1,87 @@ objects)+1); + $this->objects[$temp] = $object; + } + else if( $object instanceof materials\MaterialsBase ) + { + $temp = 'material_'.sprintf("%014d",count($this->materials)+1); + $this->materials[$temp] = $object; + } + else if($object instanceof ligth\LightBase) + { + $temp = 'light_'.sprintf("%014d",count($this->lights)+1); + $this->lights[$temp] = $object; + } + else if($object instanceof camera\Camera) + { + $temp = 'camera_'.sprintf("%014d",count($this->camera)+1); + $this->camera[$temp] = $object; + } + else if($object instanceof texture\TextureBase) + { + $temp = 'texture_'.sprintf("%014d",count($this->textures)+1); + $this->textures[$temp] = $object; + } + else if( $object instanceof volumes\VolumesBase ) + { + $temp = 'volume_'.sprintf("%014d",count($this->volumes)+1); + $this->volumes[$temp] = $object; + } + else; - public function __construct() - { - self::$conn = $this; + foreach( $attributeArr as $key => $value) + { + if( $value instanceof texture\TextureBase || $value instanceof materials\MaterialsBase || $value instanceof volumes\VolumesBase ) + { + $object->$key = $this->addobject( $value ); + } + } + return $temp; } } diff --git a/src/scene/camera/Camera.php b/src/scene/camera/Camera.php new file mode 100644 index 0000000..07db399 --- /dev/null +++ b/src/scene/camera/Camera.php @@ -0,0 +1,13 @@ + diff --git a/src/scene/light/LigthBase.php b/src/scene/light/LigthBase.php new file mode 100644 index 0000000..0f410ee --- /dev/null +++ b/src/scene/light/LigthBase.php @@ -0,0 +1,13 @@ + diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index 7fdaaab..e33c07b 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -1,12 +1,9 @@ type.'_'.sprintf("%09d",count(Scene::$conn->materials)+1); - Scene::$conn->materials[$temp] = $this; - return $temp; - } - } ?> diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index 053e034..83bdb02 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -1,6 +1,7 @@ id = rand(0,1000000); + Base::__construct($config); } } diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php new file mode 100644 index 0000000..bd0cdc0 --- /dev/null +++ b/src/scene/texture/TextureBase.php @@ -0,0 +1,13 @@ + diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php new file mode 100644 index 0000000..2128ec8 --- /dev/null +++ b/src/scene/volumes/VolumesBase.php @@ -0,0 +1,13 @@ +