Load lights from files (dae, 3ds, b3d,...)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

Hello,

I'm new to Irrlicht and I'm working with version 1.8.

I've tried a lot of things and I can't successfully load lights from 3D files (including COLLADA).
I've performed some tests and I can see that lights are in fact loaded but their positions are always (0, 0, 0) (and they are correct in the dae file of course).

I use

Code: Select all

smgr->getSceneNodesFromType(ESNT_LIGHT, lightNodes);
to check the lights and they are loaded with dae file (not with 3ds or b3d), but not "fully".

I've seen some topics about that but they are quite old (2004, 2006) and I don't know if the problem is solved or not.

I work with Blender 2.62 and I'd like to be able to get objects from the blender file (even if I need to export objects in b3d and lights in dae).

Thanks for your help and sorry if this has been discussed in another topic.

K.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

I don't know right now about other formats, but collada should support this I think, so sound like we're missing something. Can you make a quick .dae test-file with 1-2 lights (you probably already know how to do that)? Always helps if we have a concrete test-case to check.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

Hi,

I'm not sure how to attach a file, so I copy the dae contents here (372 lines, tell me if I'm wrong):
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
  <asset>
    <contributor>
      <author>Blender User</author>
      <authoring_tool>Blender 2.62.0 r44136</authoring_tool>
    </contributor>
    <created>2013-03-14T20:55:49</created>
    <modified>2013-03-14T20:55:49</modified>
    <unit name="meter" meter="1"/>
    <up_axis>Z_UP</up_axis>
  </asset>
  <library_cameras/>
  <library_lights>
    <light id="Point_004-light" name="Point.004">
      <technique_common>
        <point>
          <color sid="color">5000 5000 5000</color>
          <constant_attenuation>1</constant_attenuation>
          <linear_attenuation>0</linear_attenuation>
          <quadratic_attenuation>10e-5</quadratic_attenuation>
        </point>
      </technique_common>
      <extra>
        <technique profile="blender">
          <adapt_thresh>0.000999987</adapt_thresh>
          <area_shape>0</area_shape>
          <area_size>1</area_size>
          <area_sizey>1</area_sizey>
          <area_sizez>1</area_sizez>
          <atm_distance_factor>1</atm_distance_factor>
          <atm_extinction_factor>1</atm_extinction_factor>
          <atm_turbidity>2</atm_turbidity>
          <att1>0</att1>
          <att2>1</att2>
          <backscattered_light>1</backscattered_light>
          <bias>1</bias>
          <blue>1</blue>
          <buffers>1</buffers>
          <bufflag>0</bufflag>
          <bufsize>512</bufsize>
          <buftype>2</buftype>
          <clipend>40</clipend>
          <clipsta>0.5</clipsta>
          <compressthresh>0.04999995</compressthresh>
          <dist sid="blender_dist">100</dist>
          <energy sid="blender_energy">5000</energy>
          <falloff_type>2</falloff_type>
          <filtertype>0</filtertype>
          <flag>0</flag>
          <gamma sid="blender_gamma">1</gamma>
          <green>1</green>
          <halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
          <horizon_brightness>1</horizon_brightness>
          <mode>1</mode>
          <ray_samp>1</ray_samp>
          <ray_samp_method>1</ray_samp_method>
          <ray_samp_type>0</ray_samp_type>
          <ray_sampy>1</ray_sampy>
          <ray_sampz>1</ray_sampz>
          <red>1</red>
          <samp>3</samp>
          <shadhalostep>0</shadhalostep>
          <shadow_b sid="blender_shadow_b">0</shadow_b>
          <shadow_g sid="blender_shadow_g">0</shadow_g>
          <shadow_r sid="blender_shadow_r">0</shadow_r>
          <shadspotsize>45</shadspotsize>
          <sky_colorspace>2</sky_colorspace>
          <sky_exposure>1</sky_exposure>
          <skyblendfac>1</skyblendfac>
          <skyblendtype>1</skyblendtype>
          <soft>3</soft>
          <spotblend>0.15</spotblend>
          <spotsize>45</spotsize>
          <spread>1</spread>
          <sun_brightness>1</sun_brightness>
          <sun_effect_type>0</sun_effect_type>
          <sun_intensity>1</sun_intensity>
          <sun_size>1</sun_size>
          <type>0</type>
        </technique>
      </extra>
    </light>
    <light id="Point_002-light" name="Point.002">
      <technique_common>
        <point>
          <color sid="color">5000 5000 5000</color>
          <constant_attenuation>1</constant_attenuation>
          <linear_attenuation>0</linear_attenuation>
          <quadratic_attenuation>10e-5</quadratic_attenuation>
        </point>
      </technique_common>
      <extra>
        <technique profile="blender">
          <adapt_thresh>0.000999987</adapt_thresh>
          <area_shape>0</area_shape>
          <area_size>1</area_size>
          <area_sizey>1</area_sizey>
          <area_sizez>1</area_sizez>
          <atm_distance_factor>1</atm_distance_factor>
          <atm_extinction_factor>1</atm_extinction_factor>
          <atm_turbidity>2</atm_turbidity>
          <att1>0</att1>
          <att2>1</att2>
          <backscattered_light>1</backscattered_light>
          <bias>1</bias>
          <blue>1</blue>
          <buffers>1</buffers>
          <bufflag>0</bufflag>
          <bufsize>512</bufsize>
          <buftype>2</buftype>
          <clipend>40</clipend>
          <clipsta>0.5</clipsta>
          <compressthresh>0.04999995</compressthresh>
          <dist sid="blender_dist">100</dist>
          <energy sid="blender_energy">5000</energy>
          <falloff_type>2</falloff_type>
          <filtertype>0</filtertype>
          <flag>0</flag>
          <gamma sid="blender_gamma">1</gamma>
          <green>1</green>
          <halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
          <horizon_brightness>1</horizon_brightness>
          <mode>1</mode>
          <ray_samp>1</ray_samp>
          <ray_samp_method>1</ray_samp_method>
          <ray_samp_type>0</ray_samp_type>
          <ray_sampy>1</ray_sampy>
          <ray_sampz>1</ray_sampz>
          <red>1</red>
          <samp>3</samp>
          <shadhalostep>0</shadhalostep>
          <shadow_b sid="blender_shadow_b">0</shadow_b>
          <shadow_g sid="blender_shadow_g">0</shadow_g>
          <shadow_r sid="blender_shadow_r">0</shadow_r>
          <shadspotsize>45</shadspotsize>
          <sky_colorspace>2</sky_colorspace>
          <sky_exposure>1</sky_exposure>
          <skyblendfac>1</skyblendfac>
          <skyblendtype>1</skyblendtype>
          <soft>3</soft>
          <spotblend>0.15</spotblend>
          <spotsize>45</spotsize>
          <spread>1</spread>
          <sun_brightness>1</sun_brightness>
          <sun_effect_type>0</sun_effect_type>
          <sun_intensity>1</sun_intensity>
          <sun_size>1</sun_size>
          <type>0</type>
        </technique>
      </extra>
    </light>
  </library_lights>
  <library_images/>
  <library_effects/>
  <library_materials/>
  <library_geometries/>
  <library_animations>
    <animation id="Armature_Bone_pose_matrix">
      <source id="Armature_Bone_pose_matrix-input">
        <float_array id="Armature_Bone_pose_matrix-input-array" count="3">0.08333331 4.166666 8.333333</float_array>
        <technique_common>
          <accessor source="#Armature_Bone_pose_matrix-input-array" count="3" stride="1">
            <param name="TIME" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Armature_Bone_pose_matrix-output">
        <float_array id="Armature_Bone_pose_matrix-output-array" count="48">1 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 1 -0.3910979 0 0 0 0 0 0.3910979 0 0 0.3910979 0 -0.1413308 0 0 0 1 1 0 -2.38419e-7 0 -2.38419e-7 0 -1 0 0 1 0 0 0 0 0 1</float_array>
        <technique_common>
          <accessor source="#Armature_Bone_pose_matrix-output-array" count="3" stride="16">
            <param name="TRANSFORM" type="float4x4"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Armature_Bone_pose_matrix-interpolation">
        <Name_array id="Armature_Bone_pose_matrix-interpolation-array" count="3">LINEAR LINEAR LINEAR</Name_array>
        <technique_common>
          <accessor source="#Armature_Bone_pose_matrix-interpolation-array" count="3" stride="1">
            <param name="INTERPOLATION" type="name"/>
          </accessor>
        </technique_common>
      </source>
      <sampler id="Armature_Bone_pose_matrix-sampler">
        <input semantic="INPUT" source="#Armature_Bone_pose_matrix-input"/>
        <input semantic="OUTPUT" source="#Armature_Bone_pose_matrix-output"/>
        <input semantic="INTERPOLATION" source="#Armature_Bone_pose_matrix-interpolation"/>
      </sampler>
      <channel source="#Armature_Bone_pose_matrix-sampler" target="Bone/transform"/>
    </animation>
    <animation id="Plane_location_X">
      <source id="Plane_location_X-input">
        <float_array id="Plane_location_X-input-array" count="2">0.08333331 0.8333333</float_array>
        <technique_common>
          <accessor source="#Plane_location_X-input-array" count="2" stride="1">
            <param name="TIME" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_X-output">
        <float_array id="Plane_location_X-output-array" count="2">0.1955668 0.1955668</float_array>
        <technique_common>
          <accessor source="#Plane_location_X-output-array" count="2" stride="1">
            <param name="X" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_X-interpolation">
        <Name_array id="Plane_location_X-interpolation-array" count="2">BEZIER BEZIER</Name_array>
        <technique_common>
          <accessor source="#Plane_location_X-interpolation-array" count="2" stride="1">
            <param name="INTERPOLATION" type="name"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_X-intangent">
        <float_array id="Plane_location_X-intangent-array" count="4">-0.2094753 0.1955668 0.5405247 0.1955668</float_array>
        <technique_common>
          <accessor source="#Plane_location_X-intangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_X-outtangent">
        <float_array id="Plane_location_X-outtangent-array" count="4">0.3761419 0.1955668 1.126142 0.1955668</float_array>
        <technique_common>
          <accessor source="#Plane_location_X-outtangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <sampler id="Plane_location_X-sampler">
        <input semantic="INPUT" source="#Plane_location_X-input"/>
        <input semantic="OUTPUT" source="#Plane_location_X-output"/>
        <input semantic="INTERPOLATION" source="#Plane_location_X-interpolation"/>
        <input semantic="IN_TANGENT" source="#Plane_location_X-intangent"/>
        <input semantic="OUT_TANGENT" source="#Plane_location_X-outtangent"/>
      </sampler>
      <channel source="#Plane_location_X-sampler" target="Plane/location.X"/>
    </animation>
    <animation id="Plane_location_Y">
      <source id="Plane_location_Y-input">
        <float_array id="Plane_location_Y-input-array" count="2">0.08333331 0.8333333</float_array>
        <technique_common>
          <accessor source="#Plane_location_Y-input-array" count="2" stride="1">
            <param name="TIME" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Y-output">
        <float_array id="Plane_location_Y-output-array" count="2">2.433264 2.433264</float_array>
        <technique_common>
          <accessor source="#Plane_location_Y-output-array" count="2" stride="1">
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Y-interpolation">
        <Name_array id="Plane_location_Y-interpolation-array" count="2">BEZIER BEZIER</Name_array>
        <technique_common>
          <accessor source="#Plane_location_Y-interpolation-array" count="2" stride="1">
            <param name="INTERPOLATION" type="name"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Y-intangent">
        <float_array id="Plane_location_Y-intangent-array" count="4">-0.2094753 2.433264 0.5405247 2.433264</float_array>
        <technique_common>
          <accessor source="#Plane_location_Y-intangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Y-outtangent">
        <float_array id="Plane_location_Y-outtangent-array" count="4">0.3761419 2.433264 1.126142 2.433264</float_array>
        <technique_common>
          <accessor source="#Plane_location_Y-outtangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <sampler id="Plane_location_Y-sampler">
        <input semantic="INPUT" source="#Plane_location_Y-input"/>
        <input semantic="OUTPUT" source="#Plane_location_Y-output"/>
        <input semantic="INTERPOLATION" source="#Plane_location_Y-interpolation"/>
        <input semantic="IN_TANGENT" source="#Plane_location_Y-intangent"/>
        <input semantic="OUT_TANGENT" source="#Plane_location_Y-outtangent"/>
      </sampler>
      <channel source="#Plane_location_Y-sampler" target="Plane/location.Y"/>
    </animation>
    <animation id="Plane_location_Z">
      <source id="Plane_location_Z-input">
        <float_array id="Plane_location_Z-input-array" count="2">0.08333331 0.8333333</float_array>
        <technique_common>
          <accessor source="#Plane_location_Z-input-array" count="2" stride="1">
            <param name="TIME" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Z-output">
        <float_array id="Plane_location_Z-output-array" count="2">-2.637029 2.582715</float_array>
        <technique_common>
          <accessor source="#Plane_location_Z-output-array" count="2" stride="1">
            <param name="Z" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Z-interpolation">
        <Name_array id="Plane_location_Z-interpolation-array" count="2">BEZIER BEZIER</Name_array>
        <technique_common>
          <accessor source="#Plane_location_Z-interpolation-array" count="2" stride="1">
            <param name="INTERPOLATION" type="name"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Z-intangent">
        <float_array id="Plane_location_Z-intangent-array" count="4">-0.1699584 -2.637029 0.5800417 2.582715</float_array>
        <technique_common>
          <accessor source="#Plane_location_Z-intangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <source id="Plane_location_Z-outtangent">
        <float_array id="Plane_location_Z-outtangent-array" count="4">0.336625 -2.637029 1.086625 2.582715</float_array>
        <technique_common>
          <accessor source="#Plane_location_Z-outtangent-array" count="2" stride="2">
            <param name="X" type="float"/>
            <param name="Y" type="float"/>
          </accessor>
        </technique_common>
      </source>
      <sampler id="Plane_location_Z-sampler">
        <input semantic="INPUT" source="#Plane_location_Z-input"/>
        <input semantic="OUTPUT" source="#Plane_location_Z-output"/>
        <input semantic="INTERPOLATION" source="#Plane_location_Z-interpolation"/>
        <input semantic="IN_TANGENT" source="#Plane_location_Z-intangent"/>
        <input semantic="OUT_TANGENT" source="#Plane_location_Z-outtangent"/>
      </sampler>
      <channel source="#Plane_location_Z-sampler" target="Plane/location.Z"/>
    </animation>
  </library_animations>
  <library_controllers/>
  <library_visual_scenes>
    <visual_scene id="Scene" name="Scene">
      <node id="Point_004" type="NODE">
        <translate sid="location">3.557724 -2.628502 1.049254</translate>
        <rotate sid="rotationZ">0 0 1 0</rotate>
        <rotate sid="rotationY">0 1 0 0</rotate>
        <rotate sid="rotationX">1 0 0 0</rotate>
        <scale sid="scale">1 1 1</scale>
        <instance_light url="#Point_004-light"/>
      </node>
      <node id="Point_002" type="NODE">
        <translate sid="location">-3.778859 3.369381 1.049254</translate>
        <rotate sid="rotationZ">0 0 1 0</rotate>
        <rotate sid="rotationY">0 1 0 0</rotate>
        <rotate sid="rotationX">1 0 0 0</rotate>
        <scale sid="scale">1 1 1</scale>
        <instance_light url="#Point_002-light"/>
      </node>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#Scene"/>
  </scene>
