Browse Source

新增三个体积效果的类文件,修改了体积效果基类文件,材质、贴图、模型、类文件的bool型属性使用了OPEN、CLOSE常量初始化

master
yuanjiajia 3 years ago
parent
commit
cdffeb4dff
  1. 6
      examples/print.php
  2. 2
      src/scene/materials/Disney.php
  3. 6
      src/scene/materials/Glossy.php
  4. 12
      src/scene/materials/GlossyTranslucent.php
  5. 16
      src/scene/materials/MaterialsBase.php
  6. 2
      src/scene/materials/emission/Emission.php
  7. 6
      src/scene/materials/emission/Visibility.php
  8. 4
      src/scene/objects/Objects.php
  9. 2
      src/scene/texture/map/ImageMap.php
  10. 2
      src/scene/texture/mapping/Triplanar.php
  11. 11
      src/scene/volumes/Clear.php
  12. 72
      src/scene/volumes/HeteroGeneous.php
  13. 62
      src/scene/volumes/HomoGeneous.php
  14. 84
      src/scene/volumes/VolumesBase.php

6
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' ] ); //创建一个的模型, $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 = new materials\Glass(); //创建一个玻璃材质,
$colorGlass->setVolumeInterior($ClearVol); //将 Clear体积材质赋值到玻璃材质 的 体积属性
$colorGlass->setVolumeInterior($ClearVol); //将 Clear体积效果赋值到玻璃材质 的 体积属性
$scene->registerMaterial($colorGlass); //将玻璃材质注册到 Scene $scene->registerMaterial($colorGlass); //将玻璃材质注册到 Scene
$obj->setMaterial($colorGlass); //将玻璃材质赋值到模型的材质属性 $obj->setMaterial($colorGlass); //将玻璃材质赋值到模型的材质属性

2
src/scene/materials/Disney.php

@ -11,7 +11,7 @@ class Disney extends MaterialsBase
const TYPE_DISNEY = 'disney'; const TYPE_DISNEY = 'disney';
/** /**
* @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名sd
* @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/ */
public $basecolor = "0.7 0.7 0.7"; public $basecolor = "0.7 0.7 0.7";

6
src/scene/materials/Glossy.php

@ -48,7 +48,7 @@ class Glossy extends MaterialsBase
/** /**
* @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false) * @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false)
*/ */
public $multibounce = false;
public $multibounce = self::CLOSE;
public function __construct($config = []) public function __construct($config = [])
{ {
@ -150,12 +150,12 @@ class Glossy extends MaterialsBase
public function openMultiBounce() public function openMultiBounce()
{ {
$this->multibounce = true;
$this->multibounce = self::OPEN;
} }
public function closeMultiBounce() public function closeMultiBounce()
{ {
$this->multibounce = false;
$this->multibounce = self::CLOSE;
} }
} }

12
src/scene/materials/GlossyTranslucent.php

@ -53,7 +53,7 @@ class Glossy extends MaterialsBase
/** /**
* @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false) * @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false)
*/ */
public $multibounce = false;
public $multibounce = self::CLOSE;
@ -92,7 +92,7 @@ class Glossy extends MaterialsBase
/** /**
* @var bool TODO:BF 否是使用多弹射,具体作用尚未明确,(默认取值:false) * @var bool TODO:BF 否是使用多弹射,具体作用尚未明确,(默认取值:false)
*/ */
public $multibounce_bf = false;
public $multibounce_bf = self::CLOSE;
public function __construct($config = []) public function __construct($config = [])
@ -208,12 +208,12 @@ class Glossy extends MaterialsBase
public function openMultiBounce() public function openMultiBounce()
{ {
$this->multibounce = true;
$this->multibounce = self::OPEN;
} }
public function closeMultiBounce() public function closeMultiBounce()
{ {
$this->multibounce = false;
$this->multibounce = self::CLOSE;
} }
@ -300,12 +300,12 @@ class Glossy extends MaterialsBase
public function openMultiBounce_BF() public function openMultiBounce_BF()
{ {
$this->multibounce_bf = true;
$this->multibounce_bf = self::OPEN;
} }
public function closeMultiBounce_BF() public function closeMultiBounce_BF()
{ {
$this->multibounce_bf = false;
$this->multibounce_bf = self::CLOSE;
} }
} }

