Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


From a Ray to a Texture address

This topic is 5941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im working on a WipOut-like game. And when a ship gets shooted, I have to draw a bullet hole on its texture but I don''t know how to do that, I don''t know even how to know where in the texture I have to draw. Can anyone help me?!? I''m actually in troubles.

Share this post

Link to post
Share on other sites
I cannot think of any tutorials / docs on this sort of thing off the top of my head but you might want to try and do a search for "decals" and "planar projections". These are the things you are effectively looking for and will get you moving in the right direction.


Share this post

Link to post
Share on other sites
I would fake it and use a set of secondary textures, or a render target...
When the ship gets shot, render a bullet sprite or whatever to a texture, possibly in the approximate region of the bullet impact point (I think that if it''s a fast-paced wipeout-stylee job, then players really won''t care, or have time to care where EXACTLY the bullet hit, especially if it''s not a major point of the game, but maybe it is..i don''t know..), and then render this new texture on top of the ship.

Either that, or you could set up 7 or 8 textures with progressivly detailed scrape and bullet marks, and just switch them according to the extremety of the damage to the ship.

In the type of game you describe I wouldn''t go into such detail as finding exact plane coordinates and presice hit points, then worry about how to draw a single bullet hole on the ship..

Share this post

Link to post
Share on other sites
U and V returned by D3DXIntersect are NOT texture coordinates. They are barycentrics coordinates. You will have to further convert them into texture UV coordinates.

T = T2*Bu + T3*Bv + T1*(1-Bu-Bv)

T is a vector representing the intersection coordinates in UV texture coordinates
T1 is a vector representing the texture coordinate for the first vertex in the face
T2 is the second
T3 is the third
B is a vector representing the barycentric point of intersection
Bu is the U component for barycentric vector
Bv is the V component for barycentric vector

Oooh, you found the horadric cube!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!