Browse Source

渲染器类构造函数形参增加了默认值,材质、贴图、模型、体积材质修改set涵数,Base类文件增加了获取子类名的函数

master
yuanjiajia 3 years ago
parent
commit
052ad4e5a9
  1. 18
      examples/print.php
  2. 8
      src/core/Base.php
  3. 34
      src/scene/materials/Disney.php
  4. 110
      src/scene/materials/Glass.php
  5. 100
      src/scene/materials/Glossy.php
  6. 46
      src/scene/materials/MaterialsBase.php
  7. 21
      src/scene/materials/Metal.php
  8. 6
      src/scene/materials/Mix.php
  9. 30
      src/scene/materials/NullMaterial.php
  10. 50
      src/scene/materials/Roughmatte.php
  11. 7
      src/scene/objects/Objects.php
  12. 12
      src/scene/render/Film.php
  13. 1
      src/scene/render/OpenCL.php
  14. 12
      src/scene/render/Path.php
  15. 13
      src/scene/render/Sampler.php
  16. 7
      src/scene/render/cache/LightStrategy.php
  17. 12
      src/scene/render/cache/PhotonGI.php
  18. 5
      src/scene/texture/TextureBase.php
  19. 2
      src/scene/texture/map/Blend.php
  20. 2
      src/scene/texture/map/Clouds.php
  21. 2
      src/scene/texture/map/ImageMap.php
  22. 2
      src/scene/texture/mapping/Triplanar.php
  23. 3
      src/scene/texture/transform/NormalMap.php
  24. 6
      src/scene/volumes/VolumesBase.php

18
examples/print.php

@ -8,13 +8,6 @@ include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
/*
echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'; echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>';
echo "\n\n\n\n"; echo "\n\n\n\n";
@ -28,7 +21,7 @@ $openCL = new render\OpenCL();
echo $openCL; echo $openCL;
//设置打印光线跟踪的配置参数 //设置打印光线跟踪的配置参数
$path = new render\Path( new render\PathDepth( ['total'=>24,'glossy'=>12] ) );
$path = new render\Path();
echo $path; echo $path;
//设置打印 采样器 配置参数 //设置打印 采样器 配置参数
@ -54,7 +47,7 @@ echo $scene;
//设置打印 “胶片” 配置参数 //设置打印 “胶片” 配置参数
$film = new render\Film( new render\NoiseEstimation(),new render\Filter() );//添加一个胶片,
$film = new render\Film();//添加一个胶片,
$img = new render\Image(); $img = new render\Image();
$img->effect = [new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()]; $img->effect = [new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()];
@ -72,7 +65,7 @@ echo $film;
*/
@ -82,7 +75,7 @@ echo "\n\n\n\n";
$scene = new Scene();//创建一个场景, $scene = new Scene();//创建一个场景,
/*
//添加第一个模型 //添加第一个模型
@ -96,7 +89,7 @@ $imageMap = new texture\map\ImageMap(); //创建一个 ImageMap类的贴图
$scene->registerTexture($imageMap); //将这个对象注册到 Scene $scene->registerTexture($imageMap); //将这个对象注册到 Scene
$blend = new texture\map\Blend(); //创建一个 Blend类的贴图对象 $blend = new texture\map\Blend(); //创建一个 Blend类的贴图对象
//$scene->registerTexture($blend); //将这个对象注册到 Scene
$scene->registerTexture($blend); //将这个对象注册到 Scene
$disney = new materials\Disney(); //创建一个 Disney 材质对象 $disney = new materials\Disney(); //创建一个 Disney 材质对象
@ -135,4 +128,5 @@ $scene->addObject($obj); //将模型添加到场景中
echo $scene; echo $scene;
?> ?>

8
src/core/Base.php

@ -17,4 +17,12 @@ class Base
} }
} }
/**
* 获得子类的类名
*/
public function getInstanceClassName()
{
return array_reverse(explode('\\', get_class($this)))[0];
}
} }

34
src/scene/materials/Disney.php