16
src/scene/materials/MaterialsBase.php

@ -33,7 +33,7 @@ class MaterialsBase extends BaseCfg
/** /**
* @var string 一个色值,表示材质的自发光颜色,如果为空,则关闭材质的自发光,
* @var string 一个色值或是一个textures(贴图数组)中的某个键名,表示材质的自发光颜色,如果为空,则关闭材质的自发光,
*/ */
public $emission; public $emission;
@ -50,12 +50,12 @@ class MaterialsBase extends BaseCfg
/** /**
* @var string 内部体积材质,(体积材质数组的某个键名)
* @var string 内部体积效果,(体积效果数组的某个键名)
*/ */
public $volumeInterior; public $volumeInterior;
/** /**
* @var string 外部体积材质,(体积材质数组的某个键名)
* @var string 外部体积效果,(体积效果数组的某个键名)
*/ */
public $volumeExterior; public $volumeExterior;
@ -72,7 +72,7 @@ class MaterialsBase extends BaseCfg
public $id; public $id;
/** /**
* @var bool TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出
* @var string TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出
*/ */
public $cards; public $cards;
@ -84,22 +84,22 @@ class MaterialsBase extends BaseCfg
/** /**
* @var bool 是否开启阴捕捉(取值:ture false * @var bool 是否开启阴捕捉(取值:ture false
*/ */
public $shadowcatcherEnable = false;
public $shadowcatcherEnable = self::CLOSE;
/** /**
* @var bool 是否仅捕捉内部灯光的阴影,需要上一个参数打开,本参数才可以设置(取值:ture false * @var bool 是否仅捕捉内部灯光的阴影,需要上一个参数打开,本参数才可以设置(取值:ture false
*/ */
public $shadowcatcherOnlyinfinitelights = false;
public $shadowcatcherOnlyinfinitelights = self::CLOSE;
/** /**
* @var bool 设置当前材质是否保存和使用全局光缓存,当需要打开时,需要渲染器开启全局光缓存功能(取值:ture false * @var bool 设置当前材质是否保存和使用全局光缓存,当需要打开时,需要渲染器开启全局光缓存功能(取值:ture false
*/ */
public $photongiEnable = true;
public $photongiEnable = self::OPEN;
/** /**
* @var bool 设置当前材质的模型是否对摄像机背景透明,当需要打开时,需要摄像机开启 Transparent Film 功通(取值:ture false * @var bool 设置当前材质的模型是否对摄像机背景透明,当需要打开时,需要摄像机开启 Transparent Film 功通(取值:ture false
*/ */
public $holdoutEnable = false;
public $holdoutEnable = self::CLOSE;

2
src/scene/materials/emission/Emission.php

@ -27,7 +27,7 @@ class Emission extends BaseCfg
/** /**
* @var bool TODO:颜色亮度进行规格化,具体作用沿未明确,当发光强度单位非 artistic 类型时,可以设置此参数,(取值:true或false),否则固定为 false * @var bool TODO:颜色亮度进行规格化,具体作用沿未明确,当发光强度单位非 artistic 类型时,可以设置此参数,(取值:true或false),否则固定为 false
*/ */
public $normalizebycolor = false;
public $normalizebycolor = self::CLOSE;
/** /**
* @var float 光线的发射时的扩散角度,设置为光源的半角。默认值为90。较小的值意味着在 垂直光源表面 的方向上发射的光更多,而在侧面发射的光更少,反之亦然 * @var float 光线的发射时的扩散角度,设置为光源的半角。默认值为90。较小的值意味着在 垂直光源表面 的方向上发射的光更多,而在侧面发射的光更少,反之亦然

6
src/scene/materials/emission/Visibility.php

@ -9,17 +9,17 @@ class Visibility extends BaseCfg
/** /**
* @var bool 是否开启漫反射可见(取值:true false * @var bool 是否开启漫反射可见(取值:true false
*/ */
public $indirectDiffuseEnable = true;
public $indirectDiffuseEnable = self::OPEN;
/** /**
* @var bool 是否开启光泽度可见(取值:ture false * @var bool 是否开启光泽度可见(取值:ture false
*/ */
public $indirectGlossyEnable = true;
public $indirectGlossyEnable = self::OPEN;
/** /**
* @var bool 是否开启高光可见(取值:ture false * @var bool 是否开启高光可见(取值:ture false
*/ */
public $indirectSpecularEnable = true;
public $indirectSpecularEnable = self::OPEN;
} }

