Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I need to move clipping plane of OpenGL and begin the clipping from that position. The default location of clipping plane is (0,0,0), so if my model is far enough from the center of coordinate system it immediately disappears, as I begin the clipping, cause it appears in the half clipped by the plane that just moved from (0,0,0) point. So what I need is :

  1. Create a clipping plane
  2. Translate it to the point I want (normally it's near model surface I want to clip)
  3. Begin the clipping from that point and not from (0,0,0).

How can I achieve my goal ?

share|improve this question
    
So, did jpaver's suggestion work? –  Sam Hocevar Nov 4 '11 at 22:03

1 Answer 1

up vote 2 down vote accepted

glClipPlane takes 4 coordinates for the plane equation: {Nx, Ny, Nz, d}, where N=[Nx,Ny,Nz] is the normal of the plane, and d is the projected distance of any point on that plane along the normal.

The definition of a plane is:

dotProduct(P,N) + d = 0

(where P is any point on that plane)

So, by simple math,

d = -dotProduct(P,N)

eg. if you want to place your plane at (0,3,1), you calculate:

d = -dotProduct([0,3,1], [Nx,Ny,Nz])

then it should just be a matter of sending Nx,Ny,Nz,d to glClipPlane.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.