@ -113,7 +113,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->basecolor = $color->cards; if( $color->cards != null ) $this->basecolor = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->basecolor = $color; else $this->basecolor = $color;
@ -126,7 +126,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->subsurface = $color->cards; if( $color->cards != null ) $this->subsurface = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->subsurface = $color; else $this->subsurface = $color;
@ -139,7 +139,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->metallic = $color->cards; if( $color->cards != null ) $this->metallic = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->metallic = $color; else $this->metallic = $color;
@ -152,7 +152,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->specular = $color->cards; if( $color->cards != null ) $this->specular = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->specular = $color; else $this->specular = $color;
@ -165,7 +165,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->speculartint = $color->cards; if( $color->cards != null ) $this->speculartint = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->speculartint = $color; else $this->speculartint = $color;
@ -178,7 +178,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->roughness = $color->cards; if( $color->cards != null ) $this->roughness = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->roughness = $color; else $this->roughness = $color;
@ -191,7 +191,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->anisotropic = $color->cards; if( $color->cards != null ) $this->anisotropic = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->anisotropic = $color; else $this->anisotropic = $color;
@ -204,7 +204,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->sheen = $color->cards; if( $color->cards != null ) $this->sheen = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->sheen = $color; else $this->sheen = $color;
@ -217,7 +217,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->sheentint = $color->cards; if( $color->cards != null ) $this->sheentint = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->sheentint = $color; else $this->sheentint = $color;
@ -230,7 +230,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->clearcoat = $color->cards; if( $color->cards != null ) $this->clearcoat = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->clearcoat = $color; else $this->clearcoat = $color;
@ -243,7 +243,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->clearcoatgloss = $color->cards; if( $color->cards != null ) $this->clearcoatgloss = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->clearcoatgloss = $color; else $this->clearcoatgloss = $color;
@ -256,7 +256,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->transparencyFront = $color->cards; if( $color->cards != null ) $this->transparencyFront = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->transparencyFront = $color; else $this->transparencyFront = $color;
@ -269,7 +269,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->transparencyBack = $color->cards; if( $color->cards != null ) $this->transparencyBack = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->transparencyBack = $color; else $this->transparencyBack = $color;
@ -282,7 +282,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->filmamount = $color->cards; if( $color->cards != null ) $this->filmamount = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->filmamount = $color; else $this->filmamount = $color;
@ -294,7 +294,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->filmthickness = $color->cards; if( $color->cards != null ) $this->filmthickness = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->filmthickness = $color; else $this->filmthickness = $color;
@ -307,7 +307,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->filmior = $color->cards; if( $color->cards != null ) $this->filmior = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->filmior = $color; else $this->filmior = $color;
@ -320,7 +320,7 @@ class Disney extends MaterialsBase
if( $color->cards != null ) $this->bumptex = $color->cards; if( $color->cards != null ) $this->bumptex = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->bumptex = $color; else $this->bumptex = $color;

110
src/scene/materials/Glass.php

