Original Post
I am trying to figure a way to pick vertices instead of faces
so that i can raise or lower a vertex of a terrain in an editor
when the user clicks it with a given radius affecting nearby
vertices as well.
I am looking at D3DXIntersect in the SDK and it talks about
"barycentric" coordinates:
Barycentric coordinates are a form of general coordinates.
In this context, using barycentric coordinates represents a
change in coordinate systems...
Ok that doesn''t tell me much at all.
What is this barycentric coordinate system?
Are they related to the texture coordinates, and if I
define texture coordinates will it affect the barycentric
coordinates this function returns?
The documentation also says:
"this function returns the resulting point by using
the following equation v1+u(v2-v1)+v(v3-v1)"
Yet the return value is an HRESULT and it seems
to return an array of faces using a pointer to an array
of DWORDS. So I don''t see a point being returned
anywhere. Am I right? How do I figure the closest point
(vertex) from the information returned.
Of course, it doesn''t explain how the DWORD value
corresponds to a face either. How do I know which
face?
As far as the term barycentric google turned up some info
from which I assume this conclusion:
there are three vertices of a tri ABC
using barycentric coords u,v,w
u increases as point P moves closer to A
v increases as point P moves closer to B
w increases as point P moves closer to C
replace increase with the word decrease, and closer with
the word farther in any of the above statements ,and they
still hold true.
but now let''s try to make sense of D3DXIntersect:
1 the function only gives u and v instead of 3 coords
2 nowhere are the ranges of the coords explained
3 and no where is explained how we can tell whether u
corresponds to A,B, or C and the same for v (I am assuming
some elaborate system of indexing, but I wouldnt be surprised
if some unknown factor would screw it up since this
function is documented like crap, i.e if u and v change
depending on matrixes, or are always consistant in some manner)
so here are more specific questions:
how do you use a barycentric coord system with only two coords
instead of three to find if you are closer to A, B, or C?
what are the ranges of these coords?
how can you keep track of whether u and v correspond to A,B, or C
since these labels are abstract? Is it consistant? Do Matrixes
affect this?
Do I need an elaborate indexing system?
There are probably enough questions in this post to write a
book, but useful information at all would help a great deal.
Thanx,
Christopher