Collision based on object mesh
by Tony Pitman · in Torque X 3D · 11/13/2009 (7:03 pm) · 5 replies
I need a tutorial on how to set up a collision object based on the mesh of the DTS object. I see in the documentation that there is a object called CollisionMeshShape.
I have in my xml the object based on a DTS model. It has a T3DRigidComponent. That component currently has a collision shape node with a CollisionSphereShape.
Is there a way to specify a CollisionMeshShape based on the DTS model itself? Can this be done in the XML or will I have to create it in code?
I have in my xml the object based on a DTS model. It has a T3DRigidComponent. That component currently has a collision shape node with a CollisionSphereShape.
Is there a way to specify a CollisionMeshShape based on the DTS model itself? Can this be done in the XML or will I have to create it in code?
#2
11/13/2009 (11:50 pm)
Bummer. Thanks for the answer.
#3
When using the T3DStaticTSRenderComponent make sure you have an empty RigidComponent that it can place it's Collision Shape into.
Look at _CreateCollisionMesh() in the T3DStaticGeometryComponent and
GetCollisionData() in T3DStaticTSRenderComponent for more information if you want to customize or create your own Collision Meshes.
11/14/2009 (11:57 pm)
Actually, if you use a T3DStaticTSRenderComponent it will create a polysoup collision object. When using the T3DStaticTSRenderComponent make sure you have an empty RigidComponent that it can place it's Collision Shape into.
Look at _CreateCollisionMesh() in the T3DStaticGeometryComponent and
GetCollisionData() in T3DStaticTSRenderComponent for more information if you want to customize or create your own Collision Meshes.
#4
I have a TorqueObject that is a DTS model loaded in my levelData xml file. It has a T3DSceneComponenent and a T3DTSRenderComponent on it. Those are in the xml. This object is a template so I can create copies of it in code to spawn my enemies.
In code I create a T3DRigidComponent and get it all created with the values I need.
I copied the code from the _CreateCollisionMesh method in T3DStaticGeometryComponent to my method that I create my spawned enemies.
When it gets to the point where the code wants to walk through the T3DSceneClients in the T3DSceneComponent.SceneClientList there aren't any clients in the list.
Any ideas how I get from here to where I need to be? Basically the code needs to get a list of vertices and triangles, but I am not sure where to get them from since the SceneClientList is empty.
11/15/2009 (2:39 am)
Ok, I am working through this and trying to figure out how to get from what I have to what I need.I have a TorqueObject that is a DTS model loaded in my levelData xml file. It has a T3DSceneComponenent and a T3DTSRenderComponent on it. Those are in the xml. This object is a template so I can create copies of it in code to spawn my enemies.
In code I create a T3DRigidComponent and get it all created with the values I need.
I copied the code from the _CreateCollisionMesh method in T3DStaticGeometryComponent to my method that I create my spawned enemies.
When it gets to the point where the code wants to walk through the T3DSceneClients in the T3DSceneComponent.SceneClientList there aren't any clients in the list.
Any ideas how I get from here to where I need to be? Basically the code needs to get a list of vertices and triangles, but I am not sure where to get them from since the SceneClientList is empty.
#5
If you really want to port it over to the DTSRenderComponent, you will need to grab the SceneComponent, as that is what the StaticGeometryComponent is based off of. i.e. try using Owner.Components.FindComponent<T3DRigidComponent>().sceneclientlist as opposed to just sceneclientlist.
11/15/2009 (2:27 pm)
As a note, if your enemies are animated, it's going to place the Collision meshes in Root Pose, and the RigidComponent will be unable to process the animated meshes.If you really want to port it over to the DTSRenderComponent, you will need to grab the SceneComponent, as that is what the StaticGeometryComponent is based off of. i.e. try using Owner.Components.FindComponent<T3DRigidComponent>().sceneclientlist as opposed to just sceneclientlist.
Torque Owner b2fxna