Game Development Community

Q: Where can I get access to the actual mesh data that makes up

by Jarrod Roberson · in Torque Game Engine · 05/15/2002 (11:03 am) · 5 replies

I need to get access to the actual poly mesh and textures on that mesh that gets rendered as part of a ShapeBase object? I think it might be the TSShape class.

Please ring a bell if I am right!

If I get a buzzer, please point me in the right direction :)

#1
05/15/2002 (11:23 am)




Welcome to the mess that is TSShape! =) There is no simple answer to where the poly mesh is. It is in the TSShape class but have fun getting it out! The textures are referenced in TSMaterialList * materialList (a member of TSShape).
#2
05/15/2002 (1:43 pm)
Great now I am getting heckled!!!

Thanks for the encouraging words! :)

I guess I should know not to ask questions that I am not prepared for the answers to.

At least I am in the right direction, eh? This does seem to be pretty convoluted at first, but I am sure it makes sense at some point :) We do have the COMPLETE code so tracing thru it will reveal somethign to someone one maybe just not me :(

I found this Class called TSMesh? What does that do?

Basically I want to do two things. These are simple requirements I plan on more sophisticated implemenations, I am just trying to communicate the most basic end result I am looking to achieve.

1. I want to enable collision detection with the actual MODEL mesh if the bounding box gets hit.

2. I want to get the RGB and XY ( UV ) values of where on the actual MODEL mesh the hit is.

I just need some help finding the right place to look for the data?
#3
05/15/2002 (3:21 pm)
indeed you have found your way,
as the TSMesh is storing all data for the mesh,
as well it controls the rendering and most other processing done with the mesh..
so your are here look no further, it is time to study :)

Edit :
p.s. its a yucky public class, so you should have no trouble accessing your data :)
#4
05/15/2002 (4:09 pm)
Greetings!

Just chiming in here and agreeing with Badguy.

It is my understanding from the engine overview that all 3D objects (not terrain or interiors) use the TSShapeInstance class. This contains all of the TSMeshes that are used in the rendering of the object (which ones depends on the current detail level).

In fact, I'd take a look at TSShapeInstance::castRay() in tsCollision.cc as it steps through each of the meshes (using their own castRay() functions) to determine a hit. Perhaps you could insert yourself here or derive a new function to return the information you need. Then you could look up the primitive (based on ToolVector primitives; within TSMesh), find the vertices (based on ToolVector verts; in you know where), and finally obtain the texture coordinates for each vertex (based on ToolVector tverts;).

This is all theory, of course. You're question got me interested, so I thought I'd take a quick peek myself. My experience is more with getting the shapes into the engine, rather than manipulating them once there. Please let us know when you make any progress.

EDIT:
I just noticed that the commented out collision code for castRay() in TSMesh (the non-optimized version) shows how to obtain the material that is hit my the ray. This would then be returned in the RayInfo structure (or would be, if it wasn't commented out). So, you'd now have the material that was hit, and you'd just need to work on which vertices.

- LightWave Dave
#5
05/15/2002 (4:24 pm)
you guys ROCK!

Thanks for all the help!

Pixel accurate hit detection IS a possibility!