diff --git a/examples/PrintRender.php b/examples/printRender.php similarity index 100% rename from examples/PrintRender.php rename to examples/printRender.php diff --git a/examples/PrintScene.php b/examples/printScene.php similarity index 100% rename from examples/PrintScene.php rename to examples/printScene.php diff --git a/src/scene/Scene.php b/src/scene/Scene.php index d800b22..59f4b8b 100644 --- a/src/scene/Scene.php +++ b/src/scene/Scene.php @@ -47,36 +47,14 @@ 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->registerId; - } - 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 = sprintf("%014d",$obj->id); - $obj->registerId = $temp; + $id = sprintf("%014d",$obj->id); + $obj->registerId = $id; if($obj->material == null) { if( !array_key_exists('__default',$this->materials ) ) @@ -85,7 +63,7 @@ class Scene extends BaseCfg } $obj->material = '__default'; } - $this->objects[$temp] = $obj; + $this->objects[$id] = $obj; } /** @@ -93,9 +71,9 @@ class Scene extends BaseCfg */ public function registerMaterial(&$material) { - $temp = $material->type.'_'.sprintf("%014d",$material->id); - $material->registerId = $temp; - $this->materials[$temp] = $material; + $id = $material->type.'_'.sprintf("%014d",$material->id); + $material->registerId = $id; + $this->materials[$id] = $material; } /** @@ -103,9 +81,9 @@ class Scene extends BaseCfg */ public function registerTexture(&$texture) { - $temp = $texture->type.'_'.sprintf("%014d",$texture->id); - $texture->registerId = $temp; - $this->textures[$temp] = $texture; + $id = $texture->type.'_'.sprintf("%014d",$texture->id); + $texture->registerId = $id; + $this->textures[$id] = $texture; } /** @@ -113,9 +91,9 @@ class Scene extends BaseCfg */ public function registerVolume(&$volume) { - $temp = $volume->type.'_'.sprintf("%014d",$volume->id); - $volume->registerId = $temp; - $this->volumes[$temp] = $volume; + $id = $volume->type.'_'.sprintf("%014d",$volume->id); + $volume->registerId = $id; + $this->volumes[$id] = $volume; } /** @@ -123,9 +101,9 @@ class Scene extends BaseCfg */ public function registerLight(&$light) { - $temp = $light->type.'_'.sprintf("%014d",$light->id); - $light->registerId = $temp; - $this->lights[$temp] = $light; + $id = $light->type.'_'.sprintf("%014d",$light->id); + $light->registerId = $id; + $this->lights[$id] = $light; } /** @@ -133,9 +111,9 @@ class Scene extends BaseCfg */ public function registerCamera(&$camera) { - $temp = $camera->type.'_'.sprintf("%014d",$camera->id); - $camera->registerId = $temp; - $this->cameras[$temp] = $camera; + $id = $camera->type.'_'.sprintf("%014d",$camera->id); + $camera->registerId = $id; + $this->cameras[$id] = $camera; } } diff --git a/src/scene/materials/CarPaint.php b/src/scene/materials/CarPaint.php index 04f5c31..dc61ca9 100644 --- a/src/scene/materials/CarPaint.php +++ b/src/scene/materials/CarPaint.php @@ -88,7 +88,7 @@ class CarPaint extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } /** @@ -96,7 +96,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular1($color) { - $this->ks1 = Scene::testAbnormal($color); + $this->ks1 = $this->judgeAttribute($color); } /** @@ -104,7 +104,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular2($color) { - $this->ks2 = Scene::testAbnormal($color); + $this->ks2 = $this->judgeAttribute($color); } /** @@ -112,7 +112,7 @@ class CarPaint extends MaterialsBase */ public function setSpecular3($color) { - $this->ks3 = Scene::testAbnormal($color); + $this->ks3 = $this->judgeAttribute($color); } /** @@ -120,7 +120,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness1($color) { - $this->m1 = Scene::testAbnormal($color); + $this->m1 = $this->judgeAttribute($color); } /** @@ -128,7 +128,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness2($color) { - $this->m2 = Scene::testAbnormal($color); + $this->m2 = $this->judgeAttribute($color); } /** @@ -136,7 +136,7 @@ class CarPaint extends MaterialsBase */ public function setMicrofacetRoughness3($color) { - $this->m3 = Scene::testAbnormal($color); + $this->m3 = $this->judgeAttribute($color); } /** @@ -144,7 +144,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy1($color) { - $this->r1 = Scene::testAbnormal($color); + $this->r1 = $this->judgeAttribute($color); } /** @@ -152,7 +152,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy2($color) { - $this->r2 = Scene::testAbnormal($color); + $this->r2 = $this->judgeAttribute($color); } /** @@ -160,7 +160,7 @@ class CarPaint extends MaterialsBase */ public function setGlossy3($color) { - $this->r3 = Scene::testAbnormal($color); + $this->r3 = $this->judgeAttribute($color); } /** @@ -169,7 +169,7 @@ class CarPaint extends MaterialsBase */ public function setAbsorption($color) { - $this->ka = Scene::testAbnormal($color); + $this->ka = $this->judgeAttribute($color); } /** @@ -177,7 +177,7 @@ class CarPaint extends MaterialsBase */ public function setAbsorptionDepht($color) { - $this->d = Scene::testAbnormal($color); + $this->d = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Cloth.php b/src/scene/materials/Cloth.php index 590893b..ef2ff0d 100644 --- a/src/scene/materials/Cloth.php +++ b/src/scene/materials/Cloth.php @@ -71,7 +71,7 @@ class Cloth extends MaterialsBase */ public function setWarpBaseColor($color) { - $this->warp_kd = Scene::testAbnormal($color); + $this->warp_kd = $this->judgeAttribute($color); } /** @@ -79,7 +79,7 @@ class Cloth extends MaterialsBase */ public function setWeftBaseColor($color) { - $this->weft_kd = Scene::testAbnormal($color); + $this->weft_kd = $this->judgeAttribute($color); } /** @@ -87,7 +87,7 @@ class Cloth extends MaterialsBase */ public function setWarpSpecular($color) { - $this->warp_ks = Scene::testAbnormal($color); + $this->warp_ks = $this->judgeAttribute($color); } /** @@ -95,7 +95,7 @@ class Cloth extends MaterialsBase */ public function setWeftSpecular($color) { - $this->weft_ks = Scene::testAbnormal($color); + $this->weft_ks = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 1e4eb2b..d89ad48 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -98,7 +98,7 @@ class Disney extends MaterialsBase */ public function setBaseColor($color) { - $this->basecolor = Scene::testAbnormal($color); + $this->basecolor = $this->judgeAttribute($color); } /** @@ -106,7 +106,7 @@ class Disney extends MaterialsBase */ public function setSubsurface($color) { - $this->subsurface = Scene::testAbnormal($color); + $this->subsurface = $this->judgeAttribute($color); } /** @@ -114,7 +114,7 @@ class Disney extends MaterialsBase */ public function setMetallic($color) { - $this->metallic = Scene::testAbnormal($color); + $this->metallic = $this->judgeAttribute($color); } /** @@ -122,7 +122,7 @@ class Disney extends MaterialsBase */ public function setSpecular($color) { - $this->specular = Scene::testAbnormal($color); + $this->specular = $this->judgeAttribute($color); } /** @@ -130,7 +130,7 @@ class Disney extends MaterialsBase */ public function setSpeculartint($color) { - $this->speculartint = Scene::testAbnormal($color); + $this->speculartint = $this->judgeAttribute($color); } /** @@ -138,7 +138,7 @@ class Disney extends MaterialsBase */ public function setRoughness($color) { - $this->roughness = Scene::testAbnormal($color); + $this->roughness = $this->judgeAttribute($color); } /** @@ -146,7 +146,7 @@ class Disney extends MaterialsBase */ public function setAnisotropic($color) { - $this->anisotropic = Scene::testAbnormal($color); + $this->anisotropic = $this->judgeAttribute($color); } /** @@ -154,7 +154,7 @@ class Disney extends MaterialsBase */ public function setSheen($color) { - $this->sheen = Scene::testAbnormal($color); + $this->sheen = $this->judgeAttribute($color); } /** @@ -162,7 +162,7 @@ class Disney extends MaterialsBase */ public function setSheentint($color) { - $this->sheentint = Scene::testAbnormal($color); + $this->sheentint = $this->judgeAttribute($color); } /** @@ -170,7 +170,7 @@ class Disney extends MaterialsBase */ public function setClearcoat($color) { - $this->clearcoat = Scene::testAbnormal($color); + $this->clearcoat = $this->judgeAttribute($color); } /** @@ -178,7 +178,7 @@ class Disney extends MaterialsBase */ public function setClearcoatgloss($color) { - $this->clearcoatgloss = Scene::testAbnormal($color); + $this->clearcoatgloss = $this->judgeAttribute($color); } /** @@ -186,7 +186,7 @@ class Disney extends MaterialsBase */ public function setFilmamount($color) { - $this->filmamount = Scene::testAbnormal($color); + $this->filmamount = $this->judgeAttribute($color); } /** @@ -194,7 +194,7 @@ class Disney extends MaterialsBase */ public function setFilmthickness($color) { - $this->filmthickness = Scene::testAbnormal($color); + $this->filmthickness = $this->judgeAttribute($color); } /** @@ -202,7 +202,7 @@ class Disney extends MaterialsBase */ public function setFilmior($color) { - $this->filmior = Scene::testAbnormal($color); + $this->filmior = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Glass.php b/src/scene/materials/Glass.php index 57c5e28..5050d03 100644 --- a/src/scene/materials/Glass.php +++ b/src/scene/materials/Glass.php @@ -59,7 +59,7 @@ class Glass extends MaterialsBase */ public function setFilmthickness($color) { - $this->filmthickness = Scene::testAbnormal($color); + $this->filmthickness = $this->judgeAttribute($color); } /** @@ -67,7 +67,7 @@ class Glass extends MaterialsBase */ public function setFilmior($color) { - $this->filmior = Scene::testAbnormal($color); + $this->filmior = $this->judgeAttribute($color); } /** @@ -75,7 +75,7 @@ class Glass extends MaterialsBase */ public function setTransmission($color) { - $this->kt = Scene::testAbnormal($color); + $this->kt = $this->judgeAttribute($color); } /** @@ -83,7 +83,7 @@ class Glass extends MaterialsBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } /** @@ -91,7 +91,7 @@ class Glass extends MaterialsBase */ public function setInteriorIor($color) { - $this->interiorior = Scene::testAbnormal($color); + $this->interiorior = $this->judgeAttribute($color); } /** @@ -99,7 +99,7 @@ class Glass extends MaterialsBase */ public function setCauchyb($color) { - $this->cauchyb = Scene::testAbnormal($color); + $this->cauchyb = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/GlassArch.php b/src/scene/materials/GlassArch.php index 604d207..daf0b33 100644 --- a/src/scene/materials/GlassArch.php +++ b/src/scene/materials/GlassArch.php @@ -56,7 +56,7 @@ class GlassArch extends MaterialsBase */ public function setFilmthickness($color) { - $this->filmthickness = Scene::testAbnormal($color); + $this->filmthickness = $this->judgeAttribute($color); } /** @@ -64,7 +64,7 @@ class GlassArch extends MaterialsBase */ public function setFilmior($color) { - $this->filmior = Scene::testAbnormal($color); + $this->filmior = $this->judgeAttribute($color); } /** @@ -72,7 +72,7 @@ class GlassArch extends MaterialsBase */ public function setTransmission($color) { - $this->kt = Scene::testAbnormal($color); + $this->kt = $this->judgeAttribute($color); } /** @@ -80,7 +80,7 @@ class GlassArch extends MaterialsBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } /** @@ -88,7 +88,7 @@ class GlassArch extends MaterialsBase */ public function setInteriorIor($color) { - $this->interiorior = Scene::testAbnormal($color); + $this->interiorior = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/GlassRough.php b/src/scene/materials/GlassRough.php index a119f89..218e08c 100644 --- a/src/scene/materials/GlassRough.php +++ b/src/scene/materials/GlassRough.php @@ -64,7 +64,7 @@ class GlassRough extends MaterialsBase */ public function setUroughness($color) { - $this->uroughness = Scene::testAbnormal($color); + $this->uroughness = $this->judgeAttribute($color); } /** @@ -72,7 +72,7 @@ class GlassRough extends MaterialsBase */ public function setVroughness($color) { - $this->vroughness = Scene::testAbnormal($color); + $this->vroughness = $this->judgeAttribute($color); } /** @@ -80,7 +80,7 @@ class GlassRough extends MaterialsBase */ public function setFilmthickness($color) { - $this->filmthickness = Scene::testAbnormal($color); + $this->filmthickness = $this->judgeAttribute($color); } /** @@ -88,7 +88,7 @@ class GlassRough extends MaterialsBase */ public function setFilmior($color) { - $this->filmior = Scene::testAbnormal($color); + $this->filmior = $this->judgeAttribute($color); } /** @@ -96,7 +96,7 @@ class GlassRough extends MaterialsBase */ public function setTransmission($color) { - $this->kt = Scene::testAbnormal($color); + $this->kt = $this->judgeAttribute($color); } /** @@ -104,7 +104,7 @@ class GlassRough extends MaterialsBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } /** @@ -112,7 +112,7 @@ class GlassRough extends MaterialsBase */ public function setInteriorIor($color) { - $this->interiorior = Scene::testAbnormal($color); + $this->interiorior = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Glossy.php b/src/scene/materials/Glossy.php index b5b5eda..4ceb45b 100644 --- a/src/scene/materials/Glossy.php +++ b/src/scene/materials/Glossy.php @@ -68,7 +68,7 @@ class Glossy extends MaterialsBase */ public function setUroughness($color) { - $this->uroughness = Scene::testAbnormal($color); + $this->uroughness = $this->judgeAttribute($color); } /** @@ -76,7 +76,7 @@ class Glossy extends MaterialsBase */ public function setVroughness($color) { - $this->vroughness = Scene::testAbnormal($color); + $this->vroughness = $this->judgeAttribute($color); } /** @@ -84,7 +84,7 @@ class Glossy extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } /** @@ -92,7 +92,7 @@ class Glossy extends MaterialsBase */ public function setSpecular($color) { - $this->ks = Scene::testAbnormal($color); + $this->ks = $this->judgeAttribute($color); } /** @@ -101,7 +101,7 @@ class Glossy extends MaterialsBase */ public function setAbsorption($color) { - $this->ka = Scene::testAbnormal($color); + $this->ka = $this->judgeAttribute($color); } /** @@ -109,7 +109,7 @@ class Glossy extends MaterialsBase */ public function setAbsorptionDepht($color) { - $this->d = Scene::testAbnormal($color); + $this->d = $this->judgeAttribute($color); } /** @@ -117,7 +117,7 @@ class Glossy extends MaterialsBase */ public function setIor($color) { - $this->index = Scene::testAbnormal($color); + $this->index = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/GlossyCoating.php b/src/scene/materials/GlossyCoating.php index 98d7a17..098b493 100644 --- a/src/scene/materials/GlossyCoating.php +++ b/src/scene/materials/GlossyCoating.php @@ -69,7 +69,7 @@ class GlossyCoating extends MaterialsBase */ public function setUroughness($color) { - $this->uroughness = Scene::testAbnormal($color); + $this->uroughness = $this->judgeAttribute($color); } /** @@ -77,7 +77,7 @@ class GlossyCoating extends MaterialsBase */ public function setVroughness($color) { - $this->vroughness = Scene::testAbnormal($color); + $this->vroughness = $this->judgeAttribute($color); } /** @@ -93,7 +93,7 @@ class GlossyCoating extends MaterialsBase */ public function setSpecular($color) { - $this->ks = Scene::testAbnormal($color); + $this->ks = $this->judgeAttribute($color); } /** @@ -102,7 +102,7 @@ class GlossyCoating extends MaterialsBase */ public function setAbsorption($color) { - $this->ka = Scene::testAbnormal($color); + $this->ka = $this->judgeAttribute($color); } /** @@ -110,7 +110,7 @@ class GlossyCoating extends MaterialsBase */ public function setAbsorptionDepht($color) { - $this->d = Scene::testAbnormal($color); + $this->d = $this->judgeAttribute($color); } /** @@ -118,7 +118,7 @@ class GlossyCoating extends MaterialsBase */ public function setIor($color) { - $this->index = Scene::testAbnormal($color); + $this->index = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/GlossyTranslucent.php b/src/scene/materials/GlossyTranslucent.php index 838c004..7409f3e 100644 --- a/src/scene/materials/GlossyTranslucent.php +++ b/src/scene/materials/GlossyTranslucent.php @@ -113,7 +113,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setUroughness($color) { - $this->uroughness = Scene::testAbnormal($color); + $this->uroughness = $this->judgeAttribute($color); } /** @@ -121,7 +121,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setVroughness($color) { - $this->vroughness = Scene::testAbnormal($color); + $this->vroughness = $this->judgeAttribute($color); } /** @@ -129,7 +129,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } /** @@ -137,7 +137,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setSpecular($color) { - $this->ks = Scene::testAbnormal($color); + $this->ks = $this->judgeAttribute($color); } /** @@ -145,7 +145,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setTransmission($color) { - $this->kt = Scene::testAbnormal($color); + $this->kt = $this->judgeAttribute($color); } /** @@ -154,7 +154,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorption($color) { - $this->ka = Scene::testAbnormal($color); + $this->ka = $this->judgeAttribute($color); } /** @@ -162,7 +162,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorptionDepht($color) { - $this->d = Scene::testAbnormal($color); + $this->d = $this->judgeAttribute($color); } /** @@ -170,7 +170,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setIor($color) { - $this->index = Scene::testAbnormal($color); + $this->index = $this->judgeAttribute($color); } @@ -182,7 +182,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setUroughness_BF($color) { - $this->uroughness_bf = Scene::testAbnormal($color); + $this->uroughness_bf = $this->judgeAttribute($color); } /** @@ -190,7 +190,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setVroughness_BF($color) { - $this->vroughness_bf = Scene::testAbnormal($color); + $this->vroughness_bf = $this->judgeAttribute($color); } /** @@ -198,7 +198,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setSpecular_BF($color) { - $this->ks_bf = Scene::testAbnormal($color); + $this->ks_bf = $this->judgeAttribute($color); } /** @@ -207,7 +207,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorption_BF($color) { - $this->ka_bf = Scene::testAbnormal($color); + $this->ka_bf = $this->judgeAttribute($color); } /** @@ -215,7 +215,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setAbsorptionDepht_BF($color) { - $this->d_bf = Scene::testAbnormal($color); + $this->d_bf = $this->judgeAttribute($color); } /** @@ -223,7 +223,7 @@ class GlossyTranslucent extends MaterialsBase */ public function setIor_BF($color) { - $this->index_bf = Scene::testAbnormal($color); + $this->index_bf = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index da19eb1..3c730e4 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -110,7 +110,7 @@ class MaterialsBase extends BaseCfg */ public function setTransparencyFront($color) { - $this->transparencyFront = Scene::testAbnormal($color); + $this->transparencyFront = $this->judgeAttribute($color); } /** @@ -118,7 +118,7 @@ class MaterialsBase extends BaseCfg */ public function setTransparencyBack($color) { - $this->transparencyBack = Scene::testAbnormal($color); + $this->transparencyBack = $this->judgeAttribute($color); } /** @@ -126,7 +126,7 @@ class MaterialsBase extends BaseCfg */ public function setBumptex($color) { - $this->bumptex = Scene::testAbnormal($color); + $this->bumptex = $this->judgeAttribute($color); } /** @@ -134,7 +134,7 @@ class MaterialsBase extends BaseCfg */ public function setEmission($color,Emission $emissionCfg = null,Visibility $visibility = null) { - $this->emission = Scene::testAbnormal($color); + $this->emission = $this->judgeAttribute($color); if( $emissionCfg != null ) $this->emissionCfg = $emissionCfg; else $this->emissionCfg = new Emission(); @@ -147,7 +147,7 @@ class MaterialsBase extends BaseCfg */ public function setVolumeInterior($volumeInterior) { - $this->volumeInterior = Scene::testAbnormal($volumeInterior); + $this->volumeInterior = $this->judgeAttribute($volumeInterior); } /** @@ -155,9 +155,32 @@ class MaterialsBase extends BaseCfg */ public function setVolumeExterior($volumeExterior) { - $this->volumeExterior = Scene::testAbnormal($volumeExterior); + $this->volumeExterior = $this->judgeAttribute($volumeExterior); } + /** + * @param object $value 接收的是一个 由自身set函数 所接收到的值,本函数可以被这些类set函数调用, + * 并判断set函数接收到值是否合法,合法则返回$value,否则抛出一个异常 + */ + protected static function judgeAttribute($value) + { + if( is_object($value) ) + { + if( $value->registerId != null ) + { + return $value->registerId; + } + else + { + throw new \Exception("You use an unregistered ".$value->getInstanceClassName()." object for the current property"); + } + } + else + { + return $value; + } + } + } ?> diff --git a/src/scene/materials/Matte.php b/src/scene/materials/Matte.php index ed67002..1ac4cbc 100644 --- a/src/scene/materials/Matte.php +++ b/src/scene/materials/Matte.php @@ -32,7 +32,7 @@ class Matte extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/MatteRough.php b/src/scene/materials/MatteRough.php index fd64fec..087ea2d 100644 --- a/src/scene/materials/MatteRough.php +++ b/src/scene/materials/MatteRough.php @@ -37,7 +37,7 @@ class MatteRough extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } /** @@ -45,7 +45,7 @@ class MatteRough extends MaterialsBase */ public function setSigma($color) { - $this->sigma = Scene::testAbnormal($color); + $this->sigma = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/MatteTranslucent.php b/src/scene/materials/MatteTranslucent.php index 0846f8d..5f1572d 100644 --- a/src/scene/materials/MatteTranslucent.php +++ b/src/scene/materials/MatteTranslucent.php @@ -37,7 +37,7 @@ class Roughmatte extends MaterialsBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } /** @@ -45,7 +45,7 @@ class Roughmatte extends MaterialsBase */ public function setTransmission($color) { - $this->kt = Scene::testAbnormal($color); + $this->kt = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index c476361..4bed386 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -44,7 +44,7 @@ class Metal extends MaterialsBase */ public function setFresnel($color) { - $this->fresnel = Scene::testAbnormal($color); + $this->fresnel = $this->judgeAttribute($color); } @@ -53,7 +53,7 @@ class Metal extends MaterialsBase */ public function setUroughness($color) { - $this->uroughness = Scene::testAbnormal($color); + $this->uroughness = $this->judgeAttribute($color); } /** @@ -61,7 +61,7 @@ class Metal extends MaterialsBase */ public function setVroughness($color) { - $this->vroughness = Scene::testAbnormal($color); + $this->vroughness = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Mirror.php b/src/scene/materials/Mirror.php index 6fa5a7c..0ca5a5e 100644 --- a/src/scene/materials/Mirror.php +++ b/src/scene/materials/Mirror.php @@ -32,7 +32,7 @@ class Mirror extends MaterialsBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index 7fcf361..3757a1f 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -41,7 +41,7 @@ class Mix extends MaterialsBase */ public function setMaterial1($material) { - $this->material1 = Scene::testAbnormal($material); + $this->material1 = $this->judgeAttribute($material); } /** @@ -49,7 +49,7 @@ class Mix extends MaterialsBase */ public function setMaterial2($material) { - $this->material2 = Scene::testAbnormal($material); + $this->material2 = $this->judgeAttribute($material); } /** @@ -57,7 +57,7 @@ class Mix extends MaterialsBase */ public function setAmount($color) { - $this->amount = Scene::testAbnormal($color); + $this->amount = $this->judgeAttribute($color); } } diff --git a/src/scene/materials/TwoSided.php b/src/scene/materials/TwoSided.php index c97df89..2011da8 100644 --- a/src/scene/materials/TwoSided.php +++ b/src/scene/materials/TwoSided.php @@ -37,7 +37,7 @@ class TwoSided extends MaterialsBase */ public function setMaterial1($material) { - $this->frontmaterial = Scene::testAbnormal($material); + $this->frontmaterial = $this->judgeAttribute($material); } /** @@ -45,7 +45,7 @@ class TwoSided extends MaterialsBase */ public function setMaterial2($material) { - $this->backmaterial = Scene::testAbnormal($material); + $this->backmaterial = $this->judgeAttribute($material); } } diff --git a/src/scene/materials/Velvet.php b/src/scene/materials/Velvet.php index 596948e..98194e6 100644 --- a/src/scene/materials/Velvet.php +++ b/src/scene/materials/Velvet.php @@ -51,7 +51,7 @@ class Velvet extends MaterialsBase */ public function setBaseColor($color) { - $this->kd = Scene::testAbnormal($color); + $this->kd = $this->judgeAttribute($color); } /** @@ -59,7 +59,7 @@ class Velvet extends MaterialsBase */ public function setP1($color) { - $this->p1 = Scene::testAbnormal($color); + $this->p1 = $this->judgeAttribute($color); } /** @@ -67,7 +67,7 @@ class Velvet extends MaterialsBase */ public function setP2($color) { - $this->p2 = Scene::testAbnormal($color); + $this->p2 = $this->judgeAttribute($color); } /** @@ -75,7 +75,7 @@ class Velvet extends MaterialsBase */ public function setP3($color) { - $this->p3 = Scene::testAbnormal($color); + $this->p3 = $this->judgeAttribute($color); } /** @@ -83,7 +83,7 @@ class Velvet extends MaterialsBase */ public function setThickness($color) { - $this->thickness = Scene::testAbnormal($color); + $this->thickness = $this->judgeAttribute($color); } } diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index 7d16504..d6fdc38 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -52,7 +52,30 @@ class Objects extends BaseCfg */ public function setMaterial($material) { - $this->material = Scene::testAbnormal($material); + $this->material = $this->judgeAttribute($material); + } + + /** + * @param object $value 接收的是一个 由自身set函数 所接收到的值,本函数可以被这些类set函数调用, + * 并判断set函数接收到值是否合法,合法则返回$value,否则抛出一个异常 + */ + protected static function judgeAttribute($value) + { + if( is_object($value) ) + { + if( $value->registerId != null ) + { + return $value->registerId; + } + else + { + throw new \Exception("You use an unregistered ".$value->getInstanceClassName()." object for the current property"); + } + } + else + { + return $value; + } } } diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php index b97934b..e80a303 100644 --- a/src/scene/texture/TextureBase.php +++ b/src/scene/texture/TextureBase.php @@ -21,6 +21,29 @@ class TextureBase extends BaseCfg * @var string TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出 */ public $registerId; + + /** + * @param object $value 接收的是一个 由自身set函数 所接收到的值,本函数可以被这些类set函数调用, + * 并判断set函数接收到值是否合法,合法则返回$value,否则抛出一个异常 + */ + protected static function judgeAttribute($value) + { + if( is_object($value) ) + { + if( $value->registerId != null ) + { + return $value->registerId; + } + else + { + throw new \Exception("You use an unregistered ".$value->getInstanceClassName()." object for the current property"); + } + } + else + { + return $value; + } + } } diff --git a/src/scene/texture/composite/Absolute.php b/src/scene/texture/composite/Absolute.php index 5e00180..08fe469 100644 --- a/src/scene/texture/composite/Absolute.php +++ b/src/scene/texture/composite/Absolute.php @@ -35,7 +35,7 @@ class Absolute extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Add.php b/src/scene/texture/composite/Add.php index b642a9a..a3d3772 100644 --- a/src/scene/texture/composite/Add.php +++ b/src/scene/texture/composite/Add.php @@ -40,7 +40,7 @@ class Add extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -48,7 +48,7 @@ class Add extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Clamp.php b/src/scene/texture/composite/Clamp.php index 33af7ad..b3abc28 100644 --- a/src/scene/texture/composite/Clamp.php +++ b/src/scene/texture/composite/Clamp.php @@ -44,7 +44,7 @@ class Clamp extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Divide.php b/src/scene/texture/composite/Divide.php index e020891..69ed154 100644 --- a/src/scene/texture/composite/Divide.php +++ b/src/scene/texture/composite/Divide.php @@ -40,7 +40,7 @@ class Divide extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -48,7 +48,7 @@ class Divide extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Dotproduct.php b/src/scene/texture/composite/Dotproduct.php index 0b3c8aa..277ace5 100644 --- a/src/scene/texture/composite/Dotproduct.php +++ b/src/scene/texture/composite/Dotproduct.php @@ -40,7 +40,7 @@ class Dotproduct extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -48,7 +48,7 @@ class Dotproduct extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/GreaterThan.php b/src/scene/texture/composite/GreaterThan.php index 98e8324..04250df 100644 --- a/src/scene/texture/composite/GreaterThan.php +++ b/src/scene/texture/composite/GreaterThan.php @@ -39,7 +39,7 @@ class GreaterThan extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class GreaterThan extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/LessThan.php b/src/scene/texture/composite/LessThan.php index 5f7b7f0..0abb8bd 100644 --- a/src/scene/texture/composite/LessThan.php +++ b/src/scene/texture/composite/LessThan.php @@ -39,7 +39,7 @@ class LessThan extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class LessThan extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/MakeFloat3.php b/src/scene/texture/composite/MakeFloat3.php index c0801ed..b506020 100644 --- a/src/scene/texture/composite/MakeFloat3.php +++ b/src/scene/texture/composite/MakeFloat3.php @@ -44,7 +44,7 @@ class MakeFloat3 extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -52,7 +52,7 @@ class MakeFloat3 extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } /** @@ -60,7 +60,7 @@ class MakeFloat3 extends TextureBase */ public function setTexture3($color) { - $this->texture3 = Scene::testAbnormal($color); + $this->texture3 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Mix.php b/src/scene/texture/composite/Mix.php index 29551e2..5f190fe 100644 --- a/src/scene/texture/composite/Mix.php +++ b/src/scene/texture/composite/Mix.php @@ -44,7 +44,7 @@ class Mix extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -52,7 +52,7 @@ class Mix extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } /** @@ -60,7 +60,7 @@ class Mix extends TextureBase */ public function setAmount($color) { - $this->amount = Scene::testAbnormal($color); + $this->amount = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Modulo.php b/src/scene/texture/composite/Modulo.php index 963d0f2..8df3d2e 100644 --- a/src/scene/texture/composite/Modulo.php +++ b/src/scene/texture/composite/Modulo.php @@ -39,7 +39,7 @@ class Modulo extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Modulo extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Power.php b/src/scene/texture/composite/Power.php index b3e4a7a..baf7e42 100644 --- a/src/scene/texture/composite/Power.php +++ b/src/scene/texture/composite/Power.php @@ -39,7 +39,7 @@ class Power extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Power extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Remap.php b/src/scene/texture/composite/Remap.php index c851d6c..3bb1f6d 100644 --- a/src/scene/texture/composite/Remap.php +++ b/src/scene/texture/composite/Remap.php @@ -55,7 +55,7 @@ class Remap extends TextureBase */ public function setTexture($color) { - $this->value = Scene::testAbnormal($color); + $this->value = $this->judgeAttribute($color); } /** @@ -63,7 +63,7 @@ class Remap extends TextureBase */ public function setSourcemin($color) { - $this->sourcemin = Scene::testAbnormal($color); + $this->sourcemin = $this->judgeAttribute($color); } /** @@ -71,7 +71,7 @@ class Remap extends TextureBase */ public function setSourcemax($color) { - $this->sourcemax = Scene::testAbnormal($color); + $this->sourcemax = $this->judgeAttribute($color); } /** @@ -79,7 +79,7 @@ class Remap extends TextureBase */ public function setTargetmin($color) { - $this->targetmin = Scene::testAbnormal($color); + $this->targetmin = $this->judgeAttribute($color); } /** @@ -87,7 +87,7 @@ class Remap extends TextureBase */ public function setTargetmax($color) { - $this->targetmax = Scene::testAbnormal($color); + $this->targetmax = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Rounding.php b/src/scene/texture/composite/Rounding.php index a0fc41a..c0a1b3f 100644 --- a/src/scene/texture/composite/Rounding.php +++ b/src/scene/texture/composite/Rounding.php @@ -39,7 +39,7 @@ class Rounding extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Rounding extends TextureBase */ public function setIncrement($color) { - $this->increment = Scene::testAbnormal($color); + $this->increment = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Scale.php b/src/scene/texture/composite/Scale.php index 8517815..58bf163 100644 --- a/src/scene/texture/composite/Scale.php +++ b/src/scene/texture/composite/Scale.php @@ -39,7 +39,7 @@ class Scale extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Scale extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/SplitFloat3.php b/src/scene/texture/composite/SplitFloat3.php index 69f9249..d8f8d9d 100644 --- a/src/scene/texture/composite/SplitFloat3.php +++ b/src/scene/texture/composite/SplitFloat3.php @@ -45,7 +45,7 @@ class SplitFloat3 extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/composite/Subtract.php b/src/scene/texture/composite/Subtract.php index 0df9e3f..42155c8 100644 --- a/src/scene/texture/composite/Subtract.php +++ b/src/scene/texture/composite/Subtract.php @@ -39,7 +39,7 @@ class Subtract extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Subtract extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/deformation/Distort.php b/src/scene/texture/deformation/Distort.php index da0dc9d..50b2bcb 100644 --- a/src/scene/texture/deformation/Distort.php +++ b/src/scene/texture/deformation/Distort.php @@ -45,7 +45,7 @@ class Distort extends TextureBase */ public function setSource($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } /** @@ -53,7 +53,7 @@ class Distort extends TextureBase */ public function setOffset($color) { - $this->offset = Scene::testAbnormal($color); + $this->offset = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/luminous/BlackBody.php b/src/scene/texture/luminous/BlackBody.php new file mode 100644 index 0000000..58b32a1 --- /dev/null +++ b/src/scene/texture/luminous/BlackBody.php @@ -0,0 +1,45 @@ +type = self::TYPE_BLACKBODY; + $this->id = Scene::createID(); + Base::__construct($config); + } + +} + +?> diff --git a/src/scene/texture/luminous/IrregularData.php b/src/scene/texture/luminous/IrregularData.php new file mode 100644 index 0000000..a11ba97 --- /dev/null +++ b/src/scene/texture/luminous/IrregularData.php @@ -0,0 +1,50 @@ +type = self::TYPE_IRREGULARDATA; + $this->id = Scene::createID(); + Base::__construct($config); + } + +} + +?> diff --git a/src/scene/texture/luminous/PresetLamp.php b/src/scene/texture/luminous/PresetLamp.php new file mode 100644 index 0000000..5daf737 --- /dev/null +++ b/src/scene/texture/luminous/PresetLamp.php @@ -0,0 +1,174 @@ + diff --git a/src/scene/texture/procedural/Brick.php b/src/scene/texture/procedural/Brick.php index 97e452d..4f805a6 100644 --- a/src/scene/texture/procedural/Brick.php +++ b/src/scene/texture/procedural/Brick.php @@ -99,7 +99,7 @@ class Brick extends TextureBase */ public function setBricktex($color) { - $this->bricktex = Scene::testAbnormal($color); + $this->bricktex = $this->judgeAttribute($color); } /** @@ -107,7 +107,7 @@ class Brick extends TextureBase */ public function setBrickmodtex($color) { - $this->brickmodtex = Scene::testAbnormal($color); + $this->brickmodtex = $this->judgeAttribute($color); } /** @@ -115,7 +115,7 @@ class Brick extends TextureBase */ public function setMortartex($color) { - $this->mortartex = Scene::testAbnormal($color); + $this->mortartex = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/procedural/Checkerboard2d.php b/src/scene/texture/procedural/Checkerboard2d.php index b54683c..0b2354e 100644 --- a/src/scene/texture/procedural/Checkerboard2d.php +++ b/src/scene/texture/procedural/Checkerboard2d.php @@ -47,7 +47,7 @@ class Checkerboard2d extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -55,7 +55,7 @@ class Checkerboard2d extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/procedural/Checkerboard3d.php b/src/scene/texture/procedural/Checkerboard3d.php index 8e6cfc1..d43cf4d 100644 --- a/src/scene/texture/procedural/Checkerboard3d.php +++ b/src/scene/texture/procedural/Checkerboard3d.php @@ -47,7 +47,7 @@ class Checkerboard3d extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -55,7 +55,7 @@ class Checkerboard3d extends TextureBase */ public function setTexture2($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/procedural/Fresnelcolor.php b/src/scene/texture/procedural/Fresnelcolor.php index af65626..1de1776 100644 --- a/src/scene/texture/procedural/Fresnelcolor.php +++ b/src/scene/texture/procedural/Fresnelcolor.php @@ -34,7 +34,7 @@ class Fresnelcolor extends TextureBase */ public function setRefraction($color) { - $this->kr = Scene::testAbnormal($color); + $this->kr = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/procedural/Fresnelconst.php b/src/scene/texture/procedural/Fresnelconst.php index c15c26c..7332940 100644 --- a/src/scene/texture/procedural/Fresnelconst.php +++ b/src/scene/texture/procedural/Fresnelconst.php @@ -39,7 +39,7 @@ class Fresnelconst extends TextureBase */ public function setRefractionN($color) { - $this->n = Scene::testAbnormal($color); + $this->n = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class Fresnelconst extends TextureBase */ public function setRefractionK($color) { - $this->k = Scene::testAbnormal($color); + $this->k = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/procedural/Random.php b/src/scene/texture/procedural/Random.php index dff1c99..f7f1a83 100644 --- a/src/scene/texture/procedural/Random.php +++ b/src/scene/texture/procedural/Random.php @@ -38,7 +38,7 @@ class Random extends TextureBase */ public function setTexture1($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/tint/BrightContrast.php b/src/scene/texture/tint/BrightContrast.php index 4b529bf..25be081 100644 --- a/src/scene/texture/tint/BrightContrast.php +++ b/src/scene/texture/tint/BrightContrast.php @@ -45,7 +45,7 @@ class BrightContrast extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } /** @@ -53,7 +53,7 @@ class BrightContrast extends TextureBase */ public function setBrightness($color) { - $this->brightness = Scene::testAbnormal($color); + $this->brightness = $this->judgeAttribute($color); } /** @@ -61,7 +61,7 @@ class BrightContrast extends TextureBase */ public function setContrast($color) { - $this->contrast = Scene::testAbnormal($color); + $this->contrast = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/tint/Hsv.php b/src/scene/texture/tint/Hsv.php index 2be5c76..dcc2e46 100644 --- a/src/scene/texture/tint/Hsv.php +++ b/src/scene/texture/tint/Hsv.php @@ -50,7 +50,7 @@ class Hsv extends TextureBase */ public function setTexture($color) { - $this->texture = Scene::testAbnormal($color); + $this->texture = $this->judgeAttribute($color); } /** @@ -58,7 +58,7 @@ class Hsv extends TextureBase */ public function setHue($color) { - $this->hue = Scene::testAbnormal($color); + $this->hue = $this->judgeAttribute($color); } /** @@ -66,7 +66,7 @@ class Hsv extends TextureBase */ public function setSaturation($color) { - $this->saturation = Scene::testAbnormal($color); + $this->saturation = $this->judgeAttribute($color); } /** @@ -74,7 +74,7 @@ class Hsv extends TextureBase */ public function setBrightness($color) { - $this->value = Scene::testAbnormal($color); + $this->value = $this->judgeAttribute($color); } } diff --git a/src/scene/texture/tint/Subtract.php b/src/scene/texture/tint/Subtract.php index 90774fc..ef5a733 100644 --- a/src/scene/texture/tint/Subtract.php +++ b/src/scene/texture/tint/Subtract.php @@ -40,7 +40,7 @@ class Subtract extends TextureBase */ public function setBrightness($color) { - $this->texture1 = Scene::testAbnormal($color); + $this->texture1 = $this->judgeAttribute($color); } /** @@ -48,7 +48,7 @@ class Subtract extends TextureBase */ public function setSource($color) { - $this->texture2 = Scene::testAbnormal($color); + $this->texture2 = $this->judgeAttribute($color); } } diff --git a/src/scene/volumes/HeteroGeneous.php b/src/scene/volumes/HeteroGeneous.php index ffe7915..c00b202 100644 --- a/src/scene/volumes/HeteroGeneous.php +++ b/src/scene/volumes/HeteroGeneous.php @@ -49,7 +49,7 @@ class HomoGeneous extends VolumesBase */ public function setAsymmetry($color) { - $this->asymmetry = Scene::testAbnormal($color); + $this->asymmetry = $this->judgeAttribute($color); } /** @@ -57,7 +57,7 @@ class HomoGeneous extends VolumesBase */ public function setScattering($color) { - $this->scattering = Scene::testAbnormal($color); + $this->scattering = $this->judgeAttribute($color); } } diff --git a/src/scene/volumes/HomoGeneous.php b/src/scene/volumes/HomoGeneous.php index c024c62..af76ecd 100644 --- a/src/scene/volumes/HomoGeneous.php +++ b/src/scene/volumes/HomoGeneous.php @@ -39,7 +39,7 @@ class HomoGeneous extends VolumesBase */ public function setAsymmetry($color) { - $this->asymmetry = Scene::testAbnormal($color); + $this->asymmetry = $this->judgeAttribute($color); } /** @@ -47,7 +47,7 @@ class HomoGeneous extends VolumesBase */ public function setScattering($color) { - $this->scattering = Scene::testAbnormal($color); + $this->scattering = $this->judgeAttribute($color); } } diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php index 4b22609..4cb1a86 100644 --- a/src/scene/volumes/VolumesBase.php +++ b/src/scene/volumes/VolumesBase.php @@ -62,7 +62,7 @@ class VolumesBase extends BaseCfg */ public function setEmission($color,$emissionId = 0) { - $this->emission = Scene::testAbnormal($color); + $this->emission = $this->judgeAttribute($color); $this->emissionId = $emissionId; } @@ -71,7 +71,7 @@ class VolumesBase extends BaseCfg */ public function setAbsorption($color) { - $this->absorption = Scene::testAbnormal($color); + $this->absorption = $this->judgeAttribute($color); } /** @@ -79,8 +79,32 @@ class VolumesBase extends BaseCfg */ public function setIor($color) { - $this->ior = Scene::testAbnormal($color); - } + $this->ior = $this->judgeAttribute($color); + } + + /** + * @param object $value 接收的是一个 由自身set函数 所接收到的值,本函数可以被这些类set函数调用, + * 并判断set函数接收到值是否合法,合法则返回$value,否则抛出一个异常 + */ + protected static function judgeAttribute($value) + { + if( is_object($value) ) + { + if( $value->registerId != null ) + { + return $value->registerId; + } + else + { + throw new \Exception("You use an unregistered ".$value->getInstanceClassName()." object for the current property"); + } + } + else + { + return $value; + } + } + } ?>