horde3d / Horde3D

Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.
http://horde3d.org/
1.55k stars 308 forks source link

Help - getting individual item info from a editor created scene #222

Closed gwald closed 11 months ago

gwald commented 11 months ago

Hello again, Happy holidays :)

I'm trying to get individual items from a scene created by the editor. I can load the scene, but I want to move the individual parts in the scene.


        modelRes = h3dAddResource( H3D_ResTypes_SceneGraph, filename, 0 );

        if(modelRes == 0)//failed
        {
            printf("Failed Model: <%s>\n",filename );
            return 1;
        }
h3dutLoadResourcesFromDisk( "." );
    // Add model to scene
    g_model = h3dAddNodes( H3DRootNode, modelRes );

        printf("1 h3dGetResElemCount %d\n", h3dGetResElemCount(modelRes, H3D_ResTypes_SceneGraph    ) );

But it looks like there's nothing there?


int Resource::getElemCount( int elem ) const
{
    H3D_UNUSED_VAR(elem);
    Modules::setError( "Invalid elem in h3dGetResElemCount" );
    return 0;
}

Is it not possible to get nodes from an editor scene?

gwald commented 11 months ago

I noticed in the editor it uses h3dGetNextResource


                int i = 0;
        while( ( i = h3dGetNextResource( H3D_ResTypes_Undefined, i ) ) != 0 )
        {
            printf("h3dGetResName( %d ) %s\n", i, h3dGetResName( i )  );
        }

That gives out a nice list of everything in the scene file:

h3dGetResName( 1 ) $Tex2D
h3dGetResName( 2 ) $TexCube
h3dGetResName( 3 ) $Tex3D
h3dGetResName( 4 ) pipelines/forward.pipeline.xml
h3dGetResName( 5 ) models/NewScene1.scene.xml
h3dGetResName( 6 ) animations\models/NewScene1.scene.xml\models/NewScene1.scene.xml.anim
h3dGetResName( 7 ) pipelines/globalSettings.material.xml
h3dGetResName( 8 ) models/b.scene.xml
h3dGetResName( 9 ) models/g.scene.xml
h3dGetResName( 10 ) models/r.scene.xml
h3dGetResName( 11 ) models/t1.scene.xml
h3dGetResName( 12 ) models/t2.scene.xml
h3dGetResName( 13 ) models/t3.scene.xml
h3dGetResName( 14 ) models/room.scene.xml
h3dGetResName( 15 ) textures/ambientMap.dds
h3dGetResName( 16 ) models/b.geo
h3dGetResName( 17 ) models/b_blue.material.xml
h3dGetResName( 18 ) models/g.geo
h3dGetResName( 19 ) models/g_green.material.xml
h3dGetResName( 20 ) models/r.geo
h3dGetResName( 21 ) models/r_red.material.xml
h3dGetResName( 22 ) models/t1.geo
h3dGetResName( 23 ) models/t1_text1.material.xml
h3dGetResName( 24 ) models/t2.geo
h3dGetResName( 25 ) models/t2_text2.material.xml
h3dGetResName( 26 ) models/t3.geo
h3dGetResName( 27 ) models/t3_text3.material.xml
h3dGetResName( 28 ) models/room.geo
h3dGetResName( 29 ) models/room_green.material.xml
h3dGetResName( 30 ) models/room_red.material.xml
h3dGetResName( 31 ) models/room_blue-lit.material.xml
h3dGetResName( 32 ) shaders/model.shader
h3dGetResName( 33 ) models/t10.bmp
h3dGetResName( 34 ) models/t21.bmp
h3dGetResName( 35 ) models/t32.bmp
h3dGetResName( 36 ) textures/common/white.tga
h3dGetResName( 37 ) textures/common/defnorm.tga
h3dGetResName( 38 ) shaders/utilityLib/vertCommon.glsl
h3dGetResName( 39 ) shaders/utilityLib/vertSkinning.glsl
h3dGetResName( 40 ) shaders/utilityLib/fragDeferredWrite.glsl
h3dGetResName( 41 ) shaders/utilityLib/fragLighting.glsl

Using the model's scene files ie models/t1.scene.xml, the ResHandle is 11.

The whole sense ( models/NewScene1.scene.xml reshandle: 5) or individual parts can be use in the scene by using

node = h3dAddNodes( H3DRootNode, reshandleNum );