Q: Location Specific Hit Detection
by Jarrod Roberson · in Torque Game Engine · 05/14/2002 (12:19 pm) · 2 replies
Ok I am making mad progress on a dynamic player class where everything about the player is based on attributes, and uses the datablock only as a base reference to modify. Thanks to Daniel Neilsen for posting his tutorial, it confirmed I was on the right track and was a great kickstart to make the modifications I need to make. I plan on making lots of what I code available to the public.
One thing I am looking at now is location hit detection.
I want something more sophisticated than head/torso/arm/leg hit detection.
The idea I have is to paint a hit location bitmap based on the UV texture map, probably just make it index color, that would give me 256 possible locations.
Then use a greyscale bitmap to map armor protected areas. This would give me 256 discreet values to map protective values to. 0% ( black ) to 100% ( white ).
My plan is to rayCast from where the hitbox is hit to the model to get the texture coordinates if possible. Is this information available? If so which struct/class?
Where would I start looking in the C++ code to get the x,y coordinates of the UV Texture map of where a ShapeBase object was hit by a projectile?
If I can get those values the possibilites would be pretty endless, especially if the armor bitmap could be updated to reflect damage it had taken, thus dynamiclly "removing" the armor.
You could have lots of death animations based on hit locations just like in the light gun games like TimeCrisis where they grab the general location that you hit them, or they spin and fall differently base on where you hit them.
Of course the mapping of values to colors would be scriptable thru a datablock!
any suggestions on where to start in the C++ code?
source file name / function names / class names / operation names / etc would be greatly appreciated
One thing I am looking at now is location hit detection.
I want something more sophisticated than head/torso/arm/leg hit detection.
The idea I have is to paint a hit location bitmap based on the UV texture map, probably just make it index color, that would give me 256 possible locations.
Then use a greyscale bitmap to map armor protected areas. This would give me 256 discreet values to map protective values to. 0% ( black ) to 100% ( white ).
My plan is to rayCast from where the hitbox is hit to the model to get the texture coordinates if possible. Is this information available? If so which struct/class?
Where would I start looking in the C++ code to get the x,y coordinates of the UV Texture map of where a ShapeBase object was hit by a projectile?
If I can get those values the possibilites would be pretty endless, especially if the armor bitmap could be updated to reflect damage it had taken, thus dynamiclly "removing" the armor.
You could have lots of death animations based on hit locations just like in the light gun games like TimeCrisis where they grab the general location that you hit them, or they spin and fall differently base on where you hit them.
Of course the mapping of values to colors would be scriptable thru a datablock!
any suggestions on where to start in the C++ code?
source file name / function names / class names / operation names / etc would be greatly appreciated
About the author
#2
I am an old school board gamer. I like lots of stats. I like more information than I need gives you options. It is easier to remove un-needed data and complexity than add it latter.
I am not so much concerned with whether something is feasible or appropriate at this time. I am more concerned about figuring out where to start looking to edit/add code to see if it is feasible.
So does anyone know where I should start looking?
What does the
void getDamageLocation(const Point3F& in_rPos, const char *&out_rpVert, const char *&out_rpQuad);
in player.cc do?
05/14/2002 (8:09 pm)
well it is detailed because I am working on a DETAIL oriented simulation game idea! I am an old school board gamer. I like lots of stats. I like more information than I need gives you options. It is easier to remove un-needed data and complexity than add it latter.
I am not so much concerned with whether something is feasible or appropriate at this time. I am more concerned about figuring out where to start looking to edit/add code to see if it is feasible.
So does anyone know where I should start looking?
What does the
void getDamageLocation(const Point3F& in_rPos, const char *&out_rpVert, const char *&out_rpQuad);
in player.cc do?
Torque Owner Josh Albrecht
I beleive your approach here seems too detailed. People cannot aim well enough to hit holes in armor. Also, they will not really notice if you instead simply use a pre-created damage map or something for partially damaged armor, and simply replace the "new armor" with the "damaged armor". And worrying about greyscale for armor values... it just seems like overkill to me.
Just my two cents. :)
About your question: I HIGHLY doubt that you can get teh UV coords of an intersection. That would require rediculous amounts of processing, as you would have to collide with every triangle in the mesh to find which you collided with, then collision with that plane to figure out where on the poly you hit, then you would have to somehow convert that to UV coords. It wont be easy or pretty, and I am not sure it is even possible without a huge performance hit and/or major changes to the engine. :/