2015-09-28 05:19:31 +00:00
|
|
|
#ifndef _DNACOMMON_BABEDEAD_HPP_
|
|
|
|
#define _DNACOMMON_BABEDEAD_HPP_
|
|
|
|
|
|
|
|
#include <BlenderConnection.hpp>
|
|
|
|
|
2015-10-12 04:41:28 +00:00
|
|
|
#ifndef _USE_MATH_DEFINES
|
|
|
|
#define _USE_MATH_DEFINES 1
|
|
|
|
#endif
|
|
|
|
#include <math.h>
|
|
|
|
|
2015-09-28 05:19:31 +00:00
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
|
|
|
|
template<class BabeDeadLight>
|
|
|
|
void ReadBabeDeadLightToBlender(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
const BabeDeadLight& light, unsigned s, unsigned l)
|
|
|
|
{
|
|
|
|
switch (light.lightType)
|
|
|
|
{
|
|
|
|
case BabeDeadLight::LightLocalAmbient:
|
2015-09-28 06:16:41 +00:00
|
|
|
case BabeDeadLight::LightLocalAmbient2:
|
2015-09-28 05:19:31 +00:00
|
|
|
os.format("bg_node.inputs[0].default_value = (%f,%f,%f,1.0)\n"
|
|
|
|
"bg_node.inputs[1].default_value = %f\n",
|
|
|
|
light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
|
|
|
light.q / 8.0);
|
|
|
|
return;
|
|
|
|
case BabeDeadLight::LightDirectional:
|
|
|
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SUN')\n"
|
|
|
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
|
|
|
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
|
|
|
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
|
|
|
"\n", s, l,
|
|
|
|
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2]);
|
|
|
|
break;
|
|
|
|
case BabeDeadLight::LightCustom:
|
|
|
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'POINT')\n"
|
|
|
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
|
|
|
"\n", s, l);
|
|
|
|
break;
|
|
|
|
case BabeDeadLight::LightSpot:
|
2015-09-28 06:16:41 +00:00
|
|
|
case BabeDeadLight::LightSpot2:
|
2015-09-28 05:19:31 +00:00
|
|
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SPOT')\n"
|
|
|
|
"lamp.spot_size = %f\n"
|
|
|
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
|
|
|
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
|
|
|
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
|
|
|
"\n", s, l,
|
|
|
|
light.spotCutoff * M_PI / 180.f,
|
|
|
|
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2]);
|
|
|
|
break;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os.format("lamp.retro_layer = %u\n"
|
2015-09-28 06:16:41 +00:00
|
|
|
"lamp.retro_origtype = %u\n"
|
2015-09-28 05:19:31 +00:00
|
|
|
"lamp.use_nodes = True\n"
|
|
|
|
"falloff_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n"
|
|
|
|
"lamp.energy = 0.0\n"
|
|
|
|
"falloff_node.inputs[0].default_value = %f\n"
|
|
|
|
"hue_sat_node = lamp.node_tree.nodes.new('ShaderNodeHueSaturation')\n"
|
|
|
|
"hue_sat_node.inputs[1].default_value = 1.25\n"
|
|
|
|
"hue_sat_node.inputs[4].default_value = (%f,%f,%f,1.0)\n"
|
|
|
|
"lamp.node_tree.links.new(hue_sat_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[0])\n"
|
|
|
|
"lamp_obj.location = (%f,%f,%f)\n"
|
|
|
|
"bpy.context.scene.objects.link(lamp_obj)\n"
|
2015-09-28 06:16:41 +00:00
|
|
|
"\n", s, light.lightType, light.q / 8.0,
|
2015-09-28 05:19:31 +00:00
|
|
|
light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
|
|
|
light.position.vec[0], light.position.vec[1], light.position.vec[2]);
|
|
|
|
|
|
|
|
switch (light.falloff)
|
|
|
|
{
|
|
|
|
case BabeDeadLight::FalloffConstant:
|
|
|
|
os << "falloff_node.inputs[0].default_value *= 75.0\n"
|
|
|
|
"lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n";
|
|
|
|
break;
|
|
|
|
case BabeDeadLight::FalloffLinear:
|
|
|
|
os << "lamp.node_tree.links.new(falloff_node.outputs[1], lamp.node_tree.nodes['Emission'].inputs[1])\n";
|
|
|
|
break;
|
|
|
|
case BabeDeadLight::FalloffQuadratic:
|
|
|
|
os << "lamp.node_tree.links.new(falloff_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[1])\n";
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _DNACOMMON_BABEDEAD_HPP_
|