@ -86,57 +86,145 @@ class Glass extends MaterialsBase
public function setUroughness($color) public function setUroughness($color)
{ {
$this->uroughness = $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) public function setVroughness($color)
{ {
$this->vroughness = $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 setTransparencyFront($color) public function setTransparencyFront($color)
{ {
$this->transparencyFront = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyFront = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyFront = $color;
} }
public function setTransparencyBack($color) public function setTransparencyBack($color)
{ {
$this->transparencyBack = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyBack = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyBack = $color;
} }
public function setBumptex($color) public function setBumptex($color)
{ {
$this->bumptex = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->bumptex = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bumptex = $color;
} }
public function setFilmthickness($color) public function setFilmthickness($color)
{ {
$this->filmthickness = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->filmthickness = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->filmthickness = $color;
} }
public function setFilmior($color) public function setFilmior($color)
{ {
$this->filmior = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->filmior = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->filmior = $color;
} }
public function setTransmission($color) public function setTransmission($color)
{ {
$this->kt = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->kt = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->kt = $color;
} }
public function setRefraction($color) public function setRefraction($color)
{ {
$this->kr = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->kr = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->kr = $color;
} }
public function setInteriorIor($color) public function setInteriorIor($color)
{ {
$this->interiorior = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->interiorior = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->interiorior = $color;
} }
public function setCauchyb($color) public function setCauchyb($color)
{ {
$this->cauchyb = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->cauchyb = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->cauchyb = $color;
} }
} }

100
src/scene/materials/Glossy.php

@ -74,52 +74,132 @@ class Glossy extends MaterialsBase
public function setUroughness($color) public function setUroughness($color)
{ {
$this->uroughness = $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) public function setVroughness($color)
{ {
$this->vroughness = $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 setTransparencyFront($color) public function setTransparencyFront($color)
{ {
$this->transparencyFront = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyFront = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyFront = $color;
} }
public function setTransparencyBack($color) public function setTransparencyBack($color)
{ {
$this->transparencyBack = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyBack = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyBack = $color;
} }
public function setBumptex($color) public function setBumptex($color)
{ {
$this->bumptex = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->bumptex = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bumptex = $color;
} }
public function setBaseColor($color) public function setBaseColor($color)
{ {
$this->kd = $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 setSpecular($color) public function setSpecular($color)
{ {
$this->ks = $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) public function setAbsorption($color)
{ {
$this->ka = $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) public function setAbsorptionDepht($color)
{ {
$this->d = $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) public function setIor($color)
{ {
$this->index = $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() public function openMultiBounce()

46
src/scene/materials/MaterialsBase.php

@ -86,24 +86,48 @@ class MaterialsBase extends BaseCfg
*/ */
public $volumeExterior; public $volumeExterior;
public function setEmission($color)
public function setEmission($color,Emission $emissionCfg = null,Visibility $visibility = null)
{ {
$this->emission = $color;
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;
if( $emissionCfg != null ) $this->emissionCfg = $emissionCfg;
else $this->emissionCfg = new Emission();
if( $visibility != null ) $this->visibility = $visibility;
else $this->visibility = new Visibility();
} }
public function setVolumeInterior($color)
public function setVolumeInterior($volumeInterior)
{ {
$this->volumeInterior = $color;
if( is_object( $volumeInterior ) )
{
if( $volumeInterior->cards != null ) $this->volumeInterior = $volumeInterior->cards;
else
{
throw new \Exception("You use an unregistered ".$volumeInterior->getInstanceClassName()." object for the current property");
}
}
else $this->volumeInterior = $volumeInterior;
} }
public function setVolumeExterior($color)
public function setVolumeExterior($volumeExterior)
{ {
$this->volumeExterior = $color;
}
public function getClassName()
{
return array_reverse(explode('\\', get_class($this)))[0];
if( is_object( $volumeExterior ) )
{
if( $volumeExterior->cards != null ) $this->volumeExterior = $volumeExterior->cards;
else
{
throw new \Exception("You use an unregistered ".$volumeExterior->getInstanceClassName()." object for the current property");
}
}
else $this->volumeExterior = $volumeExterior;
} }
} }

21
src/scene/materials/Metal.php

@ -59,8 +59,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->kr = $color->cards; if( $color->cards != null ) $this->kr = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->kr = $color; else $this->kr = $color;
@ -74,8 +73,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->fresnel = $color->cards; if( $color->cards != null ) $this->fresnel = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->fresnel = $color; else $this->fresnel = $color;
@ -89,8 +87,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->uroughness = $color->cards; if( $color->cards != null ) $this->uroughness = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->uroughness = $color; else $this->uroughness = $color;
@ -103,8 +100,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->vroughness = $color->cards; if( $color->cards != null ) $this->vroughness = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->vroughness = $color; else $this->vroughness = $color;
@ -117,8 +113,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->transparencyFront = $color->cards; if( $color->cards != null ) $this->transparencyFront = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->transparencyFront = $color; else $this->transparencyFront = $color;
@ -131,8 +126,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->transparencyBack = $color->cards; if( $color->cards != null ) $this->transparencyBack = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->transparencyBack = $color; else $this->transparencyBack = $color;
@ -145,8 +139,7 @@ class Metal extends MaterialsBase
if( $color->cards != null ) $this->bumptex = $color->cards; if( $color->cards != null ) $this->bumptex = $color->cards;
else else
{ {
$className = array_reverse(explode('\\', get_class($color)))[0];
throw new \Exception("You use an unregistered {$className} object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->bumptex = $color; else $this->bumptex = $color;

6
src/scene/materials/Mix.php

@ -42,7 +42,7 @@ class Mix extends MaterialsBase
if( $Material->cards != null ) $this->material1 = $Material->cards; if( $Material->cards != null ) $this->material1 = $Material->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property");
} }
} }
else $this->material1 = $Material; else $this->material1 = $Material;
@ -55,7 +55,7 @@ class Mix extends MaterialsBase
if( $Material->cards != null ) $this->material2 = $Material->cards; if( $Material->cards != null ) $this->material2 = $Material->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$Material->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$Material->getInstanceClassName()." object for the current property");
} }
} }
else $this->material2 = $Material; else $this->material2 = $Material;
@ -68,7 +68,7 @@ class Mix extends MaterialsBase
if( $color->cards != null ) $this->amount = $color->cards; if( $color->cards != null ) $this->amount = $color->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$color->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
} }
} }
else $this->amount = $color; else $this->amount = $color;