</COLLADA>
I export the file from Blender 2.62 (file -> export -> COLLADA (.dae)). It seems that there are a lot of other objects in the file that are not needed, but I choose to export "only selected" and only the 2 lights are selected in Blender.

Also, here is the (nearly) code I use to check the positions (that are confirmed while executing the program):

Code: Select all

 
IMesh* lightMesh = smgr->getMesh("light_test_2.dae");
IMeshSceneNode* lightNode = smgr->addMeshSceneNode(lightMesh);
 
core::array< scene::ISceneNode * > lightNodes;
 
smgr->getSceneNodesFromType(ESNT_LIGHT, lightNodes);
 
for (int i = 0; i < lightNodes.size(); i++)
{
    vector3df v;
    ILightSceneNode* light = static_cast<ILightSceneNode*>(lightNodes[i]);
    v = light->getPosition();
    // Check v at that moment
}
 

Thanks,
K.
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

While looking at the Irrlicht code and COLLADA file, I've notice that:

- Lights are children of kind of dummy nodes (Point_004-light is a child of Point_004).
- Those dummy nodes are children of a "Scene" node.
- This Scene node is a child of a top level node.

- The Absolute Position matrix of lights and their direct parents (dummy nodes) are reflecting what is in the dae file.
- The Absolute Position matrix of Scene and top level node are (I guess) identity (mostly 0 and some 1).
- The relative positions of all objets are 0 (lights, dummy nodes, scene and top level).

