ParaToxic Posted November 8, 2011 Share Posted November 8, 2011 Hey i would ask you how can i get the body of an entity(a picked entity) in C++. Thanks Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 8, 2011 Share Posted November 8, 2011 well you should be able to get the body/model of a picked mesh by finding the parent of that mesh... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
LordHippo Posted November 8, 2011 Share Posted November 8, 2011 well you should be able to get the body/model of a picked mesh by finding the parent of that mesh... So how do you get the body of a model?! Quote Ali Salehi | Programmer Intel Core i3 2100 @ 3.0GHz | GeForce GTS 450 | 4GB DDR3 RAM | Windows 7 Ultimate x64 LE 2.50 | Visual Studio 2010 | RenderMonkey 1.82 | gDEBugger 5.8 | FX Composer 2.5 | UU3D 3 | xNormal 3.17 Link to comment Share on other sites More sharing options...
macklebee Posted November 8, 2011 Share Posted November 8, 2011 a model is nothing more than a container for the body and the child mesh and possibly an included script... but look at these links for examples: Entity Pick and Entity/Body conversion problem Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
ParaToxic Posted November 9, 2011 Author Share Posted November 9, 2011 Thanks i tested it with the GetEntityKey ,but it doesn't work Here is the Code(converted to C++ from BlitzMax ) inline TBody GetMeshBody(TEntity mesh) { while(mesh != NULL) { if(GetEntityKey(mesh,"class") == "Body" || GetEntityKey(mesh,"class") == "Model") { return TBody(mesh); } mesh = GetParent(mesh); } } Thanks Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 9, 2011 Share Posted November 9, 2011 yeah i cannot speak for c++... but in any case, a 5 minute search for GetMeshModel led me to find it in two places for c++. One is gamelib and the other is Chris Paulson's code that he submitted in the download section... Here is Chris' usage as found here http://www.leadwerks.com/werkspace/topic/1162-why-a-bullet-object/page__view__findpost__p__10810: void Bullet::builtHitForce( TPick& pick ) { TBody body; body = GetMeshModel( pick.entity ); if(body) { AddBodyForceAtPoint( body, Vec3(m_direction.X * m_force, m_direction.Y*m_force, m_direction.Z*m_force), Vec3(pick.X,pick.Y,pick.Z) ); // SendEntityMessage( topParent(pick.entity), "bullethit", body, 0 ); TEntity e = pick.entity; BulletHit *hit = new BulletHit; hit->m_direction = m_direction; hit->m_force = m_force; hit->m_origin = m_origin; hit->m_speed = m_speed; hit->m_pick = pick; while (e) { SendEntityMessage( e, "bullethit", (byte*)hit, 0 ); e = GetParent(e); } } } and here is his GetMeshModel code: TBody GetMeshModel(TEntity entity) { std::string classname; while (entity!=0) { classname=GetEntityKey(entity,"class"); if (classname=="Model") { return entity; } entity=GetParent(entity); } return 0; } Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
ParaToxic Posted November 10, 2011 Author Share Posted November 10, 2011 Thanks so much ;D Quote 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.