From cdffeb4dff7dd1ebc91d5b40b1c494c4f679ce9c Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Tue, 8 Mar 2022 17:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=89=E4=B8=AA=E4=BD=93?= =?UTF-8?q?=E7=A7=AF=E6=95=88=E6=9E=9C=E7=9A=84=E7=B1=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BD=93=E7=A7=AF=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=9F=BA=E7=B1=BB=E6=96=87=E4=BB=B6=EF=BC=8C=E6=9D=90?= =?UTF-8?q?=E8=B4=A8=E3=80=81=E8=B4=B4=E5=9B=BE=E3=80=81=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E3=80=81=E7=B1=BB=E6=96=87=E4=BB=B6=E7=9A=84bool=E5=9E=8B?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E4=BD=BF=E7=94=A8=E4=BA=86OPEN=E3=80=81CLOSE?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 6 +- src/scene/materials/Disney.php | 2 +- src/scene/materials/Glossy.php | 6 +- src/scene/materials/GlossyTranslucent.php | 12 +-- src/scene/materials/MaterialsBase.php | 18 ++--- src/scene/materials/emission/Emission.php | 2 +- src/scene/materials/emission/Visibility.php | 6 +- src/scene/objects/Objects.php | 4 +- src/scene/texture/map/ImageMap.php | 2 +- src/scene/texture/mapping/Triplanar.php | 2 +- src/scene/volumes/Clear.php | 13 +++- src/scene/volumes/HeteroGeneous.php | 72 +++++++++++++++++ src/scene/volumes/HomoGeneous.php | 62 +++++++++++++++ src/scene/volumes/VolumesBase.php | 86 +++++++++++++++++++-- 14 files changed, 257 insertions(+), 36 deletions(-) create mode 100644 src/scene/volumes/HeteroGeneous.php create mode 100644 src/scene/volumes/HomoGeneous.php diff --git a/examples/print.php b/examples/print.php index 625aeb7..d1676ff 100644 --- a/examples/print.php +++ b/examples/print.php @@ -121,11 +121,11 @@ $scene->registerObjects($obj); //将模型添加到场景中 //添加第二个模型 $obj = new objects\Objects( [ 'ply' => 'mesh-119.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型, -$ClearVol = new volumes\Clear(); //创建一个 Clear体积材质 -$scene->registerVolume($ClearVol); //将体积材质注册到Scene +$ClearVol = new volumes\Clear(); //创建一个 Clear体积效果 +$scene->registerVolume($ClearVol); //将体积效果注册到Scene $colorGlass = new materials\Glass(); //创建一个玻璃材质, -$colorGlass->setVolumeInterior($ClearVol); //将 Clear体积材质赋值到玻璃材质 的 体积属性 +$colorGlass->setVolumeInterior($ClearVol); //将 Clear体积效果赋值到玻璃材质 的 体积属性 $scene->registerMaterial($colorGlass); //将玻璃材质注册到 Scene $obj->setMaterial($colorGlass); //将玻璃材质赋值到模型的材质属性 diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 58aed9e..8e12ffc 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -11,7 +11,7 @@ class Disney extends MaterialsBase const TYPE_DISNEY = 'disney'; /** - * @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名sd + * @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名 */ public $basecolor = "0.7 0.7 0.7"; diff --git a/src/scene/materials/Glossy.php b/src/scene/materials/Glossy.php index 060370c..9589b90 100644 --- a/src/scene/materials/Glossy.php +++ b/src/scene/materials/Glossy.php @@ -48,7 +48,7 @@ class Glossy extends MaterialsBase /** * @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false) */ - public $multibounce = false; + public $multibounce = self::CLOSE; public function __construct($config = []) { @@ -150,12 +150,12 @@ class Glossy extends MaterialsBase public function openMultiBounce() { - $this->multibounce = true; + $this->multibounce = self::OPEN; } public function closeMultiBounce() { - $this->multibounce = false; + $this->multibounce = self::CLOSE; } } diff --git a/src/scene/materials/GlossyTranslucent.php b/src/scene/materials/GlossyTranslucent.php index 25455db..446b9fd 100644 --- a/src/scene/materials/GlossyTranslucent.php +++ b/src/scene/materials/GlossyTranslucent.php @@ -53,7 +53,7 @@ class Glossy extends MaterialsBase /** * @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false) */ - public $multibounce = false; + public $multibounce = self::CLOSE; @@ -92,7 +92,7 @@ class Glossy extends MaterialsBase /** * @var bool TODO:BF 否是使用多弹射,具体作用尚未明确,(默认取值:false) */ - public $multibounce_bf = false; + public $multibounce_bf = self::CLOSE; public function __construct($config = []) @@ -208,12 +208,12 @@ class Glossy extends MaterialsBase public function openMultiBounce() { - $this->multibounce = true; + $this->multibounce = self::OPEN; } public function closeMultiBounce() { - $this->multibounce = false; + $this->multibounce = self::CLOSE; } @@ -300,12 +300,12 @@ class Glossy extends MaterialsBase public function openMultiBounce_BF() { - $this->multibounce_bf = true; + $this->multibounce_bf = self::OPEN; } public function closeMultiBounce_BF() { - $this->multibounce_bf = false; + $this->multibounce_bf = self::CLOSE; } } diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index 4149d5a..c2fcabe 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -33,7 +33,7 @@ class MaterialsBase extends BaseCfg /** - * @var string 一个色值,表示材质的自发光颜色,如果为空,则关闭材质的自发光, + * @var string 一个色值或是一个textures(贴图数组)中的某个键名,表示材质的自发光颜色,如果为空,则关闭材质的自发光, */ public $emission; @@ -50,12 +50,12 @@ class MaterialsBase extends BaseCfg /** - * @var string 内部体积材质,(体积材质数组的某个键名) + * @var string 内部体积效果,(体积效果数组的某个键名) */ public $volumeInterior; /** - * @var string 外部体积材质,(体积材质数组的某个键名) + * @var string 外部体积效果,(体积效果数组的某个键名) */ public $volumeExterior; @@ -72,7 +72,7 @@ class MaterialsBase extends BaseCfg public $id; /** - * @var bool TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出 + * @var string TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出 */ public $cards; @@ -84,22 +84,22 @@ class MaterialsBase extends BaseCfg /** * @var bool 是否开启阴捕捉(取值:ture 或 false) */ - public $shadowcatcherEnable = false; + public $shadowcatcherEnable = self::CLOSE; /** * @var bool 是否仅捕捉内部灯光的阴影,需要上一个参数打开,本参数才可以设置(取值:ture 或 false) */ - public $shadowcatcherOnlyinfinitelights = false; + public $shadowcatcherOnlyinfinitelights = self::CLOSE; /** * @var bool 设置当前材质是否保存和使用全局光缓存,当需要打开时,需要渲染器开启全局光缓存功能(取值:ture 或 false) */ - public $photongiEnable = true; + public $photongiEnable = self::OPEN; /** * @var bool 设置当前材质的模型是否对摄像机背景透明,当需要打开时,需要摄像机开启 Transparent Film 功通(取值:ture 或 false) */ - public $holdoutEnable = false; + public $holdoutEnable = self::CLOSE; @@ -187,7 +187,7 @@ class MaterialsBase extends BaseCfg } else $this->volumeExterior = $volumeExterior; } - + } ?> diff --git a/src/scene/materials/emission/Emission.php b/src/scene/materials/emission/Emission.php index 2510ea1..5543b7c 100644 --- a/src/scene/materials/emission/Emission.php +++ b/src/scene/materials/emission/Emission.php @@ -27,7 +27,7 @@ class Emission extends BaseCfg /** * @var bool TODO:颜色亮度进行规格化,具体作用沿未明确,当发光强度单位非 artistic 类型时,可以设置此参数,(取值:true或false),否则固定为 false */ - public $normalizebycolor = false; + public $normalizebycolor = self::CLOSE; /** * @var float 光线的发射时的扩散角度,设置为光源的半角。默认值为90。较小的值意味着在 垂直光源表面 的方向上发射的光更多,而在侧面发射的光更少,反之亦然 diff --git a/src/scene/materials/emission/Visibility.php b/src/scene/materials/emission/Visibility.php index c960f87..4336575 100644 --- a/src/scene/materials/emission/Visibility.php +++ b/src/scene/materials/emission/Visibility.php @@ -9,17 +9,17 @@ class Visibility extends BaseCfg /** * @var bool 是否开启漫反射可见(取值:true 或 false) */ - public $indirectDiffuseEnable = true; + public $indirectDiffuseEnable = self::OPEN; /** * @var bool 是否开启光泽度可见(取值:ture 或 false) */ - public $indirectGlossyEnable = true; + public $indirectGlossyEnable = self::OPEN; /** * @var bool 是否开启高光可见(取值:ture 或 false) */ - public $indirectSpecularEnable = true; + public $indirectSpecularEnable = self::OPEN; } diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index 1c5a04c..b3a79db 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -19,9 +19,9 @@ class Objects extends BaseCfg public $ply; /** - * @var bool 是否对摄相机可见 + * @var bool 是否对摄相机隐藏 */ - public $camerainvisible = false; + public $camerainvisible = self::CLOSE; /** * @var integer 模型的ID(取值:大于0的整数) diff --git a/src/scene/texture/map/ImageMap.php b/src/scene/texture/map/ImageMap.php index b12ef1a..fa02fee 100644 --- a/src/scene/texture/map/ImageMap.php +++ b/src/scene/texture/map/ImageMap.php @@ -31,7 +31,7 @@ class ImageMap extends TextureBase /** * @var bool 是否随机重复 */ - public $randomizedtilingEnable = false; + public $randomizedtilingEnable = self::CLOSE; /** * @var object 铺贴参数,一个Mapping类对象 diff --git a/src/scene/texture/mapping/Triplanar.php b/src/scene/texture/mapping/Triplanar.php index 3b3d80a..c53bc2d 100644 --- a/src/scene/texture/mapping/Triplanar.php +++ b/src/scene/texture/mapping/Triplanar.php @@ -29,7 +29,7 @@ class Triplanar extends TextureBase /** * @var bool 是否为凹凸贴图模式 */ - public $uvlessbumpmapEnable = 1; + public $uvlessbumpmapEnable = self::OPEN; /** * @var object 铺贴参数,一个Mapping类对象 diff --git a/src/scene/volumes/Clear.php b/src/scene/volumes/Clear.php index 87766ab..d584f4f 100644 --- a/src/scene/volumes/Clear.php +++ b/src/scene/volumes/Clear.php @@ -1,9 +1,20 @@ type = self::TYPE_CLEAR; + $this->id = Scene::createID(); + core\Base::__construct($config); + } } diff --git a/src/scene/volumes/HeteroGeneous.php b/src/scene/volumes/HeteroGeneous.php new file mode 100644 index 0000000..af6f07b --- /dev/null +++ b/src/scene/volumes/HeteroGeneous.php @@ -0,0 +1,72 @@ +type = self::TYPE_HETEROGENEOUS; + $this->id = Scene::createID(); + core\Base::__construct($config); + } + + public function setAsymmetry($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->asymmetry = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->asymmetry = $color; + } + + public function setScattering($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->scattering = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->scattering = $color; + } + +} + +?> diff --git a/src/scene/volumes/HomoGeneous.php b/src/scene/volumes/HomoGeneous.php new file mode 100644 index 0000000..4c8369e --- /dev/null +++ b/src/scene/volumes/HomoGeneous.php @@ -0,0 +1,62 @@ +type = self::TYPE_HOMOGENEOUS; + $this->id = Scene::createID(); + core\Base::__construct($config); + } + + public function setAsymmetry($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->asymmetry = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->asymmetry = $color; + } + + public function setScattering($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->scattering = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->scattering = $color; + } + +} + +?> diff --git a/src/scene/volumes/VolumesBase.php b/src/scene/volumes/VolumesBase.php index d80e489..194f031 100644 --- a/src/scene/volumes/VolumesBase.php +++ b/src/scene/volumes/VolumesBase.php @@ -5,20 +5,96 @@ use Blobt\Luxcore\scene\BaseCfg; class VolumesBase extends BaseCfg { - /** - * @var string 贴图类型 + + /** + * @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名。这里的色值是对应UI界面色值的补色, + * 因为UI界面中的色值为了获得可见即可得直观的效果 */ - public $type; + public $absorption = '0 0 0'; /** - * @var integer 当前贴图的ID号(取值:大于0的整数) + * @var integer TODO:优先级,具体作用尚未明确 */ - public $id; + public $priority = 0; + + /** + * @var float 折射率,当使用体积效果时,这里的折射率会代覆盖表面上玻璃类材质的IOR,同时需要禁止表面上玻璃类材质的IOR的参数输出 + */ + public $ior = 1.5; + + + + /** + * @var string 一个色值或是一个textures(贴图数组)中的某个键名,表示材质的自发光颜色,如果为空,则关闭材质的自发光, + */ + public $emission; + + /** + * @var object 一个 Emission类 的实例, + */ + public $emissionId; + + /** * @var string TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出 */ public $cards; + + /** + * @var bool 设置当前材质是否保存和使用全局光缓存,当需要打开时,需要渲染器开启全局光缓存功能(取值:ture 或 false) + */ + public $photongiEnable = self::CLOSE; + + /** + * @var string 体积类型 + */ + public $type; + + /** + * @var integer 当前体积的ID号(取值:大于0的整数) + */ + public $id; + + public function setEmission($color,$emissionId = 0) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->emission = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->emission = $color; + $this->emissionId = $emissionId; + } + + public function setAbsorption($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->absorption = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->absorption = $color; + } + + public function setIor($color) + { + if( is_object($color) ) + { + if( $color->cards != null ) $this->ior = $color->cards; + else + { + throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property"); + } + } + else $this->ior = $color; + } } ?>