I don't know exactly how Irrlicht deals with absolute and relative positions, but as far as I understand it updates the absolute positions from the relative ones, not the relative from the absolute.

So, maybe, the issue here is related to the way the nodes relative positions are set in CColladaFileLoader.cpp.
I see (line 298/299) the transformation applied to the absolute matrix, but it is never applied to any relative position in a "non-dummy" node (ISceneNode I guess).
It might be done at lines 847+ (?), but this code is never reached while loading the dae file.

I don't understand all the loader code but if someone has any clue, maybe I could help to investigate this issue in the Irrlicht sources :)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

Sorry, I wanted to check it today, but run into several other problems while fixing another problem. So will take some more time until I get to this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

No problem, I think I've found a kind of work around until it can be managed by the loader:

I simply loop on lights after loadind them from the dae file and update their relative position from the AbsoluteTransformation matrix. It's not so clean, but not so bad and it seems to work.

Code: Select all

 
core::array< scene::ISceneNode * > lightNodes;
 
smgr->getSceneNodesFromType(ESNT_LIGHT, lightNodes);
 
for (int i = 0; i < lightNodes.size(); i++)
{
    ILightSceneNode* light = static_cast<ILightSceneNode*>(lightNodes[i]);
    light->setPosition(light->getAbsoluteTransformation().getTranslation());
    // Useless AFAIK
    light->updateAbsolutePosition();
}
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

