Jump to content

HierarchyWorldBoundBox and light in .node


photo

Recommended Posts

Hello,
I have a .node file that contains one mesh and one lightomni.

When I use the hierarchyWorldBoundBox, the size of the returned bounding box is the <shadow_distance>100</shadow_distance> of the lightomni ??
It's a bug or maybe I made something wrong ?

I use Unigine 2.12.0.2.
Thanks

Link to comment

Hi Silent,
 

<?xml version="1.0" encoding="utf-8"?>
<nodes version="2.10.0.0">
    <node type="ObjectMeshStatic" id="1679715438" name="apc/Light Fixtures/Indoor Luminaires/Bulbs/Modern Bulbs/E27 Screw Base/Bulb 500 Lumens 001">
        <mesh_name>core/meshes/15905575051590557505.mesh</mesh_name>
        <surface name="screwcap_default9" material="684fc1172aa9eb8a1b62e5616e523f4cca40723b"/>
        <surface name="bulb_default8" material="2b45f3a7195fdcda4996067160a74d1c556305cb"/>
        <surface name="bottomceramic_default4" material="81219d488bd6a0077ac6ddba5c0a51d102f760fc"/>
        <transform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</transform>

        <node type="LightOmni" id="1733911815" name="LightOmni">
            <attenuation_distance>60</attenuation_distance>
            <shape>0.01 0.01 0.01</shape>
            <shape_type>1</shape_type>
            <color_mode>1</color_mode>
            <intensity>10</intensity>
            <color_filter>0.04 0.04 0.025 0.2</color_filter>
            <shadow_bias>1</shadow_bias>
            <shadow_distance>100</shadow_distance>
            <fade_distance>10</fade_distance>
            <mode>0</mode>
            <shadow_mode>0</shadow_mode>
            <shadow_filter_mode>0</shadow_filter_mode>
            <shadow_filter>1</shadow_filter>
            <shadow_penumbra_mode>-1</shadow_penumbra_mode>
            <shadow_penumbra>0</shadow_penumbra>
            <lens_flare_enabled>0</lens_flare_enabled>
            <transform>1 0 0 0.0 0 1 0 0.0 0 0 1 0.0 0 0 0.12 1.0</transform>
        </node>
    </node>
</nodes>

I want only the boundingBox of the mesh not the light but when I write sceneNode->getHierarchyWorldBoundBox that return the size of shadow distance.
Thanks

Link to comment

Hi!
hierarchyWorldBoundBox works as expected.
most likely you need something like this:

void getMeshBoundBox(const NodePtr & node, WorldBoundBox &bb)
{
	if (!node) return;

	int type = node->getType();
	if (type == Node::NODE_REFERENCE)
		getMeshBoundBox(static_ptr_cast<NodeReference>(node)->getReference(), bb);
	else if (type == Node::OBJECT_MESH_STATIC || type == Node::OBJECT_MESH_SKINNED || type == Node::OBJECT_MESH_DYNAMIC)
		bb.expand(node->getWorldBoundBox());

	for (int i = 0 ; i < node->getNumChildren(); i++)
		getMeshBoundBox(node->getChild(i), bb);
}


// and call it

	WorldBoundBox bound;
	getMeshBoundBox(node, bound);
	bound.getCenter()//...

 

Link to comment

Hi,
I know this is possible to get the bound box in this manner.
But I don't understand why the light return a bounding box because there is no vertexs in the light can you explain this choice ?
Thanks.

Link to comment
×
×
  • Create New...