Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

daryoushj

glClipPlane does not CLIP!

This topic is 5603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone! I have a simple 3D-Plotting program (in VB) the draws 3 rectangles on X-Y, X-Z and Y-Z Planes respectively (Their corner cordinates are: X-Y Rectangle: (0,0,0) - (10,20,0) X-Z Rectangle: (0,0,0) - (10,0,10) Y-Z Rectangle: (0,10,0) - (0,20,20) (The point-coordinates and rectangle-connections are given via an Input-File) In this program, I''m also doing XYZ-Rotation based on User-Input for which I am using glLookAt. Moreover, I am drawing a little XYZ-Axis on the bottom-left corner of the screen two show the current "rotation". the SIMPLIFIED CODE of the RenderScene subroutine which does the drawing is as follows: Public Sub RenderScene() Dim W(3, 2) As Single Dim p(2) As Single Dim X, Y, Z As Single Dim i, j, k, m As Integer Dim A() As Byte Dim s As String ''***************************** '' Setup the Clipping Equations ''***************************** Dim xClip(3) As GLdouble Dim yClip(3) As GLdouble Dim zClip(3) As GLdouble Dim xc, yc, zc As Variant xc = Array(1#, 0#, 0#, -5#) yc = Array(0#, 1#, 0#, -5#) zc = Array(0#, 0#, 1#, -5#) For i = 0 To 3 xClip(i) = xc(i): yClip(i) = yc(i): zClip(i) = zc(i) Next ''*********************** ''Initialize the Graphics ''*********************** glMatrixMode mmModelView glLoadIdentity glScalef 0.01, 0.01, 0.01 glClear clrColorBufferBit + clrDepthBufferBit ''******************************************** '' Draw the XYZ-Axis at the bottom-left croner ''******************************************** glPushMatrix glTranslatef -80, -60, 0 If xRot = 0 And zRot = 0 Then gluLookAt xRot, yRot, zRot, 0#, 0#, 0#, 0#, 0#, 1# Else gluLookAt xRot, yRot, zRot, 0#, 0#, 0#, 0#, 1#, 0# End If glRGB 255, 0, 0 glBegin bmLines glVertex3f 0, 0, 0 glVertex3f 10, 0, 0 glEnd glPushMatrix glTranslatef 10#, 0#, 0# s = "X" glListBase myFont - 32 ReDim A(0 To Len(s) + 1) StringToByteArray A, s glScalef 4#, 4#, 4# glCallLists Len(s), GL_BYTE, A(0) glPopMatrix glRGB 0, 255, 0 glBegin bmLines glVertex3f 0, 0, 0 glVertex3f 0, 10, 0 glEnd glPushMatrix glTranslatef 0#, 10#, 0# s = "Y" glListBase myFont - 32 ReDim A(0 To Len(s) + 1) StringToByteArray A, s glScalef 4#, 4#, 4# glCallLists Len(s), GL_BYTE, A(0) glPopMatrix glRGB 0, 0, 255 glBegin bmLines glVertex3f 0, 0, 0 glVertex3f 0, 0, 10 glEnd glPushMatrix glTranslatef 0#, 0#, 10# s = "Z" glListBase myFont - 32 ReDim A(0 To Len(s) + 1) StringToByteArray A, s glScalef 4#, 4#, 4# glCallLists Len(s), GL_BYTE, A(0) glPopMatrix glPopMatrix SwapBuffers frmDisplay.hDC glFlush ''****************************** '' Draw the Rectangles ''****************************** glPushMatrix If xRot = 0 And zRot = 0 Then gluLookAt xRot, yRot, zRot, 0#, 0#, 0#, 0#, 0#, 1# Else gluLookAt xRot, yRot, zRot, 0#, 0#, 0#, 0#, 1#, 0# End If glMatrixMode mmProjection For i = 1 To bIndx For j = 0 To 3 W(j, 0) = points(boxes(i, j), 0) W(j, 1) = points(boxes(i, j), 1) W(j, 2) = points(boxes(i, j), 2) Next Call Quadratic(W) Next ''1 to bIndx glClipPlane cpClipPlane0, xClip glEnable glcClipPlane0 glClipPlane cpClipPlane1, yClip glEnable glcClipPlane1 glClipPlane cpClipPlane2, zClip glEnable glcClipPlane2 glPopMatrix SwapBuffers frmDisplay.hDC '' Flush drawing commands glFlush End Sub Sub Quadratic(W() As Single) glBegin GL_LINE_LOOP glVertex3f W(0, 0), W(0, 1), W(0, 2) glVertex3f W(1, 0), W(1, 1), W(1, 2) glVertex3f W(2, 0), W(2, 1), W(2, 2) glVertex3f W(3, 0), W(3, 1), W(3, 2) glEnd glBegin GL_QUADS glVertex3f W(0, 0), W(0, 1), W(0, 2) glVertex3f W(1, 0), W(1, 1), W(1, 2) glVertex3f W(2, 0), W(2, 1), W(2, 2) glVertex3f W(3, 0), W(3, 1), W(3, 2) glEnd End Sub As it shows, I am using three 1D-Arrays (xClip, yClip & zClip) to clip the entire graph with three planes: X=5, Y=5 and Z=5 (or I am trying to!) BUT NOTHING EVER HAPPENS AT ALL! My best guess is that I am missing some other "parts" (i.e. sub/func calls) and/or maybe the order/placement of my calls are not correct. I would really appreciate any help with this regard.

Share this post


Link to post
Share on other sites
Advertisement
That is the seventh time you crossposted this into several forums. It is starting to get seriously annoying. I strongly advise you to stop it now, otherwise appropriate measures will be taken.

Post your question into ONE forum. If you don''t get replies, bump it ONCE. If you still don''t get replies, then you might think about giving additional information.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!