The dummytransformationnodes are special as they allow setting directly a matrix (instead of position, rotation, scaling) and the relative values for that one are ignored. I remember I worked on that somewhat before 1.8 and the dummy-node couldn't be completely removed easily. Collada can set the transformation/rotation values also as a matrix and as it's not possible to unambigiously get rotation and scaling from a matrix we can only use the full matrix transformation then. And we have not distinguished the case of when collada sets the transformations as separate rotation/translation/scaling and when it sets it as matrix but we just always create a matrix.

But then again that should work. Lights should have a relative position of 0,0,0 but the absolute position should then be correct because of the dummytransformation nodes. So if you set the position again then it will be added twice.

The additional node is certainly not that nice, I guess with some work we could remove it in some cases.

If the light works when you set the relative position despite the dummytransformationnode and not otherwise then I suspect that there's something strange in the lights instead. What exactly is happening with your lights - how did you figure out they are wrong?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

About absolute positions, I guess lights are relative to their parents, that's why the lights positions are 0,0,0.

But at a given level the parents (of parent...) should also have relative positions, don't they ?

I have light relative 0,0,0 to a parent (dummy) node, relative 0,0,0 to scene node, relative 0,0,0 to the top level node, relative 0,0,0 to ?
Nothing is never set at a relative position of something.

