From f4c416d81ab9630b2e242f848c66f97bbda8ce82 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Mon, 7 Mar 2022 11:14:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E5=BA=9F=E5=BC=83=E7=9A=84=E5=BC=82=E5=B8=B8=E7=B1=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8C=EF=BC=8C=E6=9D=90=E8=B4=A8=E3=80=81=E8=B4=B4?= =?UTF-8?q?=E5=9B=BE=E7=B1=BB=E3=80=81=E6=A8=A1=E5=9E=8B=E7=88=B6=E7=B1=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0get=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 4 +-- src/core/RenderException .php | 10 ------ src/core/SceneException.php | 7 ---- src/scene/materials/Disney.php | 51 +++++++++------------------ src/scene/materials/MaterialsBase.php | 5 +++ src/scene/materials/Metal.php | 14 ++++---- src/scene/materials/Mix.php | 9 ++--- src/scene/objects/Objects.php | 8 +++-- src/scene/texture/TextureBase.php | 6 ++++ src/scene/volumes/VolumesBase.php | 5 +++ 10 files changed, 51 insertions(+), 68 deletions(-) delete mode 100644 src/core/RenderException .php delete mode 100644 src/core/SceneException.php diff --git a/examples/print.php b/examples/print.php index 5cafe49..d748d5b 100644 --- a/examples/print.php +++ b/examples/print.php @@ -90,13 +90,13 @@ $obj = new objects\Objects( null,[ 'ply' => 'mesh-10086.ply','appliedtransformat $cloudsMap = new texture\map\Clouds(); //创建一个 Clouds类的贴图对象 -//$scene->registerTexture($cloudsMap); //将这个对象注册到 Scene +$scene->registerTexture($cloudsMap); //将这个对象注册到 Scene $imageMap = new texture\map\ImageMap(); //创建一个 ImageMap类的贴图对象 $scene->registerTexture($imageMap); //将这个对象注册到 Scene $blend = new texture\map\Blend(); //创建一个 Blend类的贴图对象 -$scene->registerTexture($blend); //将这个对象注册到 Scene +//$scene->registerTexture($blend); //将这个对象注册到 Scene $disney = new materials\Disney(); //创建一个 Disney 材质对象 diff --git a/src/core/RenderException .php b/src/core/RenderException .php deleted file mode 100644 index e5c62e2..0000000 --- a/src/core/RenderException .php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/src/core/SceneException.php b/src/core/SceneException.php deleted file mode 100644 index 22d39f5..0000000 --- a/src/core/SceneException.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 2f01a97..b29601d 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -113,8 +113,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->basecolor = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->basecolor = $color; @@ -127,8 +126,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->subsurface = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->subsurface = $color; @@ -141,8 +139,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->metallic = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->metallic = $color; @@ -155,8 +152,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->specular = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->specular = $color; @@ -169,8 +165,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->speculartint = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->speculartint = $color; @@ -183,8 +178,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->roughness = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->roughness = $color; @@ -197,8 +191,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->anisotropic = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->anisotropic = $color; @@ -211,8 +204,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheen = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->sheen = $color; @@ -225,8 +217,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheentint = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->sheentint = $color; @@ -239,8 +230,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoat = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->clearcoat = $color; @@ -253,8 +243,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoatgloss = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->clearcoatgloss = $color; @@ -267,8 +256,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyFront = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->transparencyFront = $color; @@ -281,8 +269,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyBack = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->transparencyBack = $color; @@ -295,8 +282,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmamount = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->filmamount = $color; @@ -308,8 +294,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmthickness = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->filmthickness = $color; @@ -322,8 +307,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmior = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->filmior = $color; @@ -336,8 +320,7 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->bumptex = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->bumptex = $color; diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index 043b423..8c66e79 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -101,6 +101,11 @@ class MaterialsBase extends BaseCfg $this->volumeExterior = $color; } + public function getClassName() + { + return array_reverse(explode('\\', get_class($this)))[0]; + } + } ?> diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index 4d9bfec..70c3b29 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -60,7 +60,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->kr = $color; @@ -75,7 +75,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->fresnel = $color; @@ -90,7 +90,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->uroughness = $color; @@ -104,7 +104,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->vroughness = $color; @@ -118,7 +118,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->transparencyFront = $color; @@ -132,7 +132,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->transparencyBack = $color; @@ -146,7 +146,7 @@ class Metal extends MaterialsBase else { $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered {$className} object for the current property"); } } else $this->bumptex = $color; diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index b6e9109..a56eb7f 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -42,8 +42,7 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material1 = $Material->cards; else { - $className = array_reverse(explode('\\', get_class($Material)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property"); } } else $this->material1 = $Material; @@ -56,8 +55,7 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material2 = $Material->cards; else { - $className = array_reverse(explode('\\', get_class($Material)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property"); } } else $this->material2 = $Material; @@ -70,8 +68,7 @@ class Mix extends MaterialsBase if( $color->cards != null ) $this->amount = $color->cards; else { - $className = array_reverse(explode('\\', get_class($color)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property"); } } else $this->amount = $color; diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index a13b5f3..b1b1a96 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -51,13 +51,17 @@ class Objects extends BaseCfg if( $material->cards != null ) $this->material = $material->cards; else { - $className = array_reverse(explode('\\', get_class($material)))[0]; - throw new core\SceneException("You use an unregistered {$className} object for the current property"); + throw new \Exception("You use an unregistered ".$material->getClassName()." object for the current property"); } } else $this->material = $material; } + public function getClassName() + { + return array_reverse(explode('\\', get_class($this)))[0]; + } + } ?> diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php index 820bec4..3d31cab 100644 --- a/src/scene/texture/TextureBase.php +++ b/src/scene/texture/TextureBase.php @@ -21,6 +21,12 @@ class TextureBase extends BaseCfg * @var string 储存个由Scene类颁发的注册信息 */ public $cards; + + public function getClassName() + { + return array_reverse(explode('\\', get_class($this)))[0]; + } + } ?> diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php index 7829231..5f543ab 100644 --- a/src/scene/volumes/VolumesBase.php +++ b/src/scene/volumes/VolumesBase.php @@ -15,6 +15,11 @@ class VolumesBase extends BaseCfg Base::__construct($config); } + public function getClassName() + { + return array_reverse(explode('\\', get_class($this)))[0]; + } + } ?>