Browse Source

新增了两个材质类文件

master
yuanjiajia 3 years ago
parent
commit
d9a7cfeaeb
  1. 240
      src/scene/materials/CarPaint.php
  2. 166
      src/scene/materials/GlossyCoating.php

240
src/scene/materials/CarPaint.php

@ -0,0 +1,240 @@
<?php
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class CarPaint extends MaterialsBase
{
/**
* 使用此类材质不能设置不透明度
*/
const TYPE_CARPAINT = 'carpaint';
/**
* @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $kd = "0.3 0.3 0.3";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $ks1 = "1 1 1";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $ks2 = "1 1 1";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $ks3 = "1 1 1";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $m1 = "0.25";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $m2 = "0.1";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $m3 = "0.015";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $r1 = "0.95";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $r2 = "0.9";
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $r3 = "0.7";
/**
* @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $ka = "0 0 0";
/**
* @var float 吸收颜色深度,一个大于等于0的小数,或是一个textures(贴图数组)中的某个键名
*/
public $d = 0;
public function __construct($config = [])
{
$this->type = self::TYPE_CARPAINT;
$this->id = Scene::createID();
Base::__construct($config);
}
public function setBaseColor($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->kd = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->kd = $color;
}
public function setSpecular1($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ks1 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ks1 = $color;
}
public function setSpecular2($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ks2 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ks2 = $color;
}
public function setSpecular3($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ks3 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ks3 = $color;
}
public function setMicrofacetRoughness1($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->m1 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->m1 = $color;
}
public function setMicrofacetRoughness2($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->m2 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->m2 = $color;
}
public function setMicrofacetRoughness3($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->m3 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->m3 = $color;
}
public function setGlossy1($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->r1 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->r1 = $color;
}
public function setGlossy2($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->r2 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->r2 = $color;
}
public function setGlossy3($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->r3 = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->r3 = $color;
}
public function setAbsorption($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ka = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ka = $color;
}
public function setAbsorptionDepht($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->d = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->d = $color;
}
}
?>

166
src/scene/materials/GlossyCoating.php

@ -0,0 +1,166 @@
<?php
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class GlossyCoating extends MaterialsBase
{
/**
* 使用此类材质不能设置不透明度
*/
const TYPE_GLOSSYCOATING = 'glossycoating';
/**
* @var string 一个材质类的实例,(材质数组的某个键名)
*/
public $base;
/**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/
public $ks = "0.05 0.05 0.05";
/**
* @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $ka = "0 0 0";
/**
* @var float 吸收颜色深度,一个大于等于0的小数,或是一个textures(贴图数组)中的某个键名
*/
public $d = 0;
/**
* @var float U向粗糙度,一个0-0.8的小数,或是一个textures(贴图数组)中的某个键名
*/
public $uroughness = 0.05;
/**
* @var float V向粗糙度,一个0-0.8的小数,或是一个textures(贴图数组)中的某个键名
*/
public $vroughness = 0.05;
/**
* @var float 菲列尔折射率,如果设置为1-2的一个小数或一个textures(贴图数组)中的某个键名,表示使用这个数值的 IOR 参数,
* 如果设置为"0 0 0",表示不使用 IOR 参数
*/
public $index = "0 0 0";
/**
* @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false)
*/
public $multibounce = self::CLOSE;
public function __construct($config = [])
{
$this->type = self::TYPE_GLOSSYCOATING;
$this->id = Scene::createID();
Base::__construct($config);
}
public function setUroughness($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->uroughness = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->uroughness = $color;
}
public function setVroughness($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->vroughness = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->vroughness = $color;
}
public function setBase($material)
{
if( is_object($material) )
{
if( $material->cards != null ) $this->base = $material->cards;
else
{
throw new \Exception("You use an unregistered ".$material->getInstanceClassName()." object for the current property");
}
}
else $this->base = $material;
}
public function setSpecular($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ks = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ks = $color;
}
public function setAbsorption($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->ka = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->ka = $color;
}
public function setAbsorptionDepht($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->d = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->d = $color;
}
public function setIor($color)
{
if( is_object($color) )
{
if( $color->cards != null ) $this->index = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->index = $color;
}
public function openMultiBounce()
{
$this->multibounce = self::OPEN;
}
public function closeMultiBounce()
{
$this->multibounce = self::CLOSE;
}
}
?>
Loading…
Cancel
Save