ok, i got the world position with:

Code:
mat4 ToWorldMatrix= osg_ViewMatrixInverse* gl_ModelViewMatrix;
vec3 worldPos = ToWorldMatrix * gl_Vertex;




now i need to check which side of the plane the worldPos is.
I googled and found some code for this but its not for glsl, ive came up with 
this but i get errors.

the code is:


Code:
vec3 n;
float d;

n = (pos1 -pos0) ^ (pos2 - pos1);
d = -n * pos0;

inside = 1.0;

if (dot(n, gl_Position) + w)
{               
inside = 0.0;
}




the errors i get are:


Code:
VERTEX glCompileShader "" FAILED
VERTEX Shader "" infolog:
0(46) : error C1021: operands to "^" must be integral

glLinkProgram "eroded" FAILED
Program "eroded" infolog:
Vertex info
-----------
0(46) : error C1021: operands to "^" must be integral

Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,)




so i tried 


Code:
vec3 n;
        float w;

        int p0 = (pos1 -pos0);
        int p1 = (pos2 - pos1);
        n =  p0 ^ p1;
        w = -n * pos0;
        inside = 1.0;

        if (dot(n, worldPos) + w)
        {               
                inside = 0.0;
        }



but it alway returns inside = 0.0;

any ideas?

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13031#13031





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to