From 052ad4e5a9d0adf3871cf4546038b9e2c50b6380 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Mon, 7 Mar 2022 16:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=99=A8=E7=B1=BB=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=87=BD=E6=95=B0=E5=BD=A2=E5=8F=82=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C=E6=9D=90=E8=B4=A8?= =?UTF-8?q?=E3=80=81=E8=B4=B4=E5=9B=BE=E3=80=81=E6=A8=A1=E5=9E=8B=E3=80=81?= =?UTF-8?q?=E4=BD=93=E7=A7=AF=E6=9D=90=E8=B4=A8=E4=BF=AE=E6=94=B9set?= =?UTF-8?q?=E6=B6=B5=E6=95=B0=EF=BC=8CBase=E7=B1=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=8E=B7=E5=8F=96=E5=AD=90=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 18 ++-- src/core/Base.php | 8 ++ src/scene/materials/Disney.php | 34 +++---- src/scene/materials/Glass.php | 110 +++++++++++++++++++--- src/scene/materials/Glossy.php | 100 ++++++++++++++++++-- src/scene/materials/MaterialsBase.php | 46 ++++++--- src/scene/materials/Metal.php | 21 ++--- src/scene/materials/Mix.php | 6 +- src/scene/materials/NullMaterial.php | 30 +++++- src/scene/materials/Roughmatte.php | 50 +++++++++- src/scene/objects/Objects.php | 7 +- src/scene/render/Film.php | 14 +-- src/scene/render/OpenCL.php | 1 - src/scene/render/Path.php | 14 +-- src/scene/render/Sampler.php | 15 ++- src/scene/render/cache/LightStrategy.php | 7 +- src/scene/render/cache/PhotonGI.php | 14 +-- src/scene/texture/TextureBase.php | 7 +- src/scene/texture/map/Blend.php | 2 +- src/scene/texture/map/Clouds.php | 2 +- src/scene/texture/map/ImageMap.php | 2 +- src/scene/texture/mapping/Triplanar.php | 2 +- src/scene/texture/transform/NormalMap.php | 3 - src/scene/volumes/VolumesBase.php | 6 -- 24 files changed, 382 insertions(+), 137 deletions(-) diff --git a/examples/print.php b/examples/print.php index d748d5b..69f4bd7 100644 --- a/examples/print.php +++ b/examples/print.php @@ -8,13 +8,6 @@ include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; - - - - -/* - - echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'; echo "\n\n\n\n"; @@ -28,7 +21,7 @@ $openCL = new render\OpenCL(); echo $openCL; //设置打印光线跟踪的配置参数 -$path = new render\Path( new render\PathDepth( ['total'=>24,'glossy'=>12] ) ); +$path = new render\Path(); echo $path; //设置打印 采样器 配置参数 @@ -54,7 +47,7 @@ echo $scene; //设置打印 “胶片” 配置参数 -$film = new render\Film( new render\NoiseEstimation(),new render\Filter() );//添加一个胶片, +$film = new render\Film();//添加一个胶片, $img = new render\Image(); $img->effect = [new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()]; @@ -72,7 +65,7 @@ echo $film; -*/ + @@ -82,7 +75,7 @@ echo "\n\n\n\n"; $scene = new Scene();//创建一个场景, - +/* //添加第一个模型 @@ -96,7 +89,7 @@ $imageMap = new texture\map\ImageMap(); //创建一个 ImageMap类的贴图 $scene->registerTexture($imageMap); //将这个对象注册到 Scene $blend = new texture\map\Blend(); //创建一个 Blend类的贴图对象 -//$scene->registerTexture($blend); //将这个对象注册到 Scene +$scene->registerTexture($blend); //将这个对象注册到 Scene $disney = new materials\Disney(); //创建一个 Disney 材质对象 @@ -135,4 +128,5 @@ $scene->addObject($obj); //将模型添加到场景中 echo $scene; + ?> diff --git a/src/core/Base.php b/src/core/Base.php index 9b2a5fe..f84a145 100644 --- a/src/core/Base.php +++ b/src/core/Base.php @@ -17,4 +17,12 @@ class Base } } + /** + * 获得子类的类名 + */ + public function getInstanceClassName() + { + return array_reverse(explode('\\', get_class($this)))[0]; + } + } diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index b29601d..e09ee83 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -113,7 +113,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->basecolor = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->basecolor = $color; @@ -126,7 +126,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->subsurface = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->subsurface = $color; @@ -139,7 +139,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->metallic = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->metallic = $color; @@ -152,7 +152,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->specular = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->specular = $color; @@ -165,7 +165,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->speculartint = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->speculartint = $color; @@ -178,7 +178,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->roughness = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->roughness = $color; @@ -191,7 +191,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->anisotropic = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->anisotropic = $color; @@ -204,7 +204,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheen = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->sheen = $color; @@ -217,7 +217,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheentint = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->sheentint = $color; @@ -230,7 +230,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoat = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->clearcoat = $color; @@ -243,7 +243,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoatgloss = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->clearcoatgloss = $color; @@ -256,7 +256,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyFront = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->transparencyFront = $color; @@ -269,7 +269,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyBack = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->transparencyBack = $color; @@ -282,7 +282,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmamount = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->filmamount = $color; @@ -294,7 +294,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmthickness = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->filmthickness = $color; @@ -307,7 +307,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmior = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->filmior = $color; @@ -320,7 +320,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->bumptex = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->bumptex = $color; diff --git a/src/scene/materials/Glass.php b/src/scene/materials/Glass.php index b03a946..56561f0 100644 --- a/src/scene/materials/Glass.php +++ b/src/scene/materials/Glass.php @@ -86,57 +86,145 @@ class Glass extends MaterialsBase public function setUroughness($color) { - $this->uroughness = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->uroughness = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->uroughness = $color; } public function setVroughness($color) { - $this->vroughness = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->vroughness = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->vroughness = $color; } public function setTransparencyFront($color) { - $this->transparencyFront = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyFront = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyFront = $color; } public function setTransparencyBack($color) { - $this->transparencyBack = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyBack = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyBack = $color; } public function setBumptex($color) { - $this->bumptex = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->bumptex = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->bumptex = $color; } public function setFilmthickness($color) { - $this->filmthickness = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->filmthickness = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->filmthickness = $color; } public function setFilmior($color) { - $this->filmior = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->filmior = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->filmior = $color; } public function setTransmission($color) { - $this->kt = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->kt = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->kt = $color; } public function setRefraction($color) { - $this->kr = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->kr = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->kr = $color; } public function setInteriorIor($color) { - $this->interiorior = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->interiorior = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->interiorior = $color; } public function setCauchyb($color) { - $this->cauchyb = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->cauchyb = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->cauchyb = $color; } } diff --git a/src/scene/materials/Glossy.php b/src/scene/materials/Glossy.php index 192070a..8c63cc9 100644 --- a/src/scene/materials/Glossy.php +++ b/src/scene/materials/Glossy.php @@ -74,52 +74,132 @@ class Glossy extends MaterialsBase public function setUroughness($color) { - $this->uroughness = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->uroughness = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->uroughness = $color; } public function setVroughness($color) { - $this->vroughness = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->vroughness = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->vroughness = $color; } public function setTransparencyFront($color) { - $this->transparencyFront = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyFront = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyFront = $color; } public function setTransparencyBack($color) { - $this->transparencyBack = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyBack = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyBack = $color; } public function setBumptex($color) { - $this->bumptex = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->bumptex = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->bumptex = $color; } public function setBaseColor($color) { - $this->kd = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->kd = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->kd = $color; } public function setSpecular($color) { - $this->ks = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->ks = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->ks = $color; } public function setAbsorption($color) { - $this->ka = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->ka = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->ka = $color; } public function setAbsorptionDepht($color) { - $this->d = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->d = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->d = $color; } public function setIor($color) { - $this->index = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->index = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->index = $color; } public function openMultiBounce() diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index 8c66e79..3ba43a0 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -86,24 +86,48 @@ class MaterialsBase extends BaseCfg */ public $volumeExterior; - public function setEmission($color) + public function setEmission($color,Emission $emissionCfg = null,Visibility $visibility = null) { - $this->emission = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->emission = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->emission = $color; + + if( $emissionCfg != null ) $this->emissionCfg = $emissionCfg; + else $this->emissionCfg = new Emission(); + if( $visibility != null ) $this->visibility = $visibility; + else $this->visibility = new Visibility(); } - public function setVolumeInterior($color) + public function setVolumeInterior($volumeInterior) { - $this->volumeInterior = $color; + if( is_object( $volumeInterior ) ) + { + if( $volumeInterior->cards != null ) $this->volumeInterior = $volumeInterior->cards; + else + { + throw new \Exception("You use an unregistered ".$volumeInterior->getInstanceClassName()." object for the current property"); + } + } + else $this->volumeInterior = $volumeInterior; } - public function setVolumeExterior($color) + public function setVolumeExterior($volumeExterior) { - $this->volumeExterior = $color; - } - - public function getClassName() - { - return array_reverse(explode('\\', get_class($this)))[0]; + if( is_object( $volumeExterior ) ) + { + if( $volumeExterior->cards != null ) $this->volumeExterior = $volumeExterior->cards; + else + { + throw new \Exception("You use an unregistered ".$volumeExterior->getInstanceClassName()." object for the current property"); + } + } + else $this->volumeExterior = $volumeExterior; } } diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index 70c3b29..50ff45d 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -59,8 +59,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->kr = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->kr = $color; @@ -74,8 +73,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->fresnel = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->fresnel = $color; @@ -89,8 +87,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->uroughness = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->uroughness = $color; @@ -103,8 +100,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->vroughness = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->vroughness = $color; @@ -117,8 +113,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->transparencyFront = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->transparencyFront = $color; @@ -131,8 +126,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->transparencyBack = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->transparencyBack = $color; @@ -145,8 +139,7 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->bumptex = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new \Exception("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->bumptex = $color; diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index a56eb7f..e758a5e 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -42,7 +42,7 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material1 = $Material->cards; else { - throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); } } else $this->material1 = $Material; @@ -55,7 +55,7 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material2 = $Material->cards; else { - throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); } } else $this->material2 = $Material; @@ -68,7 +68,7 @@ class Mix extends MaterialsBase if( $color->cards != null ) $this->amount = $color->cards; else { - throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); } } else $this->amount = $color; diff --git a/src/scene/materials/NullMaterial.php b/src/scene/materials/NullMaterial.php index b006cef..b1d4dc6 100644 --- a/src/scene/materials/NullMaterial.php +++ b/src/scene/materials/NullMaterial.php @@ -33,17 +33,41 @@ class NullMaterial extends MaterialsBase public function setTransparencyFront($color) { - $this->transparencyFront = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyFront = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyFront = $color; } public function setTransparencyBack($color) { - $this->transparencyBack = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyBack = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyBack = $color; } public function setBumptex($color) { - $this->bumptex = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->bumptex = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->bumptex = $color; } } diff --git a/src/scene/materials/Roughmatte.php b/src/scene/materials/Roughmatte.php index c92f7f8..2465b9f 100644 --- a/src/scene/materials/Roughmatte.php +++ b/src/scene/materials/Roughmatte.php @@ -43,27 +43,67 @@ class Roughmatte extends MaterialsBase public function setTransparencyFront($color) { - $this->transparencyFront = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyFront = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyFront = $color; } public function setTransparencyBack($color) { - $this->transparencyBack = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->transparencyBack = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->transparencyBack = $color; } public function setBumptex($color) { - $this->bumptex = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->bumptex = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->bumptex = $color; } public function setBaseColor($color) { - $this->kd = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->kd = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->kd = $color; } public function setSigma($color) { - $this->sigma = $color; + if( is_object($color) ) + { + if( $color->cards != null ) $this->sigma = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->sigma = $color; } } diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index b1b1a96..b84118b 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -51,17 +51,12 @@ class Objects extends BaseCfg if( $material->cards != null ) $this->material = $material->cards; else { - throw new \Exception("You use an unregistered ".$material->getClassName()." object for the current property"); + throw new \Exception("You use an unregistered ".$material->getInstanceClassName()." object for the current property"); } } else $this->material = $material; } - public function getClassName() - { - return array_reverse(explode('\\', get_class($this)))[0]; - } - } ?> diff --git a/src/scene/render/Film.php b/src/scene/render/Film.php index 28ca8f9..88e9a8f 100644 --- a/src/scene/render/Film.php +++ b/src/scene/render/Film.php @@ -54,13 +54,15 @@ class Film extends BaseCfg public $outputs = []; /** - * @param object $noiseEstimation 必须传入一个 NoiseEstimationod类对象 - * @param object $filter 如果需要设置推荐一个默认的参数,则同时传入一个 Filter类对象 + * @param object $noiseEstimation 如需自定义NoiseEstimation参数,可以传入一个 NoiseEstimation类对象,否则使用一个默认的NoiseEstimation参数 + * @param object $filter 如需自定义抗锯齿参数,可以传入一个 Filter类对象,否则使用一个默认的抗锯齿参数 */ - public function __construct( NoiseEstimation $noiseEstimation,Filter $filter = null,$config = []) - { - $this->noiseEstimation = $noiseEstimation; - $this->filter = $filter; + public function __construct($config = [], NoiseEstimation $noiseEstimation = null,Filter $filter = null) + { + if($noiseEstimation != null) $this->noiseEstimation = $noiseEstimation; + else $this->noiseEstimation = new NoiseEstimation(); + if($filter != null) $this->filter = $filter; + else $this->filter = new Filter(); Base::__construct($config); } diff --git a/src/scene/render/OpenCL.php b/src/scene/render/OpenCL.php index 24d7e0c..c7494d8 100644 --- a/src/scene/render/OpenCL.php +++ b/src/scene/render/OpenCL.php @@ -45,7 +45,6 @@ class OpenCL extends BaseCfg $this->gpuUse = self::OPEN; } - } ?> diff --git a/src/scene/render/Path.php b/src/scene/render/Path.php index 59e1f6b..431e026 100644 --- a/src/scene/render/Path.php +++ b/src/scene/render/Path.php @@ -43,13 +43,15 @@ class Path extends BaseCfg /** - * @param object $pathDepth 必须传入一个 PathDepth类对象 - * @param object $hybridBackforWard 如果需要设置推荐一个默认的参数,则同时传入一个 HybridBackforWard类对象 + * @param object $pathDepth 如需自定义追踪深度参数,可以传入一个 PathDepth类对象,否则使用一个默认的追踪深度参数 + * @param object $hybridBackforWard 如需自定义HybridBackforWard参数,可以传入一个 HybridBackforWard类对象,否则使用一个默认的HybridBackforWard参数 */ - public function __construct(PathDepth $pathDepth,HybridBackforWard $hybridBackforWard = null,$config = []) - { - $this->pathDepth = $pathDepth; - $this->hybridBackforWard= $hybridBackforWard; + public function __construct($config = [],PathDepth $pathDepth = null,HybridBackforWard $hybridBackforWard = null) + { + if($pathDepth != null) $this->pathDepth = $pathDepth; + else $this->pathDepth = new PathDepth(); + if($hybridBackforWard != null) $this->hybridBackforWard= $hybridBackforWard; + else $this->hybridBackforWard = new HybridBackforWard(); Base::__construct($config); } diff --git a/src/scene/render/Sampler.php b/src/scene/render/Sampler.php index f5d61a3..8e325c8 100644 --- a/src/scene/render/Sampler.php +++ b/src/scene/render/Sampler.php @@ -34,11 +34,18 @@ class Sampler extends BaseCfg public $metropolis; /** - * 实例 一个Sobol类,作为默认的采样器配置参数 + * @param object 如需配置一个自定义采样器参数,可以传入一个 采样器类型的对象,否则使用一个默认的采样器参数 */ - public function __construct($config = []) - { - $this->sobol = new Sobol(); + public function __construct($config = [],$sampler = null) + { + if($sampler != null) + { + if( $sampler instanceof Sobol ) $this->sobol = $sampler; + else if( $sampler instanceof Random ) $this->random = $sampler; + else if( $sampler instanceof Metropolis ) $this->metropolis = $sampler; + else throw new \Exception("You initialize the sampler to pass a ".$sampler->getInstanceClassName()." object, not the sampler type"); + } + else $this->sobol = new Sobol(); Base::__construct($config); } diff --git a/src/scene/render/cache/LightStrategy.php b/src/scene/render/cache/LightStrategy.php index 45ee9d7..cee4439 100644 --- a/src/scene/render/cache/LightStrategy.php +++ b/src/scene/render/cache/LightStrategy.php @@ -39,12 +39,13 @@ class LightStrategy extends render\LightStrategy public $entry; /** - * @param object $entry 必须传入一个 Entry类对象 + * @param object $entry 如需自定义Entry参数,可以传入一个 Entry类对象,否则使用一个默认的Entry参数 */ - public function __construct(Entry $entry,$config = []) + public function __construct($config = [],Entry $entry = null) { + if($entry = null) $this->entry = $entry; + else $this->entry = new Entry(); $this->type = self::TYPE_DLS_CACHE; - $this->entry = $entry; Base::__construct($config); } diff --git a/src/scene/render/cache/PhotonGI.php b/src/scene/render/cache/PhotonGI.php index 6206e63..8d3ac8c 100644 --- a/src/scene/render/cache/PhotonGI.php +++ b/src/scene/render/cache/PhotonGI.php @@ -38,13 +38,15 @@ class PhotonGI extends BaseCfg public $caustic; /** - * @param object $indirect 必须传入一个 Indirect类对象 - * @param object $caustic 必须传入一个 Caustic类对象 + * @param object $indirect 如需自定义Indirect参数,可以传入一个 Indirect类对象,否则使用一个默认的Indirect参数 + * @param object $caustic 如需自定义Caustic参数,可以传入一个 Caustic类对象,否则使用一个默认的Caustic参数 */ - public function __construct(Indirect $indirect,Caustic $caustic,$config = []) - { - $this->indirect = $indirect; - $this->caustic = $caustic; + public function __construct($config = [],Indirect $indirect = null,Caustic $caustic = null) + { + if($indirect != null) $this->indirect = $indirect; + else $this->indirect = new Indirect(); + if($caustic != null) $this->caustic = $caustic; + else $this->caustic = new Caustic(); Base::__construct($config); } diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php index 3d31cab..003d055 100644 --- a/src/scene/texture/TextureBase.php +++ b/src/scene/texture/TextureBase.php @@ -21,12 +21,7 @@ class TextureBase extends BaseCfg * @var string 储存个由Scene类颁发的注册信息 */ public $cards; - - public function getClassName() - { - return array_reverse(explode('\\', get_class($this)))[0]; - } - + } ?> diff --git a/src/scene/texture/map/Blend.php b/src/scene/texture/map/Blend.php index e9727d6..76f0aad 100644 --- a/src/scene/texture/map/Blend.php +++ b/src/scene/texture/map/Blend.php @@ -59,7 +59,7 @@ class Blend extends TextureBase /** * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping = null,$config = []) + public function __construct($config = [],Mapping $mapping = null) { if( $mapping != null )$this->mapping = $mapping; else $this->mapping = new Mapping(); diff --git a/src/scene/texture/map/Clouds.php b/src/scene/texture/map/Clouds.php index 9a2614b..c07b84a 100644 --- a/src/scene/texture/map/Clouds.php +++ b/src/scene/texture/map/Clouds.php @@ -71,7 +71,7 @@ class Clouds extends TextureBase /** * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping = null,$config = []) + public function __construct($config = [],Mapping $mapping = null) { if( $mapping != null )$this->mapping = $mapping; else $this->mapping = new Mapping(); diff --git a/src/scene/texture/map/ImageMap.php b/src/scene/texture/map/ImageMap.php index 942f075..b12ef1a 100644 --- a/src/scene/texture/map/ImageMap.php +++ b/src/scene/texture/map/ImageMap.php @@ -46,7 +46,7 @@ class ImageMap extends TextureBase /** * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping = null,$config = []) + public function __construct($config = [],Mapping $mapping = null) { if( $mapping != null )$this->mapping = $mapping; else $this->mapping = new Mapping(); diff --git a/src/scene/texture/mapping/Triplanar.php b/src/scene/texture/mapping/Triplanar.php index a907c59..3b3d80a 100644 --- a/src/scene/texture/mapping/Triplanar.php +++ b/src/scene/texture/mapping/Triplanar.php @@ -39,7 +39,7 @@ class Triplanar extends TextureBase /** * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping = null,$config = []) + public function __construct($config = [],Mapping $mapping = null) { if( $mapping != null )$this->mapping = $mapping; else $this->mapping = new Mapping(); diff --git a/src/scene/texture/transform/NormalMap.php b/src/scene/texture/transform/NormalMap.php index 50a84e1..5dadd6f 100644 --- a/src/scene/texture/transform/NormalMap.php +++ b/src/scene/texture/transform/NormalMap.php @@ -22,9 +22,6 @@ class ImageMap extends TextureBase */ public $scale = 1; - /** - * @param $mapping 必须传入一个 Mapping类对象 - */ public function __construct($config = []) { $this->type = self::TYPE_NORMALMAP; diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php index 5f543ab..8513789 100644 --- a/src/scene/volumes/VolumesBase.php +++ b/src/scene/volumes/VolumesBase.php @@ -8,18 +8,12 @@ use Blobt\Luxcore\core\Base; class VolumesBase extends BaseCfg { - public function __construct($config = []) { $this->id = Scene::createID(); Base::__construct($config); } - public function getClassName() - { - return array_reverse(explode('\\', get_class($this)))[0]; - } - } ?>