|
Post by DJLinux on May 10, 2007 20:48:22 GMT -5
hello girls ;D this are my latest template for all next ODE examples. i added an help screen and keys for togle gfx properties and now i use in ODE the same 3D coords as OpenGL (X,Y-Z).
one thing are missed for now: in the final version of ODE examples you can change the camere with the mouse or put it in any ODE object. Nice if you will drive vehicles from my collecion of ODE examples.
Joshy
please test it and let me now is it ok for all next ODE examples.
by the way why are the spaces in front are removed if i use " [/ CODE] ?" [code]' odetest.gb '------------ ' ODE plugin for Basic4GL. ' ' this are the basic's to create a couple of ODE objects: ' dWorldID, dSpaceID, dJointgroupID, dBodyID, dGeomID ' Now collision and contact creation are our part.
' the name say it const GRAVITY# = -9.81 ' the size of one simulation step are 1.0 / frames per second const TimeStep# = 1.0/60 ' number of boxes const NB = 60 ' maximal 100 in one collision space
struc RIGIDBODY dim Sx#,Sy#,Sz# ' size in x,y,z dim Mass# ' mass in KG dim BodyID ' ODE rigidbody dim GeomID ' ODE collision geom endstruc
dim RIGIDBODY Bodys(NB-1) dim WorldID,SpaceID,GroundID,JointGroupID,ContactJointID dim M#(20),P#(3),R#(3,3),RND1# dim SurfaceParams#(8),NumOfContacts,NContacts dim Pair(1),NumOfPairs
dim BC dim i,j,k,tex ' #################################################### ' # gfx engine: # ' # all with the prefix "gfx"_is not needed for ODE # ' # and exclusively for visualization a small world. # '#################################################### ' en/dis - able the primary gfx_properties here dim gfx_blnUseTexture : gfx_blnUseTexture = True dim gfx_blnUseLight : gfx_blnUseLight = True dim gfx_blnUseShadow : gfx_blnUseShadow = True dim gfx_blnUseFog : gfx_blnUseFog = True ' press [F1] will togle gfx_blnUseHelp dim gfx_blnUseHelp : gfx_blnUseHelp = True
dim gfx_FrameCounter dim gfx_PolyCounter
const gfx_WorldSize# = 1000 ' 500 in front of camera const gfx_GroundScale# = 1.0/24 const gfx_GroundOffsetX# = 0.5 const gfx_GroundOffsetY# = 0.5 const gfx_SkyScale# = 1.0/64 const gfx_SkyHeight# = 20.0
const gfx_Near# = 0.1 ' near plane const gfx_Far# = 500.0 ' far plane = WorldSize#*0.5 const gfx_Scale# = 0.8 ' 1 = +/- 45 degrees
const gfx_TexSky = 0 const gfx_TexGround = 1 const gfx_TexWood = 2 const gfx_TexBox = 3
dim gfx_LastKey
dim gfx_Image, gfx_Textures(3), gfx_CurrentTexture
dim gfx_GNDColor#(3) ' GND = ground dim gfx_SKYColor#(3) dim gfx_FOGColor#(3) dim gfx_BOXColor#(3)
dim gfx_SkyOffset#, gfx_SkyX#, gfx_SkyY#
dim gfx_Width#,gfx_Height# dim gfx_Scale2# dim gfx_Color#(3) ' r,g,b,a dim gfx_T#(3,3) ' transform drawing matrix dim gfx_S#(3,3) ' transform shadow matrix
dim gfx_Light_Ambient# (3) dim gfx_Light_Diffuse# (3) dim gfx_Light_Specular# (3) dim gfx_Light_Shininess#(3)
dim gfx_Mat_Ambient# (3) dim gfx_Mat_Diffuse# (3) dim gfx_Mat_Specular# (3)
' S and T params for drawing and shadows dim gfx_Draw_s#(3) ,gfx_Draw_t#(3) dim gfx_Shadow_s#(3),gfx_Shadow_t#(3) dim gfx_LightP# (3) ' Light position vector dim gfx_CameraXYZ#(3) ' Camera position vector dim gfx_CameraYPR#(3) ' Camera yaw pitch roll dim gfx_ViewXYZ# (3) ' Camera mouse control dim gfx_ViewYPR# (3) ' Camera mouse control
dim gfx_ListBox ' precompiled unit Box 'dim gfx_ListSphere ' precompiled unit Sphere 'dim gfx_ListCylinder ' precompiled unit Cylinder 'dim gfx_ListCapsule ' precompiled unit Capsule 'dim gfx_ListPyramid ' precompiled unit Pyramid
gfx_GNDColor# = vec4(0.3 ,0.3 ,0.3 ,1) ' gray gfx_BOXColor# = vec4(0.5 ,0.25,0.0 ,1) ' brown gfx_SKYColor# = Vec4(0.5 ,0.6 ,0.75 ,1) ' blue gfx_FOGColor# = Vec4(0.15,0.2 ,0.25 ,1) ' soft blue
gfx_LightP# = Vec4(1,10,1, 0)
'gfx_Draw_s# = Vec4(1.0 , 1.0 ,0.0 ,1.0) 'gfx_Draw_t# = Vec4(0.817,-0.817,0.817,1.0) 'gfx_Shadow_s# = Vec4(gfx_GroundScale#,0,0,gfx_GroundOffsetX#) 'gfx_Shadow_t# = Vec4(0,gfx_GroundScale#,0,gfx_GroundOffsetY#)
gfx_Light_Ambient# = vec4( 1,1,1, 1) gfx_Light_Diffuse# = vec4( 1,1,1, 1) gfx_Light_Specular# = vec4( 1,1,1, 1)
glGenTextures(4,gfx_Textures)
gfx_Image = LoadImage("resources/sky.bmp") gfx_CurrentTexture=gfx_TexSky gosub gfx_Image2Texture
gfx_Image = LoadImage("resources/ground.bmp") gfx_CurrentTexture=gfx_TexGround gosub gfx_Image2Texture
gfx_Image = LoadImage("resources/wood.bmp") gfx_CurrentTexture=gfx_TexWood gosub gfx_Image2Texture
gfx_Image = LoadImage("resources/box.bmp") gfx_CurrentTexture=gfx_TexBox gosub gfx_Image2Texture
' Init our ODE objects gosub InitScene
TextMode(TEXT_OVERLAID)
' our simloop While True gfx_FrameCounter=gfx_FrameCounter+1 ' draw our short world Gosub DrawScene ' get key every 5 frame if (gfx_FrameCounter % 5)=0 then gfx_LastKey=InScanKey() if (gfx_LastKey<>0) then if gfx_LastKey=112 then gfx_blnUseHelp=not gfx_blnUseHelp elseif gfx_LastKey=asc("L") then gfx_blnUseLight=not gfx_blnUseLight elseif gfx_LastKey=asc("S") then gfx_blnUseShadow=not gfx_blnUseShadow elseif gfx_LastKey=asc("T") then gfx_blnUseTexture=not gfx_blnUseTexture elseif gfx_LastKey=asc("F") then gfx_blnUseFog=not gfx_blnUseFog elseif gfx_LastKey=asc("R") then gosub ResetScene endif endif endif
if gfx_blnUseHelp=True then locate 0,0 printr "frames =" + gfx_FrameCounter + " " printr "polygones =" + gfx_PolyCounter + " " printr printr "[ESC] quit " printr "[F1] help off" print "[L] light ":if gfx_blnUseLight then printr "off" else printr "on " endif print "[S] shadow ":if gfx_blnUseShadow then printr "off" else printr "on " endif print "[T] texture ":if gfx_blnUseTexture then printr "off" else printr "on " endif print "[F] fog ":if gfx_blnUseFog then printr "off" else printr "on " endif print "[R] restart " DrawText() endif ' swap curent GL's framebuffers SwapBuffers() ' how many geoms are collided NumOfPairs=SpaceBuildCollisionPairs(SpaceID) if NumOfPairs>0 then ' loop over all collision pairs for i=0 to NumOfPairs-1 ' get geom1 and geom2 Pair=GetCollisionPair(i) ' how many contacts between geom1 and geom2 NumOfContacts=BuildContacts(Pair(0),Pair(1)) if NumOfContacts>0 then ' loop over all contacts between geom1 and geom2 for j=0 to NumOfContacts-1 ' mu must be set (if not it will be set to 0.0) SurfaceParams#(PARAM_MU)=40 SetContactSurfaceParams(j,0 ,SurfaceParams#) ContactJointID=CreateContact(WorldID,JointGroupID,j) ' connect our two bodys with the joint dJointAttach(ContactJointID,GetBody1FromContact(j),GetBody2FromContact(j)) next end if next endif
' do one physics step dWorldStep(WorldID,TimeStep#) ' clear all involved contacts for next physic step dJointGroupEmpty(JointGroupID) 'WaitTimer(1000/FPS) wend end
' the rest are for gfx_ ...
InitScene: ' ######################### ' # setup our ODE objects # ' ######################### ' create our ODE world WorldID = dWorldCreate() ' create a container for contact joints. JointGroupID = dJointGroupCreate(0) ' create a (top level) collision space SpaceID = dHashSpaceCreate (0) ' create a not moveable infinity collison plane GroundID = dCreatePlane(SpaceID,0,1,0,0) ' set our gravity -9.81 in this case dWorldSetGravity (WorldID,0,GRAVITY#,0) dim x#,y#,z#,w# ' create our n rigidbodys for bC=0 to NB-1 ' set dimension Bodys(BC).Sx# =10 Bodys(BC).Sy# =30 Bodys(BC).Sz# = 3 ' set the mass Bodys(BC).Mass#=100 ' create rigidbody Bodys(BC).BodyID=dBodyCreate(WorldID) ' create collision geom Bodys(BC).GeomID=dCreateBox (SpaceID,Bodys(BC).Sx#,Bodys(BC).Sy#,Bodys(BC).Sz#) ' fill the mass M#() array/struc M#=dMassSetBoxTotal(Bodys(BC).Mass#,Bodys(BC).Sx#,Bodys(BC).Sy#,Bodys(BC).Sz#) ' set the mass struct dBodySetMass (Bodys(BC).BodyID,M#) next gosub ResetScene return
ResetScene: ' init our rigid bodys for bC=0 to NB-1 ' set dimension y#=16+rnd() % 100 x#=Cos(w#)*150 z#=Sin(w#)*150-280 w#=w#+6.28/NB ' set RigidBody position dBodySetPosition(Bodys(BC).BodyID,x#,y#,z#) ' create rotation MATRIX R#=dRFromEulerAngles(0,w#,0) ' set the rotation MATRIX dBodySetRotation(Bodys(BC).BodyID,R#) ' set the collision GeomID to the RigidBody dGeomSetBody (Bodys(BC).GeomID,Bodys(BC).BodyID) next gfx_FrameCounter=0 gfx_PolyCounter =0 return
' ################## ' # draw our world # '################## DrawScene: ' clear buffers, set cam, draw ground and animated sky Gosub gfx_NewFrame ' draw all boxes for bc=0 to NB-1 ' set drawing mode Gosub gfx_SetDrawingMode ' get curent position VBECTOR from rigidbody P#=dBodyGetPosition(Bodys(BC).BodyID) ' get curent rotation MATRIX from rigidbody R#=dBodyGetRotation(Bodys(BC).BodyID) ' combine R#(3,3) and P#(2) in T#(3,3) Gosub gfx_SetTransForm ' set box dimension glScalef(Bodys(BC).Sx#,Bodys(BC).Sy#,Bodys(BC).Sz#) ' render the box Gosub gfx_DrawBox glPopMatrix()
if gfx_blnUseShadow=True then Gosub gfx_SetShadowMode Gosub gfx_SetShadowTransForm Gosub gfx_SetTransForm glScalef(Bodys(BC).Sx#,Bodys(BC).Sy#,Bodys(BC).Sz#) Gosub gfx_DrawBox glPopMatrix() glPopMatrix() endif next return gfx_NewFrame: ' ############################################# ' # reset OpenGl and draw the ground and sky. # '############################################# 'glenable (GL_COLOR_MATERIAL)
if gfx_blnUseTexture=True then glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glEnable (GL_TEXTURE_2D) else glDisable (GL_TEXTURE_2D) endif glDisable (GL_BLEND) glShadeModel (GL_FLAT) glClearDepth (1.0) glEnable (GL_DEPTH_TEST) glDepthFunc (GL_LESS) glEnable (GL_CULL_FACE) glCullFace (GL_FRONT) glFrontFace (GL_CW)
'gfx_Width# = WindowWidth() 'gfx_Height# = WindowHeight() ' setup viewport 'glViewport (0,0,gfx_Width#,gfx_Height#)
'glMatrixMode (GL_PROJECTION) 'glLoadIdentity() 'if (gfx_Width#>= gfx_Height#) then ' gfx_Scale2#=gfx_Height#/gfx_Width# ' glFrustum (-gfx_Near#*gfx_Scale#,gfx_Near#*gfx_Scale#,-gfx_Near#*gfx_Scale#*gfx_Scale2#,gfx_Near#*gfx_Scale#*gfx_Scale2#,gfx_Near#,gfx_Far#) 'else ' gfx_Scale2#=gfx_Width#/gfx_Height# ' glFrustum (-gfx_Near#*gfx_Scale#*gfx_Scale2#,gfx_Near#*gfx_Scale#*gfx_Scale2#,-gfx_Near#*gfx_Scale#,gfx_Near#*gfx_Scale#,gfx_Near#,gfx_Far#) 'end if ' clear buffers glClearColor (0.15,0.2,0.25 ,1) glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) ' go to GL_MODELVIEW matrix mode and set the camera glMatrixMode(GL_MODELVIEW) glLoadIdentity() ' move cam UP glTranslatef( 0, -15,0) if gfx_blnUseLight=True then glEnable (GL_LIGHTING) glEnable (GL_LIGHT0) glLightfv (GL_LIGHT0, GL_POSITION, gfx_LightP#) glLightfv (GL_LIGHT0, GL_AMBIENT , gfx_Light_Ambient# ) glLightfv (GL_LIGHT0, GL_DIFFUSE , gfx_Light_Diffuse# ) glLightfv (GL_LIGHT0, GL_SPECULAR, gfx_Light_Specular#) else glDisable (GL_LIGHTING) endif
if gfx_blnUseFog=True then ' high fog mode glFogI (GL_FOG_MODE , GL_EXP) glHint (GL_FOG_HINT , GL_NICEST) glFogF (GL_FOG_DENSITY, 0.001) ' low fog mode 'glFogI (GL_FOG_MODE , GL_LINEAR) 'glHint (GL_FOG_HINT , GL_FASTEST) 'glFogF (GL_FOG_START , 0.5) 'glFogF (GL_FOG_END , 1.0) glFogFV (GL_FOG_COLOR , gfx_FogColor#) glEnable (GL_FOG) else glDisable (GL_FOG) end if
gosub gfx_DrawGround gosub gfx_DrawSky return
gfx_DrawGround: glShadeModel (GL_FLAT) glEnable (GL_DEPTH_TEST) glDepthFunc (GL_LESS) glDepthRange (0.0,1.0) const yg#=-0.1
if gfx_blnUseLight=True then 'glEnable(GL_LIGHTING) else 'glDisable(GL_LIGHTING) endif if gfx_blnUseTexture=True then glEnable (GL_TEXTURE_2D) glBindTexture (GL_TEXTURE_2D,gfx_Textures(gfx_TexGround)) else glDisable (GL_TEXTURE_2D) endif
glColor4FV(gfx_GNDColor#)
glBegin (GL_QUADS) glNormal3f (0,1,0) glTexCoord2f (-gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetX#, -gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetY#) glVertex3f (-gfx_WorldSize#, yg#,gfx_WorldSize#) glTexCoord2f ( gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetX#, -gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetY#) glVertex3f ( gfx_WorldSize#,yg#,gfx_WorldSize#) glTexCoord2f ( gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetX#, gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetY#) glVertex3f ( gfx_WorldSize#,yg#,-gfx_WorldSize#) glTexCoord2f (-gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetX#, gfx_WorldSize#*gfx_GroundScale# + gfx_GroundOffsetY#) glVertex3f (-gfx_WorldSize#,yg#,-gfx_WorldSize#) glEnd() gfx_PolyCounter=gfx_PolyCounter+1 return
gfx_DrawSky: glShadeModel (GL_FLAT) glEnable (GL_DEPTH_TEST) glDepthFunc (GL_LEQUAL) glDepthRange (1.0,1.0) if gfx_blnUseTexture=True then glEnable (GL_TEXTURE_2D) glBindTexture (GL_TEXTURE_2D,gfx_Textures(gfx_TexSky)) else glDisable (GL_TEXTURE_2D) glColor4FV (gfx_SkyColor#) endif
gfx_ViewXYZ#(1)=5.0 gfx_SkyX#=gfx_WorldSize#*gfx_SkyScale# gfx_SkyY#=gfx_SkyHeight#+1 ' gfx_ViewXYZ(2) + gfx_SkyHeight# glBegin (GL_QUADS) glNormal3f (0,-1,0) glTexCoord2f (-gfx_SkyX#+gfx_SkyOffset# ,-gfx_SkyX#+gfx_SkyOffset#) glVertex3f (-gfx_WorldSize#,gfx_SkyY#,-gfx_WorldSize#) glTexCoord2f (-gfx_SkyX#+gfx_SkyOffset# , gfx_SkyX#+gfx_SkyOffset#) glVertex3f ( gfx_WorldSize#,gfx_SkyY#,-gfx_WorldSize#) glTexCoord2f ( gfx_SkyX#+gfx_SkyOffset# , gfx_SkyX#+gfx_SkyOffset#) glVertex3f ( gfx_WorldSize#,gfx_SkyY#,gfx_WorldSize#) glTexCoord2f ( gfx_SkyX#+gfx_SkyOffset# ,-gfx_SkyX#+gfx_SkyOffset#) glVertex3f (-gfx_WorldSize#,gfx_SkyY#,gfx_WorldSize#) glEnd()
gfx_SkyOffset# = gfx_SkyOffset# + 0.00025 if (gfx_SkyOffset# > 1.0) then gfx_SkyOffset# =gfx_SkyOffset# -1.0 endif ' reset depth test glDepthFunc (GL_LESS) glDepthRange (0.0,1.0) gfx_PolyCounter=gfx_PolyCounter+1 return
gfx_SetDrawingMode: ' ############################ ' # Set OpenGL state drawing # '############################ glDisable (GL_BLEND) if gfx_blnUseLight=True then glEnable (GL_LIGHTING) else 'glDisable (GL_LIGHTING) endif
if gfx_blnUseTexture=True then glEnable (GL_TEXTURE_2D) glBindTexture (GL_TEXTURE_2D,gfx_Textures(gfx_TexBox)) else glDisable (GL_TEXTURE_2D) endif glColor4FV(gfx_BOXColor#) glDepthRange (0,1) return
gfx_SetShadowMode: ' ######################################## ' # Set OpenGL state for texture shadow # ' # ! gfx_Texture(0) must be ground ! # '######################################## glDisable (GL_LIGHTING) glDisable (GL_TEXTURE_2D) if gfx_blnUseTexture=True then glEnable (GL_BLEND) glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) endif glColor4f (0,0,0, 0.5) return
gfx_UseColor: ' ######################################### ' # create OpenGL material from gfx_Color # ' # ! gfx_Color#() must bet set ! # '######################################### 'glColor4FV(gfx_Color#) return
gfx_Image2Texture: ' ######################################## ' # create OpenGL texture from gfx_Image # ' # ! gfx_CurrentTexture must bet set ! # '######################################## glBindTexture (GL_TEXTURE_2D,gfx_Textures(gfx_CurrentTexture)) glPixelStorei (GL_UNPACK_SWAP_BYTES , 0) glPixelStorei (GL_UNPACK_ROW_LENGTH , 0) glPixelStorei (GL_UNPACK_ALIGNMENT , 1) glPixelStorei (GL_UNPACK_SKIP_ROWS , 0) glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0) glTexImage2D (GL_TEXTURE_2D, 0, 3,ImageWidth(gfx_Image), ImageHeight(gfx_Image), 0, ImageFormat(gfx_Image), GL_UNSIGNED_BYTE, gfx_Image) gluBuild2DMipmaps (GL_TEXTURE_2D, 3,ImageWidth(gfx_Image), ImageHeight(gfx_Image), ImageFormat(gfx_Image), ImageDataType(gfx_Image), gfx_Image) 'glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) 'glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) 'glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) DeleteImage (gfx_Image) return
gfx_SetTransform: ' ########################################### ' # set OpenGL transform matrix for drawing # ' # used: gfx_T#(3,3), R#(3,3), P#(3) # '########################################### gfx_T#(0,0)=R#(0,0):gfx_T#(1,0)=R#(0,1):gfx_T#(2,0)=R#(0,2):gfx_T#(3,0)=P#(0) gfx_T#(0,1)=R#(1,0):gfx_T#(1,1)=R#(1,1):gfx_T#(2,1)=R#(1,2):gfx_T#(3,1)=P#(1) gfx_T#(0,2)=R#(2,0):gfx_T#(1,2)=R#(2,1):gfx_T#(2,2)=R#(2,2):gfx_T#(3,2)=P#(2) gfx_T#(0,3)=0 :gfx_T#(1,3)=0 :gfx_T#(2,3)=0 :gfx_T#(3,3)=1 glPushMatrix() glMultMatrixd(gfx_T#) return
gfx_SetShadowTransform: ' ########################################### ' # set OpenGL transform matrix for shadow # ' # used: gfx_S#(3,3),gfx_LightP#(3) # '########################################### gfx_s#(0,0)=1 gfx_s#(1,1)=0 ' y gfx_s#(2,2)=1 gfx_s#(3,0)=-gfx_LightP#(0) gfx_s#(3,1)=0.1 gfx_s#(3,2)=-gfx_LightP#(2) gfx_s#(3,3)=1 glPushMatrix() glMultMatrixf(gfx_S#) return
gfx_DrawBox: ' ################################### ' # draw a unit box 1.0 x 1.0 x 1.0 # ' ################################### ' compile it only once if gfx_ListBox=0 then gfx_ListBox=glGenLists(1) glNewList(gfx_ListBox,GL_COMPILE)
glBegin(GL_QUADS) ' front glNormal3f (0,0,1) glTexCoord2f(0,0): glVertex3f(-0.5, 0.5, 0.5) glTexCoord2f(0,1): glVertex3f(-0.5, -0.5, 0.5) glTexCoord2f(1,1): glVertex3f( 0.5, -0.5, 0.5) glTexCoord2f(1,0): glVertex3f( 0.5, 0.5, 0.5) ' right glNormal3f (1,0,0) glTexCoord2f(0,0): glVertex3f( 0.5, 0.5, 0.5) glTexCoord2f(0,1): glVertex3f( 0.5, -0.5, 0.5) glTexCoord2f(1,1): glVertex3f( 0.5, -0.5, -0.5) glTexCoord2f(1,0): glVertex3f( 0.5, 0.5, -0.5) ' back glNormal3f (0,0,-1) glTexCoord2f(0,0): glVertex3f( 0.5, 0.5, -0.5) glTexCoord2f(0,1): glVertex3f( 0.5, -0.5, -0.5) glTexCoord2f(1,1): glVertex3f(-0.5, -0.5, -0.5) glTexCoord2f(1,0): glVertex3f(-0.5, 0.5, -0.5) ' left glNormal3f (-1,0,0) glTexCoord2f(0,0): glVertex3f(-0.5, 0.5, -0.5) glTexCoord2f(0,1): glVertex3f(-0.5, -0.5, -0.5) glTexCoord2f(1,1): glVertex3f(-0.5, -0.5, 0.5) glTexCoord2f(1,0): glVertex3f(-0.5, 0.5, 0.5) ' top glNormal3f (0,1,0) glTexCoord2f(0,0): glVertex3f(-0.5, 0.5, -0.5) glTexCoord2f(0,1): glVertex3f(-0.5, 0.5, 0.5) glTexCoord2f(1,1): glVertex3f( 0.5, 0.5, 0.5) glTexCoord2f(1,0): glVertex3f( 0.5, 0.5, -0.5) ' bottom glNormal3f (0,-1,0) glTexCoord2f(0,0): glVertex3f(-0.5, -0.5, 0.5) glTexCoord2f(0,1): glVertex3f(-0.5, -0.5, -0.5) glTexCoord2f(1,1): glVertex3f( 0.5, -0.5, -0.5) glTexCoord2f(1,0): glVertex3f( 0.5, -0.5, 0.5) glEnd() ' close the list glEndList() endif ' draw the compiled box glCallList(gfx_ListBox) gfx_PolyCounter=gfx_PolyCounter+6 return
|
|