Browse Source

函数名已经修改为驼峰方式,“Scene”类增加了生成ID的静态函数,模型、材质、灯光、相机、贴图类构造函数,增加了“Scene”类静态函数的调用

master
yuanjiajia 3 years ago
parent
commit
78bf8b24ac
  1. 8
      examples/print.php
  2. 51
      src/scene/Scene.php
  3. 8
      src/scene/camera/Camera.php
  4. 7
      src/scene/light/LigthBase.php
  5. 3
      src/scene/materials/Disney.php
  6. 2
      src/scene/materials/Glass.php
  7. 2
      src/scene/materials/Glossy.php
  8. 2
      src/scene/materials/Metal.php
  9. 2
      src/scene/materials/Mix.php
  10. 2
      src/scene/materials/NullMaterial.php
  11. 2
      src/scene/materials/Roughmatte.php
  12. 3
      src/scene/objects/Objects.php
  13. 7
      src/scene/texture/TextureBase.php
  14. 7
      src/scene/volumes/VolumesBase.php

8
examples/print.php

@ -86,19 +86,19 @@ $scene = new Scene();//创建一个场景,
$material1 = new materials\Disney(); //创建一个 Disney 材质
$material2 = new materials\Metal(); //创建一个 Metal 材质
$material1 = $scene->addmaterial($material1); //将材质存入材质数组,并获得其键名
$material2 = $scene->addmaterial($material2); //将材质存入材质数组,并获得其键名
$material1 = $scene->setMaterial($material1); //将材质存入材质数组,并获得其键名
$material2 = $scene->setMaterial($material2); //将材质存入材质数组,并获得其键名
$mix = new materials\Mix(); //创建 Mix 材质,
$mix->material1 = $material1; //为材质通道1 指定一个键名
$mix->material2 = $material2; //为材质通道2 指定一个键名
$mix->amount = 0.6; //指定混合系数为 0.6
$mix = $scene->addmaterial($mix); //将材质存入材质数组,并获得其键名
$mix = $scene->setMaterial($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->material = $mix; //为模型的材属性 指定一个键名
$scene->addobjects($obj); //将模型添加到场景中
$scene->setObjects($obj); //将模型添加到场景中
/*

51
src/scene/Scene.php

@ -35,30 +35,67 @@ class Scene extends BaseCfg
/**
* @var array 相机数组
*/
private $camera = [];
private $cameras = [];
public function addobjects($obj)
public static function createID()
{
static $num = 0;
$num++;
return $num;
}
public function setObjects($obj)
{
$temp = null;
$temp = sprintf("%014d",count($this->objects)+1);
$temp = sprintf("%014d",$obj->id);
$this->objects[$temp] = $obj;
}
public function setMaterial($material)
{
$temp = null;
$temp = $material->type.'_'.sprintf("%014d",$material->id);
$this->materials[$temp] = $material;
return $temp;
}
public function addmaterial($material)
public function setTexture($texture)
{
$temp = null;
$temp = $texture->type.'_'.sprintf("%014d",$texture->id);
$this->textures[$temp] = $texture;
return $temp;
}
public function setVolume($volume)
{
$temp = null;
$temp = $material->type.'_'.sprintf("%014d",count($this->materials)+1);
$this->materials[$temp] = $material;
$temp = $volume->type.'_'.sprintf("%014d",$volume->id);
$this->volumes[$temp] = $volume;
return $temp;
}
public function setLight($light)
{
$temp = null;
$temp = $light->type.'_'.sprintf("%014d",$light->id);
$this->lights[$temp] = $light;
return $temp;
}
public function setCamera($camera)
{
$temp = null;
$temp = $camera->type.'_'.sprintf("%014d",$camera->id);
$this->cameras[$temp] = $camera;
return $temp;
}
/*
public function addObject( object $object )
{

8
src/scene/camera/Camera.php

@ -2,11 +2,17 @@
namespace Blobt\Luxcore\scene\camera;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class Camera extends BaseCfg
{
public function __construct($config = [])
{
$this->id = Scene::createID();
Base::__construct($config);
}
}

7
src/scene/light/LigthBase.php

@ -2,11 +2,18 @@
namespace Blobt\Luxcore\scene\ligth;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class LightBase extends BaseCfg
{
public function __construct($config = [])
{
$this->id = Scene::createID();
Base::__construct($config);
}
}

3
src/scene/materials/Disney.php

@ -2,6 +2,8 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Disney extends MaterialsBase
{
@ -96,6 +98,7 @@ class Disney extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_DISNEY;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/Glass.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Glass extends MaterialsBase
{
@ -79,6 +80,7 @@ class Glass extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_GLASS;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/Glossy.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Glossy extends MaterialsBase
{
@ -67,6 +68,7 @@ class Glossy extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_GLOSSY;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/Metal.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Metal extends MaterialsBase
{
@ -42,6 +43,7 @@ class Metal extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_METAL;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/Mix.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Mix extends MaterialsBase
{
@ -30,6 +31,7 @@ class Mix extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_MIX;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/NullMaterial.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class NullMaterial extends MaterialsBase
{
@ -26,6 +27,7 @@ class NullMaterial extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_NULL;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

2
src/scene/materials/Roughmatte.php

@ -2,6 +2,7 @@
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\Scene;
class Roughmatte extends MaterialsBase
{
@ -36,6 +37,7 @@ class Roughmatte extends MaterialsBase
public function __construct($config = [])
{
$this->type = self::TYPE_ROUGHMATTE;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);

3
src/scene/objects/Objects.php

@ -3,6 +3,7 @@
namespace Blobt\Luxcore\scene\objects;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
class Objects extends BaseCfg
{
@ -34,7 +35,7 @@ class Objects extends BaseCfg
public function __construct($config = [])
{
$this->id = rand(0,1000000);
$this->id = Scene::createID();
Base::__construct($config);
}

7
src/scene/texture/TextureBase.php

@ -2,11 +2,18 @@
namespace Blobt\Luxcore\scene\texture;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class TextureBase extends BaseCfg
{
public function __construct($config = [])
{
$this->id = Scene::createID();
Base::__construct($config);
}
}

7
src/scene/volumes/VolumesBase.php

@ -2,11 +2,18 @@
namespace Blobt\Luxcore\scene\volumes;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class VolumesBase extends BaseCfg
{
public function __construct($config = [])
{
$this->id = Scene::createID();
Base::__construct($config);
}
}

Loading…
Cancel
Save