30
src/scene/materials/NullMaterial.php

@ -33,17 +33,41 @@ class NullMaterial extends MaterialsBase
public function setTransparencyFront($color) public function setTransparencyFront($color)
{ {
$this->transparencyFront = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyFront = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyFront = $color;
} }
public function setTransparencyBack($color) public function setTransparencyBack($color)
{ {
$this->transparencyBack = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyBack = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyBack = $color;
} }
public function setBumptex($color) public function setBumptex($color)
{ {
$this->bumptex = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->bumptex = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bumptex = $color;
} }
} }

50
src/scene/materials/Roughmatte.php

@ -43,27 +43,67 @@ class Roughmatte extends MaterialsBase
public function setTransparencyFront($color) public function setTransparencyFront($color)
{ {
$this->transparencyFront = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyFront = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyFront = $color;
} }
public function setTransparencyBack($color) public function setTransparencyBack($color)
{ {
$this->transparencyBack = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->transparencyBack = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->transparencyBack = $color;
} }
public function setBumptex($color) public function setBumptex($color)
{ {
$this->bumptex = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->bumptex = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bumptex = $color;
} }
public function setBaseColor($color) public function setBaseColor($color)
{ {
$this->kd = $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 setSigma($color) public function setSigma($color)
{ {
$this->sigma = $color;
if( is_object($color) )
{
if( $color->cards != null ) $this->sigma = $color->cards;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->sigma = $color;
} }
} }

7
src/scene/objects/Objects.php

@ -51,17 +51,12 @@ class Objects extends BaseCfg
if( $material->cards != null ) $this->material = $material->cards; if( $material->cards != null ) $this->material = $material->cards;
else else
{ {
throw new \Exception("You use an unregistered ".$material->getClassName()." object for the current property");
throw new \Exception("You use an unregistered ".$material->getInstanceClassName()." object for the current property");
} }
} }
else $this->material = $material; else $this->material = $material;
} }
public function getClassName()
{
return array_reverse(explode('\\', get_class($this)))[0];
}
} }
?> ?>

12
src/scene/render/Film.php

