question about vertex

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

question about vertex

Post by kattle87 »

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... :/
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: question about vertex

Post by VilleK »

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... :/
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.

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.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

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... :cry:

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 :P 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.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

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?
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:By the way, what will happen if i try a 3Dsphere vs 3DBox collision? will it work?
Yes it works! Next release is November 1.
Post Reply