From b7765fa316808713cd4db1c5d71e401319b2aad2 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Fri, 18 Mar 2022 19:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=A4=E4=B8=AA=E7=81=AF?= =?UTF-8?q?=E5=85=89=E7=B1=BB=E6=96=87=E4=BB=B6=E3=80=81=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=A4=A9=E5=85=89=E7=BC=93=E5=AD=98=E7=B1=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E3=80=81=E4=B8=80=E4=B8=AA=E4=B8=96=E7=95=8C=E7=B1=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=85=B6=E4=BB=96=E6=9C=89=E4=B8=80=E5=B0=8F?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=B1=BB=E6=96=87=E4=BB=B6=E6=9C=89=E5=B0=8F?= =?UTF-8?q?=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 2 +- examples/printScene.php | 7 + src/scene/Scene.php | 24 +++- src/scene/light/LigthBase.php | 19 --- src/scene/lights/LightBase.php | 26 ++++ src/scene/lights/Sky.php | 127 ++++++++++++++++++ .../emission => lights}/Visibility.php | 2 +- src/scene/materials/MaterialsBase.php | 2 +- src/scene/render/cache/LightStrategy.php | 2 + src/scene/render/cache/PhotonGI.php | 2 + src/scene/render/cache/VisibilityMapCache.php | 74 ++++++++++ src/scene/texture/mapping/Mapping.php | 14 +- src/scene/texture/procedural/ImageMap.php | 2 +- src/scene/world/WorldDefault.php | 105 +++++++++++++++ 14 files changed, 381 insertions(+), 27 deletions(-) delete mode 100644 src/scene/light/LigthBase.php create mode 100644 src/scene/lights/LightBase.php create mode 100644 src/scene/lights/Sky.php rename src/scene/{materials/emission => lights}/Visibility.php (92%) create mode 100644 src/scene/render/cache/VisibilityMapCache.php create mode 100644 src/scene/world/WorldDefault.php diff --git a/.vscode/launch.json b/.vscode/launch.json index d88edc1..7a000ab 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "name": "Launch currently open script", "type": "php", "request": "launch", - "program": "${workspaceFolder}/examples/PrintScene.php", + "program": "${workspaceFolder}/examples/printScene.php", "cwd": "${workspaceFolder}", "port": 9055 } diff --git a/examples/printScene.php b/examples/printScene.php index 6245106..84a7889 100644 --- a/examples/printScene.php +++ b/examples/printScene.php @@ -70,6 +70,13 @@ $scene->registerMaterial($colorGlass); //将玻璃材质注册到 Scene $obj->setMaterial($colorGlass); //将玻璃材质赋值到模型的材质属性 $scene->registerObjects($obj); //将模型添加到场景中 + + +$default = new world\WorldDefault(); +$default->setDefaultVolume($ClearVol); + +$scene->registerWorld($default); + echo $scene; diff --git a/src/scene/Scene.php b/src/scene/Scene.php index 59f4b8b..0e0d520 100644 --- a/src/scene/Scene.php +++ b/src/scene/Scene.php @@ -1,8 +1,8 @@ cameras[$id] = $camera; } + /** + * @param object $camera 接收一个相机类对象,为其颁发一个注册信息,并将其存到Scene + */ + public function registerWorld(&$world) + { + foreach( get_object_vars($world) as $key => $value ) + { + if($value != null) + { + $key = implode(".", array_map('strtolower', StringHelper::camelStrToArray($key))); + $this->world[$key] = $value; + } + } + } + } ?> diff --git a/src/scene/light/LigthBase.php b/src/scene/light/LigthBase.php deleted file mode 100644 index 82f1f4e..0000000 --- a/src/scene/light/LigthBase.php +++ /dev/null @@ -1,19 +0,0 @@ -id = Scene::createID(); - Base::__construct($config); - } - -} - -?> diff --git a/src/scene/lights/LightBase.php b/src/scene/lights/LightBase.php new file mode 100644 index 0000000..2af1dbc --- /dev/null +++ b/src/scene/lights/LightBase.php @@ -0,0 +1,26 @@ + diff --git a/src/scene/lights/Sky.php b/src/scene/lights/Sky.php new file mode 100644 index 0000000..e99e312 --- /dev/null +++ b/src/scene/lights/Sky.php @@ -0,0 +1,127 @@ +type = self::TYPE_SKY2; + $this->id = Scene::createID(); + Base::__construct($config); + } + + /** + * 打开天光缓存 + */ + public function openCache() + { + $this->visibilitymapcacheEnable = self::OPEN; + $this->envLightCache = new VisibilityMapCache; + } + + /** + * 关闭天光缓存 + */ + public function closeCache() + { + $this->visibilitymapcacheEnable = self::CLOSE; + $this->envLightCache = null; + } +} + +?> diff --git a/src/scene/materials/emission/Visibility.php b/src/scene/lights/Visibility.php similarity index 92% rename from src/scene/materials/emission/Visibility.php rename to src/scene/lights/Visibility.php index 4336575..30c713f 100644 --- a/src/scene/materials/emission/Visibility.php +++ b/src/scene/lights/Visibility.php @@ -1,6 +1,6 @@ diff --git a/src/scene/texture/mapping/Mapping.php b/src/scene/texture/mapping/Mapping.php index 99137dd..7f184fe 100644 --- a/src/scene/texture/mapping/Mapping.php +++ b/src/scene/texture/mapping/Mapping.php @@ -36,6 +36,16 @@ class Mapping extends BaseCfg */ const TYPE_UVMAPPING3D = 'uvmapping3d'; + + /** + * 随机种子类型 + */ + const TYPE_OBJECT_ID_OFFSET = 'object_id_offset'; + const TYPE_TRIANGLE_AOV = 'triangle_aov'; + + + + /** * @var string 铺贴类型 */ @@ -51,12 +61,12 @@ class Mapping extends BaseCfg //当铺贴类型属于随机时,以下参数才可设以置和输出 /** - * @var string 随机种子类型,当铺贴类型为随机时,参数才可设以置和输出 + * @var string 随机种子类型,当铺贴类型为随机时,参数才可设以置和输出,当随机种子类型为 triangle_aov时,有一个生成1个多余ply文件的Bug */ public $seedType; /** - * @var integer 当随机种类型为 object_id_offset时,可以设置为大于等于的整数,否则只能为0,当铺贴类型为随机时,参数才可设以置和输出 + * @var integer 当随机种子类型为 object_id_offset时,可以设置为大于等于的整数,否则只能为0,当铺贴类型为随机时,参数才可设以置和输出 */ public $objectidoffsetValue; diff --git a/src/scene/texture/procedural/ImageMap.php b/src/scene/texture/procedural/ImageMap.php index cd42f5c..f47e8f0 100644 --- a/src/scene/texture/procedural/ImageMap.php +++ b/src/scene/texture/procedural/ImageMap.php @@ -31,7 +31,7 @@ class ImageMap extends TextureBase public $gamma = 2.2; /** - * @var bool 是否随机重复 + * @var bool 是否随机重复,当此项参数状态为打开时,有一个成生两个多余图像文件的Bug */ public $randomizedtilingEnable = self::CLOSE; diff --git a/src/scene/world/WorldDefault.php b/src/scene/world/WorldDefault.php new file mode 100644 index 0000000..77343ea --- /dev/null +++ b/src/scene/world/WorldDefault.php @@ -0,0 +1,105 @@ +volumeDefault = $this->judgeAttribute($volume); + } + + + //以下函数暂时注释,因为还没有发现 World存在以下这些默认的对象 + + // /** + // * @param object $material 接收一个体积对象,设置为世界默认的体积 + // */ + // public function setDefaultMaterial($material) + // { + // $this->materialDefault = $this->judgeAttribute($material); + // } + + // /** + // * @param object $camera 接收一个体积对象,设置为世界默认的体积 + // */ + // public function setDefaultCamera($camera) + // { + // $this->cameraDefault = $this->judgeAttribute($camera); + // } + + // /** + // * @param object $light 接收一个体积对象,设置为世界默认的体积 + // */ + // public function setDefaultLight($light) + // { + // $this->lightDefault = $this->judgeAttribute($light); + // } + + // /** + // * @param object $texture 接收一个体积对象,设置为世界默认的体积 + // */ + // public function setDefaultTexture($texture) + // { + // $this->textureDefault = $this->judgeAttribute($texture); + // } + + // /** + // * @param object $objects 接收一个体积对象,设置为世界默认的体积 + // */ + // public function setDefaultObjects($objects) + // { + // $this->objectsDefault = $this->judgeAttribute($objects); + // } + + + + /** + * @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; + } + } + +} + +?>