The absolute position are correct for light and dummy node, but scene node has no relative position and no absolute position. So at that stage, position seems to be "lost".

Moreover, when I use node->setPosition(), it will update its relative position, even if it does not have any parent, so that it is at the correct position. The absolute position will then be updated according to its relative position. I don't really get it :)

I figured out the problem because lights are all at 0,0,0 in my scene if I don't change manually their positions, even if the absolute positions are initially correct.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

That's the behaviour of DummyTransformationSceneNode's - they have have indeed only a relative transformation matrix - no relative position/scaling/rotation at all. They are a hack to allow using a transformation matrix instead of position/rotation/scaling. So they are different than other nodes - all other nodes just re-calculate the relative transformation matrix each time getRelativeTransformation() is called. While the DummyTransformationSceneNode really uses the matrix directly and ignores the other values.

It's admittably confusing, but I guess it was the only way we could add real matrix-transformation into Irrlicht without breaking the interface completely at some point.

But as long as the absolute positions are correct it should still work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by hybrid »

Though we now also have the matrix functions to get back the separate values, hence we could also add the original interface back to the dummy nodes. In case it would help (I have a bug filed about this behavior on the tracker)
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

I think I understand my problem:

I thought the lights were all at 0,0,0 but in fact they are not.

They seem to be because I use setScale() on the Scene mesh (my terrain) and on the light "mesh" (dae file only contains lights). But it does not seem to extend lights positions like it does for the scene mesh. Then lights look like they are all at the same point, but I activated shadows to ensure that, and I can see a slight difference in lights positions (shadows are not exactly overlapping).

