diff --git a/src/scene/Scene.php b/src/scene/Scene.php index 98b0dde..0210c50 100644 --- a/src/scene/Scene.php +++ b/src/scene/Scene.php @@ -47,12 +47,34 @@ class Scene extends BaseCfg return $num; } + /** + * @param object $value 接收的是一个 由模型、材质、体积、纹理、灯光、相机类set函数 所接收到的值,本函数可以被这些类set函数调用, + * 并判断set函数接收到值是否合法,合法则返回$value,否则抛出一个异常 + */ + public static function testAbnormal($value) + { + if( is_object($value) ) + { + if( $value->registerId != null ) + { + return $value; + } + else + { + throw new \Exception("You use an unregistered ".$value->getInstanceClassName()." object for the current property"); + } + } + else + { + return $value; + } + } + /** * @param object $obj 接收一个模型类对象,为其颁发一个注册信息,并将其存到Scene */ public function registerObjects(&$obj) { - $temp = null; $temp = sprintf("%014d",$obj->id); $obj->registerId = $temp; if($obj->material == null) @@ -71,7 +93,6 @@ class Scene extends BaseCfg */ public function registerMaterial(&$material) { - $temp = null; $temp = $material->type.'_'.sprintf("%014d",$material->id); $material->registerId = $temp; $this->materials[$temp] = $material; @@ -82,7 +103,6 @@ class Scene extends BaseCfg */ public function registerTexture(&$texture) { - $temp = null; $temp = $texture->type.'_'.sprintf("%014d",$texture->id); $texture->registerId = $temp; $this->textures[$temp] = $texture; @@ -93,7 +113,6 @@ class Scene extends BaseCfg */ public function registerVolume(&$volume) { - $temp = null; $temp = $volume->type.'_'.sprintf("%014d",$volume->id); $volume->registerId = $temp; $this->volumes[$temp] = $volume; @@ -104,7 +123,6 @@ class Scene extends BaseCfg */ public function registerLight(&$light) { - $temp = null; $temp = $light->type.'_'.sprintf("%014d",$light->id); $light->registerId = $temp; $this->lights[$temp] = $light; @@ -115,7 +133,6 @@ class Scene extends BaseCfg */ public function registerCamera(&$camera) { - $temp = null; $temp = $camera->type.'_'.sprintf("%014d",$camera->id); $camera->registerId = $temp; $this->cameras[$temp] = $camera; diff --git a/src/scene/materials/CarPaint.php b/src/scene/materials/CarPaint.php index b1e5f11..04f5c31 100644 --- a/src/scene/materials/CarPaint.php +++ b/src/scene/materials/CarPaint.php @@ -88,15 +88,7 @@ class CarPaint extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } /** @@ -104,15 +96,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular1($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks1 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks1 = $color; + $this->ks1 = Scene::testAbnormal($color); } /** @@ -120,15 +104,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular2($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks2 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks2 = $color; + $this->ks2 = Scene::testAbnormal($color); } /** @@ -136,15 +112,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular3($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks3 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks3 = $color; + $this->ks3 = Scene::testAbnormal($color); } /** @@ -152,15 +120,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness1($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->m1 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->m1 = $color; + $this->m1 = Scene::testAbnormal($color); } /** @@ -168,15 +128,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness2($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->m2 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->m2 = $color; + $this->m2 = Scene::testAbnormal($color); } /** @@ -184,15 +136,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness3($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->m3 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->m3 = $color; + $this->m3 = Scene::testAbnormal($color); } /** @@ -200,15 +144,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy1($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->r1 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->r1 = $color; + $this->r1 = Scene::testAbnormal($color); } /** @@ -216,15 +152,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy2($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->r2 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->r2 = $color; + $this->r2 = Scene::testAbnormal($color); } /** @@ -232,15 +160,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy3($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->r3 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->r3 = $color; + $this->r3 = Scene::testAbnormal($color); } /** @@ -249,15 +169,7 @@ class CarPaint extends MaterialsBase */ public function setAbsorption($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ka = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ka = $color; + $this->ka = Scene::testAbnormal($color); } /** @@ -265,15 +177,7 @@ class CarPaint extends MaterialsBase */ public function setAbsorptionDepht($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->d = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->d = $color; + $this->d = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Cloth.php b/src/scene/materials/Cloth.php index 0003c41..590893b 100644 --- a/src/scene/materials/Cloth.php +++ b/src/scene/materials/Cloth.php @@ -71,15 +71,7 @@ class Cloth extends MaterialsBase */ public function setWarpBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->warp_kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->warp_kd = $color; + $this->warp_kd = Scene::testAbnormal($color); } /** @@ -87,15 +79,7 @@ class Cloth extends MaterialsBase */ public function setWeftBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->weft_kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->weft_kd = $color; + $this->weft_kd = Scene::testAbnormal($color); } /** @@ -103,15 +87,7 @@ class Cloth extends MaterialsBase */ public function setWarpSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->warp_ks = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->warp_ks = $color; + $this->warp_ks = Scene::testAbnormal($color); } /** @@ -119,15 +95,7 @@ class Cloth extends MaterialsBase */ public function setWeftSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->weft_ks = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->weft_ks = $color; + $this->weft_ks = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 316adce..1e4eb2b 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -98,15 +98,7 @@ class Disney extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->basecolor = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->basecolor = $color; + $this->basecolor = Scene::testAbnormal($color); } /** @@ -114,15 +106,7 @@ class Disney extends MaterialsBase */ public function setSubsurface($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->subsurface = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->subsurface = $color; + $this->subsurface = Scene::testAbnormal($color); } /** @@ -130,15 +114,7 @@ class Disney extends MaterialsBase */ public function setMetallic($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->metallic = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->metallic = $color; + $this->metallic = Scene::testAbnormal($color); } /** @@ -146,15 +122,7 @@ class Disney extends MaterialsBase */ public function setSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->specular = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->specular = $color; + $this->specular = Scene::testAbnormal($color); } /** @@ -162,15 +130,7 @@ class Disney extends MaterialsBase */ public function setSpeculartint($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->speculartint = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->speculartint = $color; + $this->speculartint = Scene::testAbnormal($color); } /** @@ -178,15 +138,7 @@ class Disney extends MaterialsBase */ public function setRoughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->roughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->roughness = $color; + $this->roughness = Scene::testAbnormal($color); } /** @@ -194,15 +146,7 @@ class Disney extends MaterialsBase */ public function setAnisotropic($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->anisotropic = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->anisotropic = $color; + $this->anisotropic = Scene::testAbnormal($color); } /** @@ -210,15 +154,7 @@ class Disney extends MaterialsBase */ public function setSheen($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->sheen = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->sheen = $color; + $this->sheen = Scene::testAbnormal($color); } /** @@ -226,15 +162,7 @@ class Disney extends MaterialsBase */ public function setSheentint($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->sheentint = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->sheentint = $color; + $this->sheentint = Scene::testAbnormal($color); } /** @@ -242,15 +170,7 @@ class Disney extends MaterialsBase */ public function setClearcoat($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->clearcoat = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->clearcoat = $color; + $this->clearcoat = Scene::testAbnormal($color); } /** @@ -258,15 +178,7 @@ class Disney extends MaterialsBase */ public function setClearcoatgloss($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->clearcoatgloss = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->clearcoatgloss = $color; + $this->clearcoatgloss = Scene::testAbnormal($color); } /** @@ -274,30 +186,15 @@ class Disney extends MaterialsBase */ public function setFilmamount($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmamount = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmamount = $color; + $this->filmamount = Scene::testAbnormal($color); } /** * @param object $color 接收一个贴图对象或小数形式的色值,设置Disney清漆涂层厚度 */ public function setFilmthickness($color) - { if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmthickness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmthickness = $color; + { + $this->filmthickness = Scene::testAbnormal($color); } /** @@ -305,15 +202,7 @@ class Disney extends MaterialsBase */ public function setFilmior($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmior = $color; + $this->filmior = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Glass.php b/src/scene/materials/Glass.php index dd972af..57c5e28 100644 --- a/src/scene/materials/Glass.php +++ b/src/scene/materials/Glass.php @@ -59,15 +59,7 @@ class Glass extends MaterialsBase */ public function setFilmthickness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmthickness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmthickness = $color; + $this->filmthickness = Scene::testAbnormal($color); } /** @@ -75,15 +67,7 @@ class Glass extends MaterialsBase */ public function setFilmior($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmior = $color; + $this->filmior = Scene::testAbnormal($color); } /** @@ -91,15 +75,7 @@ class Glass extends MaterialsBase */ public function setTransmission($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kt = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kt = $color; + $this->kt = Scene::testAbnormal($color); } /** @@ -107,15 +83,7 @@ class Glass extends MaterialsBase */ public function setRefraction($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kr = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kr = $color; + $this->kr = Scene::testAbnormal($color); } /** @@ -123,15 +91,7 @@ class Glass extends MaterialsBase */ public function setInteriorIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->interiorior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->interiorior = $color; + $this->interiorior = Scene::testAbnormal($color); } /** @@ -139,15 +99,7 @@ class Glass extends MaterialsBase */ public function setCauchyb($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->cauchyb = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->cauchyb = $color; + $this->cauchyb = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/GlassArch.php b/src/scene/materials/GlassArch.php index 047ee10..604d207 100644 --- a/src/scene/materials/GlassArch.php +++ b/src/scene/materials/GlassArch.php @@ -56,15 +56,7 @@ class GlassArch extends MaterialsBase */ public function setFilmthickness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmthickness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmthickness = $color; + $this->filmthickness = Scene::testAbnormal($color); } /** @@ -72,15 +64,7 @@ class GlassArch extends MaterialsBase */ public function setFilmior($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmior = $color; + $this->filmior = Scene::testAbnormal($color); } /** @@ -88,15 +72,7 @@ class GlassArch extends MaterialsBase */ public function setTransmission($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kt = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kt = $color; + $this->kt = Scene::testAbnormal($color); } /** @@ -104,15 +80,7 @@ class GlassArch extends MaterialsBase */ public function setRefraction($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kr = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kr = $color; + $this->kr = Scene::testAbnormal($color); } /** @@ -120,15 +88,7 @@ class GlassArch extends MaterialsBase */ public function setInteriorIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->interiorior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->interiorior = $color; + $this->interiorior = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/GlassRough.php b/src/scene/materials/GlassRough.php index fa43fc7..a119f89 100644 --- a/src/scene/materials/GlassRough.php +++ b/src/scene/materials/GlassRough.php @@ -64,15 +64,7 @@ class GlassRough extends MaterialsBase */ public function setUroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness = $color; + $this->uroughness = Scene::testAbnormal($color); } /** @@ -80,15 +72,7 @@ class GlassRough extends MaterialsBase */ public function setVroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness = $color; + $this->vroughness = Scene::testAbnormal($color); } /** @@ -96,15 +80,7 @@ class GlassRough extends MaterialsBase */ public function setFilmthickness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmthickness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmthickness = $color; + $this->filmthickness = Scene::testAbnormal($color); } /** @@ -112,15 +88,7 @@ class GlassRough extends MaterialsBase */ public function setFilmior($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->filmior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->filmior = $color; + $this->filmior = Scene::testAbnormal($color); } /** @@ -128,15 +96,7 @@ class GlassRough extends MaterialsBase */ public function setTransmission($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kt = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kt = $color; + $this->kt = Scene::testAbnormal($color); } /** @@ -144,15 +104,7 @@ class GlassRough extends MaterialsBase */ public function setRefraction($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kr = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kr = $color; + $this->kr = Scene::testAbnormal($color); } /** @@ -160,15 +112,7 @@ class GlassRough extends MaterialsBase */ public function setInteriorIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->interiorior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->interiorior = $color; + $this->interiorior = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Glossy.php b/src/scene/materials/Glossy.php index 0b559e4..b5b5eda 100644 --- a/src/scene/materials/Glossy.php +++ b/src/scene/materials/Glossy.php @@ -68,15 +68,7 @@ class Glossy extends MaterialsBase */ public function setUroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness = $color; + $this->uroughness = Scene::testAbnormal($color); } /** @@ -84,15 +76,7 @@ class Glossy extends MaterialsBase */ public function setVroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness = $color; + $this->vroughness = Scene::testAbnormal($color); } /** @@ -100,15 +84,7 @@ class Glossy extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } /** @@ -116,15 +92,7 @@ class Glossy extends MaterialsBase */ public function setSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks = $color; + $this->ks = Scene::testAbnormal($color); } /** @@ -133,15 +101,7 @@ class Glossy extends MaterialsBase */ public function setAbsorption($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ka = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ka = $color; + $this->ka = Scene::testAbnormal($color); } /** @@ -149,15 +109,7 @@ class Glossy extends MaterialsBase */ public function setAbsorptionDepht($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->d = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->d = $color; + $this->d = Scene::testAbnormal($color); } /** @@ -165,15 +117,7 @@ class Glossy extends MaterialsBase */ public function setIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->index = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->index = $color; + $this->index = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/GlossyCoating.php b/src/scene/materials/GlossyCoating.php index 179cf5c..98d7a17 100644 --- a/src/scene/materials/GlossyCoating.php +++ b/src/scene/materials/GlossyCoating.php @@ -69,15 +69,7 @@ class GlossyCoating extends MaterialsBase */ public function setUroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness = $color; + $this->uroughness = Scene::testAbnormal($color); } /** @@ -85,31 +77,15 @@ class GlossyCoating extends MaterialsBase */ public function setVroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness = $color; + $this->vroughness = Scene::testAbnormal($color); } /** - * @param object $Material 接收一个材质对象,设置GlossyCoating材质的基会材质 + * @param object $material 接收一个材质对象,设置GlossyCoating材质的基会材质 */ public function setBase($material) { - if( is_object($material) ) - { - if( $material->registerId != null ) $this->base = $material->registerId; - else - { - throw new \Exception("You use an unregistered ".$material->getInstanceClassName()." object for the current property"); - } - } - else $this->base = $material; + $this->base = $material; } /** @@ -117,15 +93,7 @@ class GlossyCoating extends MaterialsBase */ public function setSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks = $color; + $this->ks = Scene::testAbnormal($color); } /** @@ -134,15 +102,7 @@ class GlossyCoating extends MaterialsBase */ public function setAbsorption($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ka = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ka = $color; + $this->ka = Scene::testAbnormal($color); } /** @@ -150,15 +110,7 @@ class GlossyCoating extends MaterialsBase */ public function setAbsorptionDepht($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->d = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->d = $color; + $this->d = Scene::testAbnormal($color); } /** @@ -166,15 +118,7 @@ class GlossyCoating extends MaterialsBase */ public function setIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->index = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->index = $color; + $this->index = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/GlossyTranslucent.php b/src/scene/materials/GlossyTranslucent.php index c5f23d4..838c004 100644 --- a/src/scene/materials/GlossyTranslucent.php +++ b/src/scene/materials/GlossyTranslucent.php @@ -113,15 +113,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setUroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness = $color; + $this->uroughness = Scene::testAbnormal($color); } /** @@ -129,15 +121,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setVroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness = $color; + $this->vroughness = Scene::testAbnormal($color); } /** @@ -145,15 +129,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } /** @@ -161,15 +137,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setSpecular($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks = $color; + $this->ks = Scene::testAbnormal($color); } /** @@ -177,15 +145,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setTransmission($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kt = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kt = $color; + $this->kt = Scene::testAbnormal($color); } /** @@ -194,15 +154,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorption($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ka = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ka = $color; + $this->ka = Scene::testAbnormal($color); } /** @@ -210,15 +162,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorptionDepht($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->d = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->d = $color; + $this->d = Scene::testAbnormal($color); } /** @@ -226,15 +170,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->index = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->index = $color; + $this->index = Scene::testAbnormal($color); } @@ -246,15 +182,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setUroughness_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness_bf = $color; + $this->uroughness_bf = Scene::testAbnormal($color); } /** @@ -262,15 +190,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setVroughness_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness_bf = $color; + $this->vroughness_bf = Scene::testAbnormal($color); } /** @@ -278,15 +198,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setSpecular_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ks_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ks_bf = $color; + $this->ks_bf = Scene::testAbnormal($color); } /** @@ -295,15 +207,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorption_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ka_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ka_bf = $color; + $this->ka_bf = Scene::testAbnormal($color); } /** @@ -311,15 +215,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorptionDepht_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->d_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->d_bf = $color; + $this->d_bf = Scene::testAbnormal($color); } /** @@ -327,15 +223,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setIor_BF($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->index_bf = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->index_bf = $color; + $this->index_bf = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index adeecdb..da19eb1 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -2,6 +2,7 @@ namespace Blobt\Luxcore\scene\materials; use Blobt\Luxcore\scene\BaseCfg; +use Blobt\Luxcore\scene\Scene; @@ -109,15 +110,7 @@ class MaterialsBase extends BaseCfg */ public function setTransparencyFront($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->transparencyFront = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->transparencyFront = $color; + $this->transparencyFront = Scene::testAbnormal($color); } /** @@ -125,15 +118,7 @@ class MaterialsBase extends BaseCfg */ public function setTransparencyBack($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->transparencyBack = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->transparencyBack = $color; + $this->transparencyBack = Scene::testAbnormal($color); } /** @@ -141,15 +126,7 @@ class MaterialsBase extends BaseCfg */ public function setBumptex($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->bumptex = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->bumptex = $color; + $this->bumptex = Scene::testAbnormal($color); } /** @@ -157,15 +134,7 @@ class MaterialsBase extends BaseCfg */ public function setEmission($color,Emission $emissionCfg = null,Visibility $visibility = null) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->emission = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->emission = $color; + $this->emission = Scene::testAbnormal($color); if( $emissionCfg != null ) $this->emissionCfg = $emissionCfg; else $this->emissionCfg = new Emission(); @@ -174,35 +143,19 @@ class MaterialsBase extends BaseCfg } /** - * @param object $color 接收一个贴图对象或小数形式的色值,设置材质的内部体积属性 + * @param object $volumeInterior 接收一个体积对象,设置材质的内部体积属性 */ public function setVolumeInterior($volumeInterior) { - if( is_object( $volumeInterior ) ) - { - if( $volumeInterior->registerId != null ) $this->volumeInterior = $volumeInterior->registerId; - else - { - throw new \Exception("You use an unregistered ".$volumeInterior->getInstanceClassName()." object for the current property"); - } - } - else $this->volumeInterior = $volumeInterior; + $this->volumeInterior = Scene::testAbnormal($volumeInterior); } /** - * @param object $color 接收一个贴图对象或小数形式的色值,设置材质的外部体积属性 + * @param object $volumeExterior 接收一个体积对象,设置材质的外部体积属性 */ public function setVolumeExterior($volumeExterior) { - if( is_object( $volumeExterior ) ) - { - if( $volumeExterior->registerId != null ) $this->volumeExterior = $volumeExterior->registerId; - else - { - throw new \Exception("You use an unregistered ".$volumeExterior->getInstanceClassName()." object for the current property"); - } - } - else $this->volumeExterior = $volumeExterior; + $this->volumeExterior = Scene::testAbnormal($volumeExterior); } } diff --git a/src/scene/materials/Matte.php b/src/scene/materials/Matte.php index 7105cd9..ed67002 100644 --- a/src/scene/materials/Matte.php +++ b/src/scene/materials/Matte.php @@ -32,15 +32,7 @@ class Matte extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/MatteRough.php b/src/scene/materials/MatteRough.php index 050eeb4..fd64fec 100644 --- a/src/scene/materials/MatteRough.php +++ b/src/scene/materials/MatteRough.php @@ -37,15 +37,7 @@ class MatteRough extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } /** @@ -53,15 +45,7 @@ class MatteRough extends MaterialsBase */ public function setSigma($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->sigma = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->sigma = $color; + $this->sigma = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/MatteTranslucent.php b/src/scene/materials/MatteTranslucent.php index 432d7b8..0846f8d 100644 --- a/src/scene/materials/MatteTranslucent.php +++ b/src/scene/materials/MatteTranslucent.php @@ -37,15 +37,7 @@ class Roughmatte extends MaterialsBase */ public function setRefraction($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kr = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kr = $color; + $this->kr = Scene::testAbnormal($color); } /** @@ -53,15 +45,7 @@ class Roughmatte extends MaterialsBase */ public function setTransmission($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kt = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kt = $color; + $this->kt = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index 803b024..c476361 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -44,15 +44,7 @@ class Metal extends MaterialsBase */ public function setFresnel($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->fresnel = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->fresnel = $color; + $this->fresnel = Scene::testAbnormal($color); } @@ -61,15 +53,7 @@ class Metal extends MaterialsBase */ public function setUroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->uroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->uroughness = $color; + $this->uroughness = Scene::testAbnormal($color); } /** @@ -77,15 +61,7 @@ class Metal extends MaterialsBase */ public function setVroughness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->vroughness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->vroughness = $color; + $this->vroughness = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Mirror.php b/src/scene/materials/Mirror.php index 6fd9125..6fa5a7c 100644 --- a/src/scene/materials/Mirror.php +++ b/src/scene/materials/Mirror.php @@ -32,15 +32,7 @@ class Mirror extends MaterialsBase */ public function setRefraction($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kr = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kr = $color; + $this->kr = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index 85ad04a..7fcf361 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -37,35 +37,19 @@ class Mix extends MaterialsBase } /** - * @param object $Material 接收一个材质对象,设置混合材质的第一个材质通道 + * @param object $material 接收一个材质对象,设置混合材质的第一个材质通道 */ - public function setMaterial1($Material) + public function setMaterial1($material) { - if( is_object( $Material ) ) - { - if( $Material->registerId != null ) $this->material1 = $Material->registerId; - else - { - throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); - } - } - else $this->material1 = $Material; + $this->material1 = Scene::testAbnormal($material); } /** - * @param object $Material 接收一个材质对象,设置混合材质的第一个材质通道 + * @param object $material 接收一个材质对象,设置混合材质的第一个材质通道 */ - public function setMaterial2($Material) + public function setMaterial2($material) { - if( is_object( $Material ) ) - { - if( $Material->registerId != null ) $this->material2 = $Material->registerId; - else - { - throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); - } - } - else $this->material2 = $Material; + $this->material2 = Scene::testAbnormal($material); } /** @@ -73,15 +57,7 @@ class Mix extends MaterialsBase */ public function setAmount($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->amount = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->amount = $color; + $this->amount = Scene::testAbnormal($color); } } diff --git a/src/scene/materials/TwoSided.php b/src/scene/materials/TwoSided.php index 0324afb..c97df89 100644 --- a/src/scene/materials/TwoSided.php +++ b/src/scene/materials/TwoSided.php @@ -33,35 +33,19 @@ class TwoSided extends MaterialsBase } /** - * @param object $Material 接收一个材质对象,设置双面材质的正面材质通道 + * @param object $material 接收一个材质对象,设置双面材质的正面材质通道 */ - public function setMaterial1($Material) + public function setMaterial1($material) { - if( is_object( $Material ) ) - { - if( $Material->registerId != null ) $this->frontmaterial = $Material->registerId; - else - { - throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); - } - } - else $this->frontmaterial = $Material; + $this->frontmaterial = Scene::testAbnormal($material); } /** - * @param object $Material 接收一个材质对象,设置双面材质的背面材质通道 + * @param object $material 接收一个材质对象,设置双面材质的背面材质通道 */ - public function setMaterial2($Material) + public function setMaterial2($material) { - if( is_object( $Material ) ) - { - if( $Material->registerId != null ) $this->backmaterial = $Material->registerId; - else - { - throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property"); - } - } - else $this->backmaterial = $Material; + $this->backmaterial = Scene::testAbnormal($material); } } diff --git a/src/scene/materials/Velvet.php b/src/scene/materials/Velvet.php index c43b5e9..596948e 100644 --- a/src/scene/materials/Velvet.php +++ b/src/scene/materials/Velvet.php @@ -51,15 +51,7 @@ class Velvet extends MaterialsBase */ public function setBaseColor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->kd = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->kd = $color; + $this->kd = Scene::testAbnormal($color); } /** @@ -67,15 +59,7 @@ class Velvet extends MaterialsBase */ public function setP1($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->p1 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->p1 = $color; + $this->p1 = Scene::testAbnormal($color); } /** @@ -83,15 +67,7 @@ class Velvet extends MaterialsBase */ public function setP2($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->p2 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->p2 = $color; + $this->p2 = Scene::testAbnormal($color); } /** @@ -99,15 +75,7 @@ class Velvet extends MaterialsBase */ public function setP3($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->p3 = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->p3 = $color; + $this->p3 = Scene::testAbnormal($color); } /** @@ -115,15 +83,7 @@ class Velvet extends MaterialsBase */ public function setThickness($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->thickness = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->thickness = $color; + $this->thickness = Scene::testAbnormal($color); } } diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index e7f0525..7d16504 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -52,15 +52,7 @@ class Objects extends BaseCfg */ public function setMaterial($material) { - if( is_object( $material ) ) - { - if( $material->registerId != null ) $this->material = $material->registerId; - else - { - throw new \Exception("You use an unregistered ".$material->getInstanceClassName()." object for the current property"); - } - } - else $this->material = $material; + $this->material = Scene::testAbnormal($material); } } diff --git a/src/scene/texture/procedural/Blend.php b/src/scene/texture/procedural/Blend.php index dc35ec1..fcbffba 100644 --- a/src/scene/texture/procedural/Blend.php +++ b/src/scene/texture/procedural/Blend.php @@ -57,7 +57,8 @@ class Blend extends TextureBase public $mapping; /** - * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 + * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ public function __construct($config = [],Mapping $mapping = null) { diff --git a/src/scene/texture/procedural/Brick.php b/src/scene/texture/procedural/Brick.php index 7aeee33..e34bb31 100644 --- a/src/scene/texture/procedural/Brick.php +++ b/src/scene/texture/procedural/Brick.php @@ -99,15 +99,7 @@ class Brick extends TextureBase */ public function setBricktex($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->bricktex = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->bricktex = $color; + $this->bricktex = Scene::testAbnormal($color); } /** @@ -115,15 +107,7 @@ class Brick extends TextureBase */ public function setBrickmodtex($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->brickmodtex = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->brickmodtex = $color; + $this->brickmodtex = Scene::testAbnormal($color); } /** @@ -131,15 +115,7 @@ class Brick extends TextureBase */ public function setMortartex($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->mortartex = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->mortartex = $color; + $this->mortartex = Scene::testAbnormal($color); } } diff --git a/src/scene/texture/procedural/Clouds.php b/src/scene/texture/procedural/Clouds.php index 3c4f9a1..39f338a 100644 --- a/src/scene/texture/procedural/Clouds.php +++ b/src/scene/texture/procedural/Clouds.php @@ -69,7 +69,8 @@ class Clouds extends TextureBase public $mapping; /** - * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 + * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ public function __construct($config = [],Mapping $mapping = null) { diff --git a/src/scene/texture/procedural/ImageMap.php b/src/scene/texture/procedural/ImageMap.php index 32d6797..d325ad1 100644 --- a/src/scene/texture/procedural/ImageMap.php +++ b/src/scene/texture/procedural/ImageMap.php @@ -47,6 +47,7 @@ class ImageMap extends TextureBase public $mapping; /** + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ public function __construct($config = [],Mapping $mapping = null) diff --git a/src/scene/texture/transform/NormalMap.php b/src/scene/texture/transform/NormalMap.php index 9adc94f..abad809 100644 --- a/src/scene/texture/transform/NormalMap.php +++ b/src/scene/texture/transform/NormalMap.php @@ -23,7 +23,10 @@ class ImageMap extends TextureBase * @var integer TODO: 具体作用尚未明确,(固定取值:1) */ public $scale = 1; - + + /** + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 + */ public function __construct($config = []) { $this->type = self::TYPE_NORMALMAP; diff --git a/src/scene/volumes/HeteroGeneous.php b/src/scene/volumes/HeteroGeneous.php index b8964b7..ffe7915 100644 --- a/src/scene/volumes/HeteroGeneous.php +++ b/src/scene/volumes/HeteroGeneous.php @@ -34,6 +34,9 @@ class HomoGeneous extends VolumesBase */ public $stepsMaxcount = 1024; + /** + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 + */ public function __construct($config = []) { $this->type = self::TYPE_HETEROGENEOUS; @@ -41,30 +44,20 @@ class HomoGeneous extends VolumesBase core\Base::__construct($config); } + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的非均匀颜色 + */ public function setAsymmetry($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->asymmetry = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->asymmetry = $color; + $this->asymmetry = Scene::testAbnormal($color); } + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的散射颜色 + */ public function setScattering($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->scattering = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->scattering = $color; + $this->scattering = Scene::testAbnormal($color); } } diff --git a/src/scene/volumes/HomoGeneous.php b/src/scene/volumes/HomoGeneous.php index 538cb77..c024c62 100644 --- a/src/scene/volumes/HomoGeneous.php +++ b/src/scene/volumes/HomoGeneous.php @@ -24,37 +24,30 @@ class HomoGeneous extends VolumesBase */ public $multiscattering = false; + /** + * @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性 + */ public function __construct($config = []) { $this->type = self::TYPE_HOMOGENEOUS; $this->id = Scene::createID(); core\Base::__construct($config); } - + + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的非均匀颜色 + */ public function setAsymmetry($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->asymmetry = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->asymmetry = $color; + $this->asymmetry = Scene::testAbnormal($color); } + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的散射颜色 + */ public function setScattering($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->scattering = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->scattering = $color; + $this->scattering = Scene::testAbnormal($color); } } diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php index f790162..4b22609 100644 --- a/src/scene/volumes/VolumesBase.php +++ b/src/scene/volumes/VolumesBase.php @@ -2,6 +2,7 @@ namespace Blobt\Luxcore\scene\volumes; use Blobt\Luxcore\scene\BaseCfg; +use Blobt\Luxcore\scene\Scene; class VolumesBase extends BaseCfg { @@ -55,45 +56,30 @@ class VolumesBase extends BaseCfg * @var integer 当前体积的ID号(取值:大于0的整数) */ public $id; - + + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的自发光颜色 + */ public function setEmission($color,$emissionId = 0) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->emission = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->emission = $color; + $this->emission = Scene::testAbnormal($color); $this->emissionId = $emissionId; } + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的吸收颜色 + */ public function setAbsorption($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->absorption = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->absorption = $color; + $this->absorption = Scene::testAbnormal($color); } + /** + * @param object $color 接收一个贴图对象或小数形式的色值,设置体积材质的折射率 + */ public function setIor($color) { - if( is_object($color) ) - { - if( $color->registerId != null ) $this->ior = $color->registerId; - else - { - throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); - } - } - else $this->ior = $color; + $this->ior = Scene::testAbnormal($color); } }