4
src/scene/objects/Objects.php

@ -19,9 +19,9 @@ class Objects extends BaseCfg
public $ply; public $ply;
/** /**
* @var bool 是否对摄相机可见
* @var bool 是否对摄相机隐藏
*/ */
public $camerainvisible = false;
public $camerainvisible = self::CLOSE;
/** /**
* @var integer 模型的ID(取值:大于0的整数) * @var integer 模型的ID(取值:大于0的整数)

2
src/scene/texture/map/ImageMap.php

@ -31,7 +31,7 @@ class ImageMap extends TextureBase
/** /**
* @var bool 是否随机重复 * @var bool 是否随机重复
*/ */
public $randomizedtilingEnable = false;
public $randomizedtilingEnable = self::CLOSE;
/** /**
* @var object 铺贴参数,一个Mapping类对象 * @var object 铺贴参数,一个Mapping类对象

2
src/scene/texture/mapping/Triplanar.php

@ -29,7 +29,7 @@ class Triplanar extends TextureBase
/** /**
* @var bool 是否为凹凸贴图模式 * @var bool 是否为凹凸贴图模式
*/ */
public $uvlessbumpmapEnable = 1;
public $uvlessbumpmapEnable = self::OPEN;
/** /**
* @var object 铺贴参数,一个Mapping类对象 * @var object 铺贴参数,一个Mapping类对象

11
src/scene/volumes/Clear.php

@ -1,10 +1,21 @@
<?php <?php
namespace Blobt\Luxcore\scene\volumes; namespace Blobt\Luxcore\scene\volumes;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
class Clear extends VolumesBase class Clear extends VolumesBase
{ {
const TYPE_CLEAR = 'clear';
public function __construct($config = [])
{
$this->type = self::TYPE_CLEAR;
$this->id = Scene::createID();
core\Base::__construct($config);
}
} }
?> ?>

72
src/scene/volumes/HeteroGeneous.php

@ -0,0 +1,72 @@
<?php
namespace Blobt\Luxcore\scene\volumes;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
class HomoGeneous extends VolumesBase
{
const TYPE_HETEROGENEOUS = 'heterogeneous';
/**
* @var string 散射颜色,一个色值或是一个textures(贴图数组)中的某个键名
*/
public $scattering = '1 1 1';
/**
* @var string 非均匀颜色,一个色值或是一个textures(贴图数组)中的某个键名
*/
public $asymmetry = '0 0 0';
/**
* @var bool 多散射,(取值:true或false)
*/
public $multiscattering = false;
/**
* @var float TODO:步长,具体作用尚未明确,(取值:大于等于0.01的小数)
*/
public $stepsSize = 0.1;
/**
* @var integer TODO:最大步长,具体作用尚未明确,(取值:大于等于0的整数)
*/
public $stepsMaxcount = 1024;
public function __construct($config = [])
{
$this->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;
}
}
?>

62
src/scene/volumes/HomoGeneous.php

@ -0,0 +1,62 @@
<?php
namespace Blobt\Luxcore\scene\volumes;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
class HomoGeneous extends VolumesBase
{
const TYPE_HOMOGENEOUS = 'homogeneous';
/**
* @var string 散射颜色,一个色值或是一个textures(贴图数组)中的某个键名
*/
public $scattering = '1 1 1';
/**
* @var string 非均匀颜色,一个色值或是一个textures(贴图数组)中的某个键名
*/
public $asymmetry = '0 0 0';
/**
* @var bool 多散射,(取值:true或false)
*/
public $multiscattering = false;
public function __construct($config = [])
{
$this->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;
}
}
?>

84
src/scene/volumes/VolumesBase.php

@ -5,20 +5,96 @@ use Blobt\Luxcore\scene\BaseCfg;
class VolumesBase extends 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类颁发的注册信息,后期会屏敝此参数的输出 * @var string TODO:储存个由Scene类颁发的注册信息,后期会屏敝此参数的输出
*/ */
public $cards; 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;
}
} }
?> ?>
Loading…
Cancel
Save