Kim C Bale wrote: > I presume this line: > > n = (pos1 -pos0) ^ (pos2 - pos1); > > is a cross product of two vectors. i.e. the normal, also known as the > vector perpendicular to the two vectors that define the plane. > > In which case you would want to use the glsl function cross(vec3,vec3) > as on the reference sheet I sent previously. > > You should have a read about the geometry math being used here. Blindy > copying code without understanding it is a good way to shoot yourself in > the foot later on. > > > Kim. > > > -----Original Message----- > From: > [mailto:] On Behalf Of Paul > Griffiths > Sent: 27 May 2009 13:40 > To: > Subject: Re: vertex shader help: compare position against > plane > > 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 > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or > g > ***************************************************************************************** > To view the terms under which this email is distributed, please go to > http://www.hull.ac.uk/legal/email_disclaimer.html > ***************************************************************************************** > _______________________________________________ > osg-users mailing list > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ------------------ > Post generated by Mail2Forum
Thanks kim. am new to this 3d math stuff. ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=13051#13051 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org