You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
4.7 KiB
175 lines
4.7 KiB
<?php
|
|
|
|
|
|
|
|
namespace Blobt\Luxcore\scene;
|
|
use GuzzleHttp\Client;
|
|
|
|
include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
|
|
|
|
const OPEN = true;
|
|
const CLOSE = false;
|
|
|
|
|
|
|
|
$client = new Client();
|
|
$response = $client->get("deep3d.backend-api.dev.com/test/render-task");
|
|
$resContents = $response->getBody()->getContents();
|
|
$resData = json_decode($resContents);
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个场景;
|
|
$scene = new Scene();
|
|
|
|
|
|
// 一、创建光场:
|
|
// 1、创建 面片光001
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('1 1 1');
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight001.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 2、创建 面片光002
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('0 0 0');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "30 30 30",
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight002.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 3、创建 面片光003
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('1 1 1');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "50 50 50",
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight003.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 4、创建 面片光004
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('0 0 0');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "4 4 4",
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight004.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 5、创建 面片光005
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('1 1 1');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "10 10 10",
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight005.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 6、创建 面片光006
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('1 1 1');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "8 8 8",
|
|
'mapfile' => "./map/SD-037.exr",
|
|
'gamma' => 1,
|
|
'storage' => "float"
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight006.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 7、创建 面片光000
|
|
$materials = new materials\Matte();
|
|
$materials->setBaseColor('0 0 0');
|
|
$materials->setTransparencyShadow('1 1 1');
|
|
$materials->setEmission('1 1 1');
|
|
$materials->emissionCfg = new lights\Emission([
|
|
'gain' => "3.3 3.3 3.3",
|
|
]);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/FaceLight000.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
// 8、创建环境光
|
|
$light = new lights\env\HdrImage([
|
|
'gain' => "1.25 1.25 1.25",
|
|
'transformation' => "0.1736481 -0.9848078 0 0 -0.9848078 -0.1736481 0 0 0 0 1 0 0 0 0 1",
|
|
'file' => "./map/env.png",
|
|
'gamma' => 1,
|
|
'storage' => "byte"
|
|
]);
|
|
$light->id = 0;
|
|
$scene->registerLight($light);
|
|
|
|
// 9、创建地面模型
|
|
$mapping = new texture\mapping\Mapping();
|
|
$mapping->useUVMapping2d(0, "0", "0.4 -0.966", "0.3 0.983");
|
|
$texture = new texture\procedural\ImageMap([
|
|
'file' => "./map/方形阴影遮照.png",
|
|
'gain' => 0.6,
|
|
'gamma' => 1,
|
|
]);
|
|
$texture->mapping = $mapping;
|
|
$scene->registerTexture($texture);
|
|
$materials = new materials\Disney([
|
|
'shadowcatcherEnable' => OPEN,
|
|
'photongiEnable' => CLOSE
|
|
]);
|
|
$materials->setBaseColor('1 1 1');
|
|
$materials->setTransparencyFront($texture);
|
|
$materials->setTransparencyBack($texture);
|
|
$scene->registerMaterial($materials);
|
|
$obj = new objects\Objects();
|
|
$obj->ply = './ply/ground.ply';
|
|
$obj->setMaterial($materials);
|
|
$scene->registerObjects($obj);
|
|
|
|
|
|
// 二、添加要渲染的模型
|
|
$loadModel = $resData->data->scene->model;
|
|
$loadCamera = $resData->data->scene->camera;
|
|
|
|
foreach($loadModel->childsParams as $childParams){
|
|
print_r($childParams);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|