Is there any way to check if a vertex of a model is entering an area?
Something like the V.Z in "MeshExpression"
EG: if i have a rotating cube, how can i be sure it has touched a wall?
If i could get X,Y and Z coordinates of every vertex i could easily do this... :/
question about vertex
Moderator: Moderators
Re: question about vertex
You would need the transformed world coordinates of each vertex for something like that. Currently ZGE cannot provide those coordinates since they are not needed internally, instead everything is handled by nested OpenGL transforms.kattle87 wrote:Is there any way to check if a vertex of a model is entering an area?
Something like the V.Z in "MeshExpression"
EG: if i have a rotating cube, how can i be sure it has touched a wall?
If i could get X,Y and Z coordinates of every vertex i could easily do this... :/
A better solution would be if ZGE had proper 3d cube collision detection, yes? Next ZGE will have 3d-box collision however it will still not take rotation into account, only so called axis-aligned boxes. I will keep improving collision detection in future ZGE versions. Complete and general 3d-collision is pretty complex and requires lots of work and large amount of runtime code which increase exe-size. So I want to find the middle-ground for ZGE.
lol... i understood almost what can be done... but nothing about working with shaders? I've seen the shader demo with the nice tea-pot code... well seems i can gather some usefull informations from it, can't i?
Let me explain... should i be able to store a value used in the shader code in a variable, and use that value in other places like conditions?
For example i could get the most-left vertex X value, and store it in a variable, then add the value to the object coordinates and check if the vertex is in the wall.... But i'm quite sure it won't work...
By the way, what will happen if i try a 3Dsphere vs 3DBox collision? will it work?
PS: Yes i know i'm always there with new questions and no working code
but i would like to do quite a crazy thing...
PS2: i do not really need working with a rotating cube, it was only an example.
Let me explain... should i be able to store a value used in the shader code in a variable, and use that value in other places like conditions?
For example i could get the most-left vertex X value, and store it in a variable, then add the value to the object coordinates and check if the vertex is in the wall.... But i'm quite sure it won't work...

By the way, what will happen if i try a 3Dsphere vs 3DBox collision? will it work?
PS: Yes i know i'm always there with new questions and no working code

PS2: i do not really need working with a rotating cube, it was only an example.
I don't believe shaders can be used that way. Shader-code run in parallell for many pixels/vertices at a time, so you cannot calculate things like most-left vertex X. Also there are difficulties sending data back from a shader to the main code. If you find a C++ example that manage this then I can check it out how they do.kattle87 wrote:should i be able to store a value used in the shader code in a variable, and use that value in other places like conditions?
Yes it works! Next release is November 1.kattle87 wrote:By the way, what will happen if i try a 3Dsphere vs 3DBox collision? will it work?