Browse Source

材质与贴图类添加set函数,增加了两个贴图的类

master
yuanjiajia 3 years ago
parent
commit
210147137a
  1. 17
      examples/print.php
  2. 12
      src/scene/Scene.php
  3. 86
      src/scene/materials/Disney.php
  4. 2
      src/scene/materials/Emission.php
  5. 57
      src/scene/materials/Glass.php
  6. 62
      src/scene/materials/Glossy.php
  7. 17
      src/scene/materials/MaterialsBase.php
  8. 31
      src/scene/materials/Metal.php
  9. 15
      src/scene/materials/Mix.php
  10. 15
      src/scene/materials/NullMaterial.php
  11. 25
      src/scene/materials/Roughmatte.php
  12. 54
      src/scene/texture/ImageMap.php
  13. 17
      src/scene/texture/TextureBase.php
  14. 42
      src/scene/texture/mapping/Mapping.php

17
examples/print.php

@ -6,6 +6,7 @@ namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\scene\materials; use Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\scene\objects; use Blobt\Luxcore\scene\objects;
use Blobt\Luxcore\scene\render; use Blobt\Luxcore\scene\render;
use Blobt\Luxcore\scene\texture;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
@ -47,7 +48,7 @@ echo $batch;
$scene = new Scene(); $scene = new Scene();
echo $scene; echo $scene;
*/
//设置打印 “胶片” 配置参数 //设置打印 “胶片” 配置参数
@ -67,7 +68,7 @@ $film->addImage($img);
echo $film; echo $film;
*/
@ -84,21 +85,25 @@ $scene = new Scene();//创建一个场景,
//添加第一个模型 //添加第一个模型
$bumpMap = new texture\ImageMap();
$baseColorMap = new texture\ImageMap();
$metallicMap = new texture\ImageMap();
$material1 = new materials\Disney(); //创建一个 Disney 材质 $material1 = new materials\Disney(); //创建一个 Disney 材质
$material2 = new materials\Metal(); //创建一个 Metal 材质 $material2 = new materials\Metal(); //创建一个 Metal 材质
$material1 = $scene->setMaterial($material1); //将材质存入材质数组,并获得其键名
$material2 = $scene->setMaterial($material2); //将材质存入材质数组,并获得其键名
$material1 = $scene->addMaterial($material1); //将材质存入材质数组,并获得其键名
$material2 = $scene->addMaterial($material2); //将材质存入材质数组,并获得其键名
$mix = new materials\Mix(); //创建 Mix 材质, $mix = new materials\Mix(); //创建 Mix 材质,
$mix->material1 = $material1; //为材质通道1 指定一个键名 $mix->material1 = $material1; //为材质通道1 指定一个键名
$mix->material2 = $material2; //为材质通道2 指定一个键名 $mix->material2 = $material2; //为材质通道2 指定一个键名
$mix->amount = 0.6; //指定混合系数为 0.6 $mix->amount = 0.6; //指定混合系数为 0.6
$mix = $scene->setMaterial($mix); //将材质存入材质数组,并获得其键名
$mix = $scene->addMaterial($mix); //将材质存入材质数组,并获得其键名
$obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型, $obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型,
$obj->material = $mix; //为模型的材属性 指定一个键名 $obj->material = $mix; //为模型的材属性 指定一个键名
$scene->setObjects($obj); //将模型添加到场景中
$scene->addObjects($obj); //将模型添加到场景中
/* /*

12
src/scene/Scene.php

@ -45,14 +45,14 @@ class Scene extends BaseCfg
} }
public function setObjects($obj)
public function addObjects($obj)
{ {
$temp = null; $temp = null;
$temp = sprintf("%014d",$obj->id); $temp = sprintf("%014d",$obj->id);
$this->objects[$temp] = $obj; $this->objects[$temp] = $obj;
} }
public function setMaterial($material)
public function addMaterial($material)
{ {
$temp = null; $temp = null;
$temp = $material->type.'_'.sprintf("%014d",$material->id); $temp = $material->type.'_'.sprintf("%014d",$material->id);
@ -61,7 +61,7 @@ class Scene extends BaseCfg
} }
public function setTexture($texture)
public function addTexture($texture)
{ {
$temp = null; $temp = null;
$temp = $texture->type.'_'.sprintf("%014d",$texture->id); $temp = $texture->type.'_'.sprintf("%014d",$texture->id);
@ -69,7 +69,7 @@ class Scene extends BaseCfg
return $temp; return $temp;
} }
public function setVolume($volume)
public function addVolume($volume)
{ {
$temp = null; $temp = null;
$temp = $volume->type.'_'.sprintf("%014d",$volume->id); $temp = $volume->type.'_'.sprintf("%014d",$volume->id);
@ -77,7 +77,7 @@ class Scene extends BaseCfg
return $temp; return $temp;
} }
public function setLight($light)
public function addLight($light)
{ {
$temp = null; $temp = null;
$temp = $light->type.'_'.sprintf("%014d",$light->id); $temp = $light->type.'_'.sprintf("%014d",$light->id);
@ -85,7 +85,7 @@ class Scene extends BaseCfg
return $temp; return $temp;
} }
public function setCamera($camera)
public function addCamera($camera)
{ {
$temp = null; $temp = null;
$temp = $camera->type.'_'.sprintf("%014d",$camera->id); $temp = $camera->type.'_'.sprintf("%014d",$camera->id);

86
src/scene/materials/Disney.php

@ -104,6 +104,92 @@ class Disney extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setBaseColor($color)
{
$this->basecolor = $color;
}
public function setSubsurface($color)
{
$this->subsurface = $color;
}
public function setMetallic($color)
{
$this->metallic = $color;
}
public function setSpecular($color)
{
$this->specular = $color;
}
public function setSpeculartint($color)
{
$this->speculartint = $color;
}
public function setRoughness($color)
{
$this->roughness = $color;
}
public function setAnisotropic($color)
{
$this->anisotropic = $color;
}
public function setSheen($color)
{
$this->sheen = $color;
}
public function setSheentint($color)
{
$this->sheentint = $color;
}
public function setClearcoat($color)
{
$this->clearcoat = $color;
}
public function setClearcoatgloss($color)
{
$this->clearcoatgloss = $color;
}
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setFilmamount($color)
{
$this->filmamount = $color;
}
public function setFilmthickness($color)
{
$this->filmthickness = $color;
}
public function setFilmior($color)
{
$this->filmior = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
} }
?> ?>

2
src/scene/materials/Emission.php

@ -70,7 +70,7 @@ class Emission extends BaseCfg
public $gamma; public $gamma;
/** /**
* @var string 图片的色值以何种方式表示(固定取值:"float"
* @var string 输出的图片的色值以何种方式表示(固定取值:"float"
*/ */
public $storage; public $storage;
} }

57
src/scene/materials/Glass.php

@ -30,7 +30,7 @@ class Glass extends MaterialsBase
public $kr = "1 1 1"; public $kr = "1 1 1";
/** /**
* @var float 菲列尔折射率,一个1-2的小数或一个textures(贴图数组)中的某个键名,
* @var float 内部折射率,一个1-2的小数或一个textures(贴图数组)中的某个键名,
*/ */
public $interiorior = 1.5; public $interiorior = 1.5;
@ -86,6 +86,61 @@ class Glass extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setUroughness($color)
{
$this->uroughness = $color;
}
public function setVroughness($color)
{
$this->vroughness = $color;
}
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
public function setFilmthickness($color)
{
$this->filmthickness = $color;
}
public function setFilmior($color)
{
$this->filmior = $color;
}
public function setTransmission($color)
{
$this->kt = $color;
}
public function setRefraction($color)
{
$this->kr = $color;
}
public function setInteriorIor($color)
{
$this->interiorior = $color;
}
public function setCauchyb($color)
{
$this->cauchyb = $color;
}
} }
?> ?>

62
src/scene/materials/Glossy.php

@ -17,7 +17,7 @@ class Glossy extends MaterialsBase
/** /**
* @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名; * @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
*/ */
public $ks = "0.5 0.5 0.5";
public $ks = "0.05 0.05 0.05";
/** /**
* @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名 * @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
@ -74,6 +74,66 @@ class Glossy extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setUroughness($color)
{
$this->uroughness = $color;
}
public function setVroughness($color)
{
$this->vroughness = $color;
}
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
public function setBaseColor($color)
{
$this->kd = $color;
}
public function setSpecular($color)
{
$this->ks = $color;
}
public function setAbsorption($color)
{
$this->ka = $color;
}
public function setAbsorptionDepht($color)
{
$this->d = $color;
}
public function setIor($color)
{
$this->index = $color;
}
public function openMultiBounce()
{
$this->multibounce = true;
}
public function closeMultiBounce()
{
$this->multibounce = false;
}
} }
?> ?>

17
src/scene/materials/MaterialsBase.php

@ -23,7 +23,7 @@ class MaterialsBase extends BaseCfg
/** /**
* @var integer 当前材质的ID号(取值:大于0的整数) * @var integer 当前材质的ID号(取值:大于0的整数)
*/ */
public $id = 1000000;
public $id;
/** /**
* @var float TODO:采样距离,具体作用尚未明确,(固定取值:0.001 * @var float TODO:采样距离,具体作用尚未明确,(固定取值:0.001
@ -81,6 +81,21 @@ class MaterialsBase extends BaseCfg
*/ */
public $volumeExterior; public $volumeExterior;
public function setEmission($color)
{
$this->emission = $color;
}
public function setVolumeInterior($color)
{
$this->volumeInterior = $color;
}
public function setVolumeExterior($color)
{
$this->volumeExterior = $color;
}
} }
?> ?>

31
src/scene/materials/Metal.php

@ -49,6 +49,37 @@ class Metal extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setFresnel($color)
{
$this->fresnel = $color;
}
public function setUroughness($color)
{
$this->uroughness = $color;
}
public function setVroughness($color)
{
$this->vroughness = $color;
}
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
} }
?> ?>

15
src/scene/materials/Mix.php

@ -37,6 +37,21 @@ class Mix extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setMaterial1($Material)
{
$this->material1 = $Material;
}
public function setMaterial2($Material)
{
$this->material2 = $Material;
}
public function setAmount($amount)
{
$this->amount = $amount;
}
} }
?> ?>

15
src/scene/materials/NullMaterial.php

@ -33,6 +33,21 @@ class NullMaterial extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
} }
?> ?>

25
src/scene/materials/Roughmatte.php

@ -43,6 +43,31 @@ class Roughmatte extends MaterialsBase
Base::__construct($config); Base::__construct($config);
} }
public function setTransparencyFront($color)
{
$this->transparencyFront = $color;
}
public function setTransparencyBack($color)
{
$this->transparencyBack = $color;
}
public function setBumptex($color)
{
$this->bumptex = $color;
}
public function setBaseColor($color)
{
$this->kd = $color;
}
public function setSigma($color)
{
$this->sigma = $color;
}
} }
?> ?>

54
src/scene/texture/ImageMap.php

@ -0,0 +1,54 @@
<?php
namespace Blobt\Luxcore\scene\texture;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\texture\mapping;
class ImageMap extends TextureBase
{
const TYPE_IMAGEMAP = 'imagemap';
/**
* @var string 光域网文件名及路径,如果为空,则表示不使用光域网
*/
public $file;
/**
* @var string 亮度增益,当发光强度单位是 artistic 类型时,或是 坎德拉类型且坎德拉参数下勾选为(每平方米时),可以设置此参数,分别
* 控制自发光颜色RGB三个通道的放大倍数;否则固定为 1 1 1
*/
public $gain = "1 1 1";
/**
* @var float 校正光域网文件的gamma值,(固定取值:1)
*/
public $gamma;
/**
* @var bool 是否随机重复
*/
public $randomizedtilingEnable = false;
/**
* @var object 铺贴参数,一个Mapping类对象
*/
public $mapping;
/**
* @var string 输出图片储存方式
*/
public $storage = 'byte';
public function __construct($config = [])
{
$this->id = Scene::createID();
$this->mapping = new mapping\Mapping();
Base::__construct($config);
}
}
?>

17
src/scene/texture/TextureBase.php

@ -2,19 +2,20 @@
namespace Blobt\Luxcore\scene\texture; namespace Blobt\Luxcore\scene\texture;
use Blobt\Luxcore\scene\BaseCfg; use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class TextureBase extends BaseCfg class TextureBase extends BaseCfg
{ {
/**
* @var string 贴图类型
*/
public $type;
public function __construct($config = [])
{
$this->id = Scene::createID();
Base::__construct($config);
}
/**
* @var integer 当前贴图的ID号(取值:大于0的整数)
*/
public $id;
} }
?> ?>

42
src/scene/texture/mapping/Mapping.php

@ -0,0 +1,42 @@
<?php
namespace Blobt\Luxcore\scene\texture\mapping;
use Blobt\Luxcore\scene\BaseCfg;
class Mapping extends BaseCfg
{
/**
* @var string 铺贴类型
*/
public $type;
/**
* @var integer 当前贴图的ID号(取值:大于0的整数)
*/
public $id;
/**
* @var string 贴图缩放参数
*/
public $uvscale = '1 -1';
/**
* @var string 贴图偏移参数
*/
public $uvdelta = '0 1';
/**
* @var float 贴图旋转参数
*/
public $rotation = 0;
/**
* @var integer UV通道
*/
public $uvindex = 0;
}
?>
Loading…
Cancel
Save