So now, I can confirm that positionning is working but it seems that scaling does not work as I expect it to do.
Am i missing something about scaling ? Is it suppose to work like I do it ?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

Your so called light mesh - do you mean you have a single parent and scale that? You could check with getAbsolutePosition() on the lights if they change position by that (I guess they should).

edit: I think the light radius will not be scaled if that's what is missing.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

When I export lights from Blender, I select only them and check "Export only selected" in the COLLADA exporter window, so I don't know why exactly I don't have only lights in the dae file.

In the program I do:

Code: Select all

 
IMesh* lightMesh = smgr->getMesh("../irrlicht-1.8/media/light_test.dae");
IMeshSceneNode* lightNode = smgr->addMeshSceneNode(lightMesh);
[b]lightNode->setScale(vector3df( 10.0, 10.0, 10.0));[/b]
 
But it does not seem to have any effect, the position matrices are the same with or without the setScale().

If I multiply the positions by 10 (for each light), I get what I expect:

Code: Select all

 
light->setPosition(light->getAbsoluteTransformation().getTranslation() * vector3df( 10.0, 10.0, 10.0));
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Load lights from files (dae, 3ds, b3d,...)

Post by CuteAlien »

Ah right, I forgot about all that stuff *sigh*. Sorry, don't know a good workaround for this right now - maybe makes Collada unsuited for the task. The problem is that the collada-loader was written as a meshloader and at some point it got extended to load complete scenes when someone sets it to that with: sceneManager->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);

But the problem is that it still returns a mesh - which doesn't even make sense in this case (it's just an empty dummy-mesh). And there is no way to set a parent for that scene, so it's just added to the root of the scenemanager. Solution would maybe be a sceneloader interface instead (and maybe the colladaloader then has to derive from both interfaces). Or at least some way to set a parent node (that would be easier to code, but a similar ugly hack as the COLLADA_CREATE_SCENE_INSTANCES attribute). Sorry - this means I have no good solution at the moment. Maybe creating an extra scenemanager (ISceneManager:: createNewSceneManager) and use that for loading - then you would know the root and could scale that root-node and then copy stuff over to the original scenemanager. I know it sounds horrible, but that might work as a workaround.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: Load lights from files (dae, 3ds, b3d,...)

Post by Kiristu »

In fact, as soon as I know exactly what I'm doing, reposionning the lights according to the scale factor is not so bad for me.

The next question, maybe off-topic, is about the reason I use COLLADA ...

I want to be able to create every objects of my application outside of the program. Since I'm using Blender for other purposes, I'd like to be able to do all my 3D design in there, and then find a way to export everything from Blender to Irrlicht. That's why I have b3d for animated meshes, but b3d does not support lights, so I select only lights and export in dae ...

But now, I'm realizing that b3d export from Blender does not (seems?) to manage advanced materials (bumps etc...), so maybe I'm just wrong using COLLADA too. Is there some best practices for working from Blender to Irrlicht ? I've searched about that but I only find old stuff or partial exporting solutions.

Again this might not be the correct topic, so please tell me :)

Thanks for your help
Post Reply