Re: Mesh.IntersectSubset
- From: "Ray" <ja-raholnospam@xxxxxxxxx>
- Date: Sun, 6 Aug 2006 18:23:00 +0200
Thanks for your reply.
I was using the method inappropriately, I switched to Mesh.Intersect
instead, and it worked. Using IntersectSubset it only searched for a ray in
that given Subset, but i had lots of subsets in my mesh :)
It will now successfully return the distance of the ray, index of the
rectangle the ray hits, also U and V coordinates in the rectangle.
-Ray
I've never played with meshes before but I've had my share of annoyances
with
collision testing. So here's some insights I've come across that you might
want to look at.
Normalize turns a vector into what is known as a unit vector which is 1
unit
long. Seems to aid in calculation but I haven't seen a better explanation
than that I'm afraid.
As to intersecting with just one side of the scene you might want to look
at
how your culling is working. I had to play about with some code so that
the
intersection code I used was relative to how my culling was done.
Xpos and YPos are the mouse position points gathered from clicking on the
screen but in this case its literally the center of the viewport which you
need to set. if you haven't been using viewport as the dimensions of your
scene you could try replacing those variables with the relevant width and
height variables set up when you created your directX object and scene.
Alternatively you can acquire the mouse co-ordinates and use them so you
can
simply click on the screen and get the intersection of the object at the
point you clicked.
Unfortunately I've been using C++ so haven't got anything that is C# coded
but if you still have problems I can try and rig up a simple project to
test
out your code segment.
"Ray" wrote:
Hi
I'm trying to get Mesh.IntersectSubset working.
I have a small 3d world which is a Mesh.
To check what face is directly in front of me, I thought I could use the
Mesh.IntersectSubset method.
This is to implement collision detection, checking what material and
texture
the face has etc.
However, I can't get it to work, and I'm not sure I understand the
method,
or maybe I should use another approach. After a bit of googling I found
this:
int Xpos = viewport.Height / 2;
int Ypos = viewport.Width / 2;
Vector3 Nearcor = Vector3.Unproject(new Vector3(Xpos, Ypos,
0),
viewport, device.Transform.Projection, device.Transform.View,
device.Transform.World);
Vector3 Farcor = Vector3.Unproject(new Vector3(Xpos, Ypos,
1),
viewport, device.Transform.Projection, device.Transform.View,
device.Transform.World);
Farcor.Normalize();
IntersectInformation closesthits;
bool testIntersect = mesh.IntersectSubset(0, Nearcor, Farcor,
out closesthits);
I'm not sure about the Xpos and Ypos. And what is "Normalize" ? In the
SDK
all it says is: "Returns the normalized version of a 3-D vector." so not
much help here either :)
Anyway, I couldn't get this to work, it seems to intersect sometimes, but
just in one side of my world and not when i'm directly in front of it.
What
am I doing wrong here?
Thanks for your time so far.
-Ray
.
- References:
- Mesh.IntersectSubset
- From: Ray
- RE: Mesh.IntersectSubset
- From: Xrystal
- Mesh.IntersectSubset
- Prev by Date: RE: Mesh.IntersectSubset
- Next by Date: Timing issue
- Previous by thread: RE: Mesh.IntersectSubset
- Next by thread: Timing issue
- Index(es):
Relevant Pages
|