Re: Mesh.IntersectSubset

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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





.



Relevant Pages

  • RE: Mesh.IntersectSubset
    ... collision testing. ... intersection code I used was relative to how my culling was done. ... screen but in this case its literally the center of the viewport which you ... height variables set up when you created your directX object and scene. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Fast hit-testing on a heightfield?
    ... Because it's a heightfield, I can't simply get the position of the mouse pointer transformed onto the plane as the mouse might in theory be intersecting many triangles. ... Testing all of the triangles in the heightfield would be major overkill, you should only need to test against a limited number of triangles that cross the ray under the cursor. ... You may further optimize this by testing against the heightmap first to determine areas of possible intersection, to which can avoid more costly ray vs. triangle tests in areas where there is no possible intersection. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: pick closest mesh by mouse
    ... > closesthit.distance does indeed give you the distance along that ray. ... > intersection code isn't working at all. ... >>> be used to compute the distance to the initial ray of selection. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Picking: pros and cons of each method
    ... boundaries) whose intersection with a ray is easy to calculate? ... understand that enclosing scene objects in virtual boundaries doesn't ... different and possible independent scene graph. ... Setting volumes and calculating their intersection with a given ray is ...
    (comp.graphics.api.opengl)
  • Re: Reflecting a ray off a line
    ... to find an intersection between a ray and a line you just solve this ... Therefor we rearrange ... there are cases in which a line and a ray don't intersect, ... then substitute t in the first equation. ...
    (comp.graphics.rendering.raytracing)