Jump to content

Recommended Posts

Posted

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?! :D

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

 

 

76561198023085627.png

Posted

Thanks i tested it with the GetEntityKey ,but it doesn't work :(

 

Here is the Code(converted to C++ from BlitzMax :D)

 

inline TBody GetMeshBody(TEntity mesh)
{
while(mesh != NULL)
{
	if(GetEntityKey(mesh,"class") == "Body" || GetEntityKey(mesh,"class") == "Model")
	{
		return TBody(mesh);
	}
	mesh = GetParent(mesh);
}

}

 

Thanks

Posted

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;
}

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...