0 registered members (),
959
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Inside / Outside of a Mesh
#402892
06/11/12 17:46
06/11/12 17:46
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Hi there,
in my code I want to check if a specific point (given with it's XYZ Position-Vector) is inside a mesh or if it's not.
Has anyone an idea what's the best - or in my case - the most efficient way to do this?
POTATO-MAN saves the day! - Random
|
|
|
Re: Inside / Outside of a Mesh
[Re: Kartoffel]
#402899
06/11/12 18:20
06/11/12 18:20
|
Joined: Mar 2007
Posts: 197
yorisimo
Member
|
Member
Joined: Mar 2007
Posts: 197
|
I made invisible level blocks out of primitives (ellipse, cylinder, block) that were close to the shape of the mesh. I then used the "c_content" function to check whether or not a point was within empty space or a passable or unpassable block. In this way I could distinguish whether or not the specified point was inside one mesh or another, or neither. In documentation however, it says that this function is abandoned an not to be used in new projects. Also if your mesh entity moves you would have to move the level blocks along with your mesh.
@MasterQ32 - sounds like a better idea!
Last edited by yorisimo; 06/11/12 18:22.
|
|
|
Re: Inside / Outside of a Mesh
[Re: yorisimo]
#402902
06/11/12 18:52
06/11/12 18:52
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Simply do a c_trace from the XYZ point in question, to the XYZ co-ordinate(origin) of the mesh. (Using USE_POLYGON of course)
If you DO get a hit, then it is outside.
If you DONT get a hit, then its inside.
Unless its a really complex mesh, then I dunno... maybe the function "c_intersect" could be twisted into effect....
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Inside / Outside of a Mesh
[Re: EvilSOB]
#402910
06/11/12 19:27
06/11/12 19:27
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Thank you very much for the answers!! Doing some testing now
POTATO-MAN saves the day! - Random
|
|
|
Re: Inside / Outside of a Mesh
[Re: Kartoffel]
#402914
06/11/12 20:14
06/11/12 20:14
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
OK I'm using now EvilSOB's method. I created a model and checked a cube with 20*20*20 single traces... which works fine but sometimes there are points outside of the mesh detected as inside of it... ( pic) Another thing is, that this c_trace-method only works it I add wait(...); functions between every trace. Without wait()s the detection goes completely wrong. And it would be nice if this could be checked once per frame. But even if it would work without the wait(); functions it would be too slow. (Manual>c_trace>Speed: Slow) Looks like this won't work with 3DGS. Anyway, thaks a lot for your nice replys! Kartoffel
POTATO-MAN saves the day! - Random
|
|
|
Re: Inside / Outside of a Mesh
[Re: Kartoffel]
#402916
06/11/12 20:48
06/11/12 20:48
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
EvilSOBs method only works if you got a mesh like a cube or a sphere the basic idea is correct, but you can also have different cases of meshes: The trace hits something (our gray funny-looking blob-mesh), but is NOT inside the mesh! As i said you have to count all hits on this mesh. Even results (in this case 2) are outside the mesh, odd numbers are inside this would be an accurate system to check if you are inside the mesh and don't forget to active USE_POLYGON For counting the hit targets you could use a contribution of me (Multiple Hit Traces)
|
|
|
Re: Inside / Outside of a Mesh
[Re: MasterQ32]
#402917
06/11/12 20:56
06/11/12 20:56
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I'm tracing from the Position which should be checked to the middle of the object.
If it hits nothing it is inside. And as long as all normals pointing away from the center and the center is inside the mesh, too this works.
For more complex models I'd go for your solution.
But as I already said: c_trace isn't the right way to go if I want to do this once per frame.
It would be nice If it works as I want, but It doesn't matter. It's just a kind of test-project I wanted to do, but obviously it wont work fast enough.
Last edited by Kartoffel; 06/11/12 20:59.
POTATO-MAN saves the day! - Random
|
|
|
|