Posted: Fri Jul 01, 2005 5:12 pm
Stefan, this example is another way to see what's happening with current S3DR lib.
At the left side there is a normal cube mesh rotated 45 degrees over X axis.
At right side there is a cube mesh design with a 45 degrees over X axis.
Then, when both figures are displayed you can rotate it over Y axis (with cursor keys left and right) and then you can see that something is wrong:Hope you see it.
At the left side there is a normal cube mesh rotated 45 degrees over X axis.
At right side there is a cube mesh design with a 45 degrees over X axis.
Then, when both figures are displayed you can rotate it over Y axis (with cursor keys left and right) and then you can see that something is wrong:
Code: Select all
#PI=3.14159265
InitSprite():InitSprite3D():InitKeyboard()
OpenScreen(1024,768,32,"")
UsePNGImageDecoder()
LoadSprite(1,"yourspritehere",#PB_Sprite_Texture); <- a 256x256x8 graph image should be good
S3DR_CreateZBuffer()
;Create the cube
Start3D():S3DR_BeginReal3D()
S3DR_StartCreateMesh()
S3DR_CreateMesh_AddQuad(-1, 1, 1,-1, 1,-1,-1,-1, 1,-1,-1,-1);<-cara izquierda
S3DR_CreateMesh_AddQuad( 1,-1, 1,-1,-1, 1, 1,-1,-1,-1,-1,-1);<-cara de abajo
S3DR_CreateMesh_AddQuad(-1, 1, 1, 1, 1, 1,-1, 1,-1, 1, 1,-1);<-cara de arriba
S3DR_CreateMesh_AddQuad(1,1,1,-1,1,1,1,-1,1,-1,-1,1);<-cara de atras
S3DR_CreateMesh_AddQuad(-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1);<-cara de enfrente
S3DR_CreateMesh_AddQuad( 1, 1,-1, 1, 1, 1, 1,-1,-1, 1,-1, 1);<-cara derecha
Cube=S3DR_StopCreateMesh()
S3DR_EndReal3D():Stop3D()
;Create a cube rotated 45 degrees over X axis
Start3D():S3DR_BeginReal3D()
S3DR_StartCreateMesh()
S3DR_CreateMesh_AddQuad(-1,Sqr(2),0,-1,0,-Sqr(2),-1,0,Sqr(2),-1,-Sqr(2),0);<-cara izquierda
S3DR_CreateMesh_AddQuad(1,0,Sqr(2),-1,0,Sqr(2),1,-Sqr(2),0,-1,-Sqr(2),0);<-cara de abajo
S3DR_CreateMesh_AddQuad(-1,Sqr(2),0,1,Sqr(2),0,-1,0,-Sqr(2),1,0,-Sqr(2));<-cara de arriba
S3DR_CreateMesh_AddQuad(1,Sqr(2),0,-1,Sqr(2),0,1,0,Sqr(2),-1,0,Sqr(2));<-cara de atras
S3DR_CreateMesh_AddQuad(-1,0,-Sqr(2),1,0,-Sqr(2),-1,-Sqr(2),0,1,-Sqr(2),0);<-cara de enfrente
S3DR_CreateMesh_AddQuad(1,0,-Sqr(2),1,Sqr(2),0,1,-Sqr(2),0,1,0,Sqr(2));<-cara derecha
Cube2=S3DR_StopCreateMesh()
S3DR_EndReal3D():Stop3D()
Sprite3DQuality(1)
Repeat
ExamineKeyboard()
Start3D():S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(0);<- clear screen in black color
StartDrawing(ScreenOutput()):Locate(400,200):DrawText("Rotating over world Y axis:")
Locate(320,240):DrawText("bad done:")
Locate(640,240):DrawText("well done:"):StopDrawing()
If KeyboardPushed(#PB_Key_Right):angleY.f-0.02:EndIf; <- rotate over Y axis of the world ?
If KeyboardPushed(#PB_Key_Left):angleY.f+0.02:EndIf; <- rotate over Y axis of the world ?
S3DR_SelectTexture(1)
;********************** DRAWING ****************************
; The cube at the left side, a normal cube mesh rotated 45 degrees over X axis:
S3DR_DrawMesh(Cube,-2,0,16,-#PI/4,angleY.f,0)
; The cube at the right side, a cube mesh designed rotating 45 degrees over X axis:
S3DR_DrawMesh(Cube2,2,0,16,0,angleY.f,0)
;********************************************************
S3DR_EndReal3D():Stop3D()
FlipBuffers():Delay(16)
Until KeyboardPushed(#PB_Key_Escape)
S3DR_FreeMesh(Cube2); Don't forget to free the Mesh.
S3DR_FreeMesh(Cube); Don't forget to free the Mesh.