@ -54,13 +54,15 @@ class Film extends BaseCfg
public $outputs = []; public $outputs = [];
/** /**
* @param object $noiseEstimation 必须传入一个 NoiseEstimationod类对象
* @param object $filter 果需要设置推荐一个默认的参数,则同时传入一个 Filter类对象
* @param object $noiseEstimation 如需自定义NoiseEstimation参数,可以传入一个 NoiseEstimation类对象,否则使用一个默认的NoiseEstimation参数
* @param object $filter 需自定义抗锯齿参数,可以传入一个 Filter类对象,否则使用一个默认的抗锯齿参数
*/ */
public function __construct( NoiseEstimation $noiseEstimation,Filter $filter = null,$config = [])
public function __construct($config = [], NoiseEstimation $noiseEstimation = null,Filter $filter = null)
{ {
$this->noiseEstimation = $noiseEstimation;
$this->filter = $filter;
if($noiseEstimation != null) $this->noiseEstimation = $noiseEstimation;
else $this->noiseEstimation = new NoiseEstimation();
if($filter != null) $this->filter = $filter;
else $this->filter = new Filter();
Base::__construct($config); Base::__construct($config);
} }

1
src/scene/render/OpenCL.php

@ -45,7 +45,6 @@ class OpenCL extends BaseCfg
$this->gpuUse = self::OPEN; $this->gpuUse = self::OPEN;
} }
} }
?> ?>

12
src/scene/render/Path.php

@ -43,13 +43,15 @@ class Path extends BaseCfg
/** /**
* @param object $pathDepth 必须传入一个 PathDepth类对象
* @param object $hybridBackforWard 果需要设置推荐一个默认的参数,则同时传入一个 HybridBackforWard类对象
* @param object $pathDepth 如需自定义追踪深度参数,可以传入一个 PathDepth类对象,否则使用一个默认的追踪深度参数
* @param object $hybridBackforWard 需自定义HybridBackforWard参数,可以传入一个 HybridBackforWard类对象,否则使用一个默认的HybridBackforWard参数
*/ */
public function __construct(PathDepth $pathDepth,HybridBackforWard $hybridBackforWard = null,$config = [])
public function __construct($config = [],PathDepth $pathDepth = null,HybridBackforWard $hybridBackforWard = null)
{ {
$this->pathDepth = $pathDepth;
$this->hybridBackforWard= $hybridBackforWard;
if($pathDepth != null) $this->pathDepth = $pathDepth;
else $this->pathDepth = new PathDepth();
if($hybridBackforWard != null) $this->hybridBackforWard= $hybridBackforWard;
else $this->hybridBackforWard = new HybridBackforWard();
Base::__construct($config); Base::__construct($config);
} }

13
src/scene/render/Sampler.php

@ -34,11 +34,18 @@ class Sampler extends BaseCfg
public $metropolis; public $metropolis;
/** /**
* 实例 一个Sobol类,作为默认的采样器配置参数
* @param object 如需配置一个自定义采样器参数,可以传入一个 采样器类型的对象,否则使用一个默认的采样器参数
*/ */
public function __construct($config = [])
public function __construct($config = [],$sampler = null)
{ {
$this->sobol = new Sobol();
if($sampler != null)
{
if( $sampler instanceof Sobol ) $this->sobol = $sampler;
else if( $sampler instanceof Random ) $this->random = $sampler;
else if( $sampler instanceof Metropolis ) $this->metropolis = $sampler;
else throw new \Exception("You initialize the sampler to pass a ".$sampler->getInstanceClassName()." object, not the sampler type");
}
else $this->sobol = new Sobol();
Base::__construct($config); Base::__construct($config);
} }

7
src/scene/render/cache/LightStrategy.php

@ -39,12 +39,13 @@ class LightStrategy extends render\LightStrategy
public $entry; public $entry;
/** /**
* @param object $entry 必须传入一个 Entry类对象
* @param object $entry 如需自定义Entry参数,可以传入一个 Entry类对象,否则使用一个默认的Entry参数
*/ */
public function __construct(Entry $entry,$config = [])
public function __construct($config = [],Entry $entry = null)
{ {
if($entry = null) $this->entry = $entry;
else $this->entry = new Entry();
$this->type = self::TYPE_DLS_CACHE; $this->type = self::TYPE_DLS_CACHE;
$this->entry = $entry;
Base::__construct($config); Base::__construct($config);
} }

12
src/scene/render/cache/PhotonGI.php

@ -38,13 +38,15 @@ class PhotonGI extends BaseCfg
public $caustic; public $caustic;
/** /**
* @param object $indirect 必须传入一个 Indirect类对象
* @param object $caustic 必须传入一个 Caustic类对象
* @param object $indirect 如需自定义Indirect参数,可以传入一个 Indirect类对象,否则使用一个默认的Indirect参数
* @param object $caustic 如需自定义Caustic参数,可以传入一个 Caustic类对象,否则使用一个默认的Caustic参数
*/ */
public function __construct(Indirect $indirect,Caustic $caustic,$config = [])
public function __construct($config = [],Indirect $indirect = null,Caustic $caustic = null)
{ {
$this->indirect = $indirect;
$this->caustic = $caustic;
if($indirect != null) $this->indirect = $indirect;
else $this->indirect = new Indirect();
if($caustic != null) $this->caustic = $caustic;
else $this->caustic = new Caustic();
Base::__construct($config); Base::__construct($config);
} }

5
src/scene/texture/TextureBase.php

@ -22,11 +22,6 @@ class TextureBase extends BaseCfg
*/ */
public $cards; public $cards;
public function getClassName()
{
return array_reverse(explode('\\', get_class($this)))[0];
}
} }
?> ?>

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

@ -59,7 +59,7 @@ class Blend extends TextureBase
/** /**
* @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数
*/ */
public function __construct(Mapping $mapping = null,$config = [])
public function __construct($config = [],Mapping $mapping = null)
{ {
if( $mapping != null )$this->mapping = $mapping; if( $mapping != null )$this->mapping = $mapping;
else $this->mapping = new Mapping(); else $this->mapping = new Mapping();

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

@ -71,7 +71,7 @@ class Clouds extends TextureBase
/** /**
* @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数
*/ */
public function __construct(Mapping $mapping = null,$config = [])
public function __construct($config = [],Mapping $mapping = null)
{ {
if( $mapping != null )$this->mapping = $mapping; if( $mapping != null )$this->mapping = $mapping;
else $this->mapping = new Mapping(); else $this->mapping = new Mapping();

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

@ -46,7 +46,7 @@ class ImageMap extends TextureBase
/** /**
* @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数
*/ */
public function __construct(Mapping $mapping = null,$config = [])
public function __construct($config = [],Mapping $mapping = null)
{ {
if( $mapping != null )$this->mapping = $mapping; if( $mapping != null )$this->mapping = $mapping;
else $this->mapping = new Mapping(); else $this->mapping = new Mapping();

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

@ -39,7 +39,7 @@ class Triplanar extends TextureBase
/** /**
* @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数
*/ */
public function __construct(Mapping $mapping = null,$config = [])
public function __construct($config = [],Mapping $mapping = null)
{ {
if( $mapping != null )$this->mapping = $mapping; if( $mapping != null )$this->mapping = $mapping;
else $this->mapping = new Mapping(); else $this->mapping = new Mapping();

3
src/scene/texture/transform/NormalMap.php

@ -22,9 +22,6 @@ class ImageMap extends TextureBase
*/ */
public $scale = 1; public $scale = 1;
/**
* @param $mapping 必须传入一个 Mapping类对象
*/
public function __construct($config = []) public function __construct($config = [])
{ {
$this->type = self::TYPE_NORMALMAP; $this->type = self::TYPE_NORMALMAP;

6
src/scene/volumes/VolumesBase.php

@ -8,18 +8,12 @@ use Blobt\Luxcore\core\Base;
class VolumesBase extends BaseCfg class VolumesBase extends BaseCfg
{ {
public function __construct($config = []) public function __construct($config = [])
{ {
$this->id = Scene::createID(); $this->id = Scene::createID();
Base::__construct($config); Base::__construct($config);
} }
public function getClassName()
{
return array_reverse(explode('\\', get_class($this)))[0];
}
} }
?> ?>
Loading…
Cancel
Save