TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
andre jones
NA
7
6.8k
using raycast to read the texture coordinates of a mesh
Jan 9 2013 10:47 PM
My overall goal is to try to create certain sounds and particle effects based on the texture of the terrain the character is walking on so I started with the ray picking sample at the msdn website below.
http://xbox.create.msdn.com/en-US/education/catalog/sample/picking_triangle
I found a second link(below) that was helpful but wasnt sure how to modify the ray triangle method according to the instructions(modify the RayIntersectsModel method that does the
triangle
test so it will output the indices of the closest intersecting triangle's vertices -- right now it just outputs the vertex positions. This is in the inner most block of the method, where it stores the information for the closest detected intersection:
// If so, is it closer than any other previous
triangle
?
if
((closestIntersection ==
null
) || (intersection < closestIntersection))
{
// ....
You just need to add an integer output parameter for the method and store the value of the i counter. If RayIntersectsModel returns with a hit, you use i, i+1, and i+2 as the indices into the texcoord list you have stored in the model's tag data. ), so I came
here for help. THANKYOU
http://xboxforums.create.msdn.com/forums/p/81663/495156.aspx
RayIntersectsTriangle(ref ray,
ref vertices[i],
ref vertices[i + 1],
ref vertices[i + 2],
out intersection);
// Does the ray intersect this triangle?
if (intersection != null)
{
// If so, is it closer than any other previous triangle?
if ((closestIntersection == null) ||
(intersection < closestIntersection))
{
// Store the distance to this triangle.
closestIntersection = intersection;
// Transform the three vertex positions into world space,
// and store them into the output vertex parameters.
Vector3.Transform(ref vertices[i],
ref modelTransform, out vertex1);
Vector3.Transform(ref vertices[i + 1],
ref modelTransform, out vertex2);
Vector3.Transform(ref vertices[i + 2],
ref modelTransform, out vertex3);
}
}
Reply
Answers (
0
)
need help
reading textcoord from a multitextured mesh