shadmar Posted April 9, 2012 Share Posted April 9, 2012 Hi I found out that LoadScene doesn't fetch lights automagic for me and the old tutorial uses a ProcessScene which doesn't seem to apply anymore. So if my C++ snip goes like this, how do I get the scene lights (without manually creating them and positioning them), Any tip would be appreciated, thanks. //Create a world world=CreateWorld(); if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); goto exitapp; } //Create render buffers TBuffer gbuffer=CreateBuffer(ScreenWidth,ScreenHeight,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TBuffer lightbuffer=CreateBuffer(ScreenWidth,ScreenHeight,BUFFER_COLOR|BUFFER_DEPTH); //Create a camera cam=CreateCamera(); CreateListener(cam); //Load the scene TEntity scene=LoadScene("C:/Leadwerks Engine SDK/Maps/tunnels.sbx"); //how do I fetch lights from this scene ? // // Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 9, 2012 Share Posted April 9, 2012 I do it like this: //Light for (int k = 1; k <= LE.CountChildren(scene); k++) { // Get the class of the entity String tempEntity = LE.GetEntityKey(LE.GetChild(scene, k), "class", ""); if (tempEntity == "Light") //do stuff Quote Link to comment Share on other sites More sharing options...
shadmar Posted April 10, 2012 Author Share Posted April 10, 2012 Thanks Aggror. I only get Model and Terrain classes returned, no light when I test using that code. I used AppLog(tempEntity) Just to print out all classes returned from the sbx. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Roland Posted April 10, 2012 Share Posted April 10, 2012 Here is a part from my scene-loader class that shows how to parse lights. void Scene::Load( const Char* pstrSBX ) { TEntity root = LoadScene( pstrSBX ); _parse( root ); } TEntity Scene::_parse( TEntity e ) { if( e == nullptr ) return nullptr ; std::string cls = GetEntityKey(e, "class"); if( cls == "Directionallight" ) _onDirectionalLight(e); else if( cls == "Mesh" ) _onMesh(e); int numChilds = CountChildren( e ); for( int ii = 0; ii < numChilds; ++ii ) _parse( GetChild(e, ii+1 ) ); return nullptr; } void Scene::_onDirectionalLight( TLight e ) { // handle light here } void Scene::_onMesh( TMesh e ) { // handle mesh here } Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
shadmar Posted April 10, 2012 Author Share Posted April 10, 2012 Thanks, however they all show up as "Model" when using GetEntityKey and class on the tunnel.sbx scene Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model Model .... But by using "name" instead of class I can distinguish them : spot_1 straight_1 fancage_1 fanblades_2 atmosphere_1 fancage_1 fanblades_2 straight_1 t_1 straight_3 switch_1 t_2 t_3 emitter_2 doorway_1 cagelight_2 cagelight_5 node_1 node_3 ambient_3 node_1 node_1 straight_3 straight_3 .... Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Roland Posted April 10, 2012 Share Posted April 10, 2012 Using the keyword class do work. You must have done something wrong. Here is the output from the code snippet I showed when the tunnel.sbx is loaded class=Pivot, name= class=Model, name=spot_1 class=Mesh, name= class=Spotlight, name= class=Model, name=straight_1 class=Mesh, name=U3D_MESH class=Model, name=fancage_1 class=Mesh, name=U3D_MESH class=Model, name=fanblades_2 class=Mesh, name=U3D_MESH class=Model, name=atmosphere_1 class=Mesh, name= class=Model, name=fancage_1 class=Mesh, name=U3D_MESH class=Model, name=fanblades_2 class=Mesh, name=U3D_MESH class=Model, name=straight_1 class=Mesh, name=U3D_MESH class=Model, name=t_1 class=Mesh, name=U3D_MESH class=Model, name=straight_3 class=Mesh, name=U3D_MESH class=Model, name=switch_1 class=Mesh, name= class=Model, name=t_2 class=Mesh, name=U3D_MESH class=Model, name=t_3 class=Mesh, name=U3D_MESH class=Model, name=emitter_2 class=Mesh, name= class=Model, name=doorway_1 class=Mesh, name=U3D_MESH class=Model, name=cagelight_2 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=cagelight_4 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=cagelight_5 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=node_1 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=ambient_3 class=Mesh, name= class=Model, name=node_1 class=Mesh, name= class=Model, name=node_1 class=Mesh, name= class=Model, name=straight_3 class=Mesh, name=U3D_MESH class=Model, name=straight_3 class=Mesh, name=U3D_MESH class=Model, name=metal01_1 class=Mesh, name=U3D_MESH class=Model, name=metal01_1 class=Mesh, name=U3D_MESH class=Model, name=doorway_1 class=Mesh, name=U3D_MESH class=Model, name=t_10 class=Mesh, name=U3D_MESH class=Model, name=cagelight_15 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=hanginglight_2 class=Mesh, name=U3D_MESH class=Spotlight, name= class=Model, name=hanginglight_2 class=Mesh, name=U3D_MESH class=Spotlight, name= class=Model, name=cagelight_14 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=room01_1 class=Mesh, name=U3D_MESH class=Model, name=cagelight_21 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=locker_48 class=Mesh, name=STATIC_MESH class=Mesh, name=01 class=Mesh, name=doorhinge class=Model, name=room02_1 class=Mesh, name=U3D_MESH class=Model, name=hanginglight_46 class=Mesh, name=U3D_MESH class=Spotlight, name= class=Model, name=hanginglight_47 class=Mesh, name=U3D_MESH class=Spotlight, name= class=Model, name=cagelight_56 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=metal01_1 class=Mesh, name=U3D_MESH class=Model, name=metal01_1 class=Mesh, name=U3D_MESH class=Model, name=cagelight_29 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=cagelight_38 class=Mesh, name=STATIC_MESH class=Mesh, name=bulb class=Mesh, name=cage class=Pointlight, name= class=Model, name=node_1 class=Mesh, name= class=Model, name=node_2 class=Mesh, name= class=Model, name=node_3 class=Mesh, name= class=Model, name=node_4 class=Mesh, name= class=Model, name=doorway_3 class=Mesh, name=U3D_MESH class=Model, name=metal01_5 class=Mesh, name=U3D_MESH class=Model, name=metal01_6 class=Mesh, name=U3D_MESH To get the print out I just added some print code like this TEntity Scene::_parse( TEntity e ) { if( e == nullptr ) return nullptr ; // --- print std::ostringstream os ; for( int tab=0; tab < _tab; ++tab ) os << " "; std::string cls = GetEntityKey(e, "class"); std::string name = GetEntityKey(e,"name"); os << "class=" << cls << ", name=" << name ; AppLog( os.str().c_str()); _tab++; // --- std::string cls = GetEntityKey(e, "class"); if( cls == "Directionallight" ) _onDirectionalLight(e); else if( cls == "Mesh" ) _onMesh(e); int numChilds = CountChildren( e ); for( int ii = 0; ii < numChilds; ++ii ) _parse( GetChild(e, ii+1 ) ); _tab--; return nullptr; } Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
shadmar Posted April 10, 2012 Author Share Posted April 10, 2012 Haha, thanks alot. I just fetched the top most one (hence all the models), I get it now, thanks for the tutorial on entities 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.