From 210147137ae6abd074b02a43060e4ed85597555d Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Tue, 1 Mar 2022 17:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E8=B4=A8=E4=B8=8E=E8=B4=B4=E5=9B=BE?= =?UTF-8?q?=E7=B1=BB=E6=B7=BB=E5=8A=A0set=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=A4=E4=B8=AA=E8=B4=B4=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 17 ++++-- src/scene/Scene.php | 12 ++-- src/scene/materials/Disney.php | 86 +++++++++++++++++++++++++++ src/scene/materials/Emission.php | 2 +- src/scene/materials/Glass.php | 57 +++++++++++++++++- src/scene/materials/Glossy.php | 62 ++++++++++++++++++- src/scene/materials/MaterialsBase.php | 17 +++++- src/scene/materials/Metal.php | 31 ++++++++++ src/scene/materials/Mix.php | 15 +++++ src/scene/materials/NullMaterial.php | 15 +++++ src/scene/materials/Roughmatte.php | 25 ++++++++ src/scene/texture/ImageMap.php | 54 +++++++++++++++++ src/scene/texture/TextureBase.php | 17 +++--- src/scene/texture/mapping/Mapping.php | 42 +++++++++++++ 14 files changed, 428 insertions(+), 24 deletions(-) create mode 100644 src/scene/texture/ImageMap.php create mode 100644 src/scene/texture/mapping/Mapping.php diff --git a/examples/print.php b/examples/print.php index de9be08..b558480 100644 --- a/examples/print.php +++ b/examples/print.php @@ -6,6 +6,7 @@ namespace Blobt\Luxcore\scene; use Blobt\Luxcore\scene\materials; use Blobt\Luxcore\scene\objects; use Blobt\Luxcore\scene\render; +use Blobt\Luxcore\scene\texture; include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; @@ -47,7 +48,7 @@ echo $batch; $scene = new Scene(); echo $scene; -*/ + //设置打印 “胶片” 配置参数 @@ -67,7 +68,7 @@ $film->addImage($img); echo $film; - +*/ @@ -84,21 +85,25 @@ $scene = new Scene();//创建一个场景, //添加第一个模型 +$bumpMap = new texture\ImageMap(); +$baseColorMap = new texture\ImageMap(); +$metallicMap = new texture\ImageMap(); + $material1 = new materials\Disney(); //创建一个 Disney 材质 $material2 = new materials\Metal(); //创建一个 Metal 材质 -$material1 = $scene->setMaterial($material1); //将材质存入材质数组,并获得其键名 -$material2 = $scene->setMaterial($material2); //将材质存入材质数组,并获得其键名 +$material1 = $scene->addMaterial($material1); //将材质存入材质数组,并获得其键名 +$material2 = $scene->addMaterial($material2); //将材质存入材质数组,并获得其键名 $mix = new materials\Mix(); //创建 Mix 材质, $mix->material1 = $material1; //为材质通道1 指定一个键名 $mix->material2 = $material2; //为材质通道2 指定一个键名 $mix->amount = 0.6; //指定混合系数为 0.6 -$mix = $scene->setMaterial($mix); //将材质存入材质数组,并获得其键名 +$mix = $scene->addMaterial($mix); //将材质存入材质数组,并获得其键名 $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' ] ); //创建一个的模型, $obj->material = $mix; //为模型的材属性 指定一个键名 -$scene->setObjects($obj); //将模型添加到场景中 +$scene->addObjects($obj); //将模型添加到场景中 /* diff --git a/src/scene/Scene.php b/src/scene/Scene.php index f832425..b29dca3 100644 --- a/src/scene/Scene.php +++ b/src/scene/Scene.php @@ -45,14 +45,14 @@ class Scene extends BaseCfg } - public function setObjects($obj) + public function addObjects($obj) { $temp = null; $temp = sprintf("%014d",$obj->id); $this->objects[$temp] = $obj; } - public function setMaterial($material) + public function addMaterial($material) { $temp = null; $temp = $material->type.'_'.sprintf("%014d",$material->id); @@ -61,7 +61,7 @@ class Scene extends BaseCfg } - public function setTexture($texture) + public function addTexture($texture) { $temp = null; $temp = $texture->type.'_'.sprintf("%014d",$texture->id); @@ -69,7 +69,7 @@ class Scene extends BaseCfg return $temp; } - public function setVolume($volume) + public function addVolume($volume) { $temp = null; $temp = $volume->type.'_'.sprintf("%014d",$volume->id); @@ -77,7 +77,7 @@ class Scene extends BaseCfg return $temp; } - public function setLight($light) + public function addLight($light) { $temp = null; $temp = $light->type.'_'.sprintf("%014d",$light->id); @@ -85,7 +85,7 @@ class Scene extends BaseCfg return $temp; } - public function setCamera($camera) + public function addCamera($camera) { $temp = null; $temp = $camera->type.'_'.sprintf("%014d",$camera->id); diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 7e59577..66ce00e 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -103,7 +103,93 @@ class Disney extends MaterialsBase $this->visibility = new Visibility($config); Base::__construct($config); } + + public function setBaseColor($color) + { + $this->basecolor = $color; + } + + public function setSubsurface($color) + { + $this->subsurface = $color; + } + + public function setMetallic($color) + { + $this->metallic = $color; + } + + public function setSpecular($color) + { + $this->specular = $color; + } + + public function setSpeculartint($color) + { + $this->speculartint = $color; + } + + public function setRoughness($color) + { + $this->roughness = $color; + } + public function setAnisotropic($color) + { + $this->anisotropic = $color; + } + + public function setSheen($color) + { + $this->sheen = $color; + } + + public function setSheentint($color) + { + $this->sheentint = $color; + } + + public function setClearcoat($color) + { + $this->clearcoat = $color; + } + + public function setClearcoatgloss($color) + { + $this->clearcoatgloss = $color; + } + + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setFilmamount($color) + { + $this->filmamount = $color; + } + + public function setFilmthickness($color) + { + $this->filmthickness = $color; + } + + public function setFilmior($color) + { + $this->filmior = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + + } ?> diff --git a/src/scene/materials/Emission.php b/src/scene/materials/Emission.php index a88bc60..2510ea1 100644 --- a/src/scene/materials/Emission.php +++ b/src/scene/materials/Emission.php @@ -70,7 +70,7 @@ class Emission extends BaseCfg public $gamma; /** - * @var string 图片的色值以何种方式表示(固定取值:"float") + * @var string 输出的图片的色值以何种方式表示(固定取值:"float") */ public $storage; } diff --git a/src/scene/materials/Glass.php b/src/scene/materials/Glass.php index 4a64da4..008eb8b 100644 --- a/src/scene/materials/Glass.php +++ b/src/scene/materials/Glass.php @@ -30,7 +30,7 @@ class Glass extends MaterialsBase public $kr = "1 1 1"; /** - * @var float 菲列尔折射率,一个1-2的小数或一个textures(贴图数组)中的某个键名, + * @var float 内部折射率,一个1-2的小数或一个textures(贴图数组)中的某个键名, */ public $interiorior = 1.5; @@ -86,6 +86,61 @@ class Glass extends MaterialsBase Base::__construct($config); } + public function setUroughness($color) + { + $this->uroughness = $color; + } + + public function setVroughness($color) + { + $this->vroughness = $color; + } + + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + + public function setFilmthickness($color) + { + $this->filmthickness = $color; + } + + public function setFilmior($color) + { + $this->filmior = $color; + } + + public function setTransmission($color) + { + $this->kt = $color; + } + + public function setRefraction($color) + { + $this->kr = $color; + } + + public function setInteriorIor($color) + { + $this->interiorior = $color; + } + + public function setCauchyb($color) + { + $this->cauchyb = $color; + } + } ?> diff --git a/src/scene/materials/Glossy.php b/src/scene/materials/Glossy.php index 735d11d..e9794a9 100644 --- a/src/scene/materials/Glossy.php +++ b/src/scene/materials/Glossy.php @@ -17,7 +17,7 @@ class Glossy extends MaterialsBase /** * @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名; */ - public $ks = "0.5 0.5 0.5"; + public $ks = "0.05 0.05 0.05"; /** * @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名 @@ -74,6 +74,66 @@ class Glossy extends MaterialsBase Base::__construct($config); } + public function setUroughness($color) + { + $this->uroughness = $color; + } + + public function setVroughness($color) + { + $this->vroughness = $color; + } + + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + + public function setBaseColor($color) + { + $this->kd = $color; + } + + public function setSpecular($color) + { + $this->ks = $color; + } + + public function setAbsorption($color) + { + $this->ka = $color; + } + + public function setAbsorptionDepht($color) + { + $this->d = $color; + } + + public function setIor($color) + { + $this->index = $color; + } + + public function openMultiBounce() + { + $this->multibounce = true; + } + + public function closeMultiBounce() + { + $this->multibounce = false; + } + } ?> diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index e33c07b..68648e1 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -23,7 +23,7 @@ class MaterialsBase extends BaseCfg /** * @var integer 当前材质的ID号(取值:大于0的整数) */ - public $id = 1000000; + public $id; /** * @var float TODO:采样距离,具体作用尚未明确,(固定取值:0.001) @@ -81,6 +81,21 @@ class MaterialsBase extends BaseCfg */ public $volumeExterior; + public function setEmission($color) + { + $this->emission = $color; + } + + public function setVolumeInterior($color) + { + $this->volumeInterior = $color; + } + + public function setVolumeExterior($color) + { + $this->volumeExterior = $color; + } + } ?> diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index 1f748ab..f0bb47a 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -49,6 +49,37 @@ class Metal extends MaterialsBase Base::__construct($config); } + public function setFresnel($color) + { + $this->fresnel = $color; + } + + + public function setUroughness($color) + { + $this->uroughness = $color; + } + + public function setVroughness($color) + { + $this->vroughness = $color; + } + + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + } ?> diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index ff49ee2..1ea4c04 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -37,6 +37,21 @@ class Mix extends MaterialsBase Base::__construct($config); } + public function setMaterial1($Material) + { + $this->material1 = $Material; + } + + public function setMaterial2($Material) + { + $this->material2 = $Material; + } + + public function setAmount($amount) + { + $this->amount = $amount; + } + } ?> diff --git a/src/scene/materials/NullMaterial.php b/src/scene/materials/NullMaterial.php index 2a834ca..860a94c 100644 --- a/src/scene/materials/NullMaterial.php +++ b/src/scene/materials/NullMaterial.php @@ -33,6 +33,21 @@ class NullMaterial extends MaterialsBase Base::__construct($config); } + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + } ?> diff --git a/src/scene/materials/Roughmatte.php b/src/scene/materials/Roughmatte.php index dceff8a..dcf12d3 100644 --- a/src/scene/materials/Roughmatte.php +++ b/src/scene/materials/Roughmatte.php @@ -43,6 +43,31 @@ class Roughmatte extends MaterialsBase Base::__construct($config); } + public function setTransparencyFront($color) + { + $this->transparencyFront = $color; + } + + public function setTransparencyBack($color) + { + $this->transparencyBack = $color; + } + + public function setBumptex($color) + { + $this->bumptex = $color; + } + + public function setBaseColor($color) + { + $this->kd = $color; + } + + public function setSigma($color) + { + $this->sigma = $color; + } + } ?> diff --git a/src/scene/texture/ImageMap.php b/src/scene/texture/ImageMap.php new file mode 100644 index 0000000..643048e --- /dev/null +++ b/src/scene/texture/ImageMap.php @@ -0,0 +1,54 @@ +id = Scene::createID(); + $this->mapping = new mapping\Mapping(); + Base::__construct($config); + } + +} + +?> diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php index eac2cb4..668813e 100644 --- a/src/scene/texture/TextureBase.php +++ b/src/scene/texture/TextureBase.php @@ -2,19 +2,20 @@ namespace Blobt\Luxcore\scene\texture; use Blobt\Luxcore\scene\BaseCfg; -use Blobt\Luxcore\scene\Scene; -use Blobt\Luxcore\core\Base; + class TextureBase extends BaseCfg { + /** + * @var string 贴图类型 + */ + public $type; - public function __construct($config = []) - { - $this->id = Scene::createID(); - Base::__construct($config); - } - + /** + * @var integer 当前贴图的ID号(取值:大于0的整数) + */ + public $id; } ?> diff --git a/src/scene/texture/mapping/Mapping.php b/src/scene/texture/mapping/Mapping.php new file mode 100644 index 0000000..fe7a916 --- /dev/null +++ b/src/scene/texture/mapping/Mapping.php @@ -0,0 +1,42 @@ +