Browse Source

增加了一个线框纹理类文件和一个砖块纹理类文件

master
yuanjiajia 3 years ago
parent
commit
d17734d96e
  1. 147
      src/scene/texture/procedural/Brick.php
  2. 71
      src/scene/texture/procedural/Wireframe.php

147
src/scene/texture/procedural/Brick.php

@ -0,0 +1,147 @@
<?php
namespace Blobt\Luxcore\scene\texture\procedural;
use Blobt\Luxcore\scene\texture\TextureBase;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\texture\mapping\Mapping;
class Brick extends TextureBase
{
/**
* 瓷砖的程序纹理
*/
const TYPE_BRICK = 'brick';
/**
* 堆切预设类型
*/
const TYPE_STACKED = 'stacked';
const TYPE_FLEMISH = 'flemish';
const TYPE_ENGLISH = 'english';
const TYPE_HERRINGBONE = 'herringbone';
const TYPE_BASKET = 'basket';
const TYPE_CHAIN_LINK = 'chain link';
/**
* @var string 堆切预设类型,取值是属于堆切预设类型的某一个字符串常量
*/
public $brickbond = self::TYPE_STACKED;
/**
* @var string 砖块颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $bricktex = "0.3 0.3 0.3";
/**
* @var string 砖块颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $brickmodtex = "0.6 0.6 0.6";
/**
* @var string 砖缝颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $mortartex = "0.2 0.2 0.2";
/**
* @var float 单个砖块的宽度,(取值:大于等于0的小数)
*/
public $brickwidth = 0.3;
/**
* @var float 单个砖块的高度,(取值:大于等于0的小数)
*/
public $brickheight = 0.1;
/**
* @var float 单个砖块的深度,(取值:大于等于0的小数)
*/
public $brickdepth = 0.15;
/**
* @var float 砖缝的宽度,(取值:大于等于0的小数)
*/
public $mortarsize = 0.01;
/**
* @var float 砖块互切(错位)百分比,(取值:0-1的小数)
*/
public $brickrun = 0.75;
/**
* @var object 调制偏置,(取值:-1至1的小数),当值越接近-1时,以$bricktex色的砖块就越多,反之接近1时,以
* $mortartex色的砖块就越多。
*/
public $brickmodbias = 0;
/**
* @var object 铺贴参数,一个Mapping类对象
*/
public $mapping;
/**
* @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性
* @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数
*/
public function __construct($config = [],Mapping $mapping = null)
{
if( $mapping != null )$this->mapping = $mapping;
else $this->mapping = new Mapping();
$this->type = self::TYPE_BRICK;
$this->id = Scene::createID();
Base::__construct($config);
}
/**
* @param object $color 接收一个贴图对象或小数形式的色值,设置砖块纹理的bricktex颜色
*/
public function setBricktex($color)
{
if( is_object($color) )
{
if( $color->registerId != null ) $this->bricktex = $color->registerId;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bricktex = $color;
}
/**
* @param object $color 接收一个贴图对象或小数形式的色值,设置砖块纹理的brickmodtex颜色
*/
public function setBrickmodtex($color)
{
if( is_object($color) )
{
if( $color->registerId != null ) $this->brickmodtex = $color->registerId;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->brickmodtex = $color;
}
/**
* @param object $color 接收一个贴图对象或小数形式的色值,设置砖块纹理的砖缝颜色
*/
public function setMortartex($color)
{
if( is_object($color) )
{
if( $color->registerId != null ) $this->mortartex = $color->registerId;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->mortartex = $color;
}
}
?>

71
src/scene/texture/procedural/Wireframe.php

@ -0,0 +1,71 @@
<?php
namespace Blobt\Luxcore\scene\texture\procedural;
use Blobt\Luxcore\scene\texture\TextureBase;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\texture\mapping\Mapping;
class Wireframe extends TextureBase
{
/**
* 线框的程序纹理
*/
const TYPE_WIREFRAME = 'wireframe';
/**
* @var string 线框颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $border = "0.7 0.7 0.7";
/**
* @var string 内部面颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
*/
public $inside = "0.2 0.2 0.2";
/**
* @param array $config 接收一个数组,可以初始化当前实例化对象的各种属性
*/
public function __construct($config = [])
{
$this->type = self::TYPE_WIREFRAME;
$this->id = Scene::createID();
Base::__construct($config);
}
/**
* @param object $color 接收一个贴图对象或小数形式的色值,设置线框纹理的线框颜色
*/
public function setBricktex($color)
{
if( is_object($color) )
{
if( $color->registerId != null ) $this->bricktex = $color->registerId;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->bricktex = $color;
}
/**
* @param object $color 接收一个贴图对象或小数形式的色值,设置线框纹理的内部面颜色
*/
public function setBrickmodtex($color)
{
if( is_object($color) )
{
if( $color->registerId != null ) $this->brickmodtex = $color->registerId;
else
{
throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
}
}
else $this->brickmodtex = $color;
}
}
?>
Loading…
Cancel
Save