Re: MP3D Engine Alpha 32
Posted: Sun Nov 02, 2014 8:43 pm
Yea, where is MPZ anyway?
http://www.purebasic.com
https://www.purebasic.fr/english/
N_Gnom wrote: i don´t need an installer.
only a working mp3d.
Code: Select all
MP_Graphics3D(640,480,0,3)
camera=MP_CreateCamera()
;MP_EntityLookAt(camera,0,0,3) ; <- Un-remark this line to see a MP_MoveEntity(camera) bug!
light=MP_CreateLight(1)
mesh=MP_CreateCube()
MP_PositionEntity(Mesh,0,0,3)
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Right):MP_MoveEntity(camera,0.01,0,0)
ElseIf MP_KeyDown(#PB_Key_Left):MP_MoveEntity(camera,-0.01,0,0)
ElseIf MP_KeyDown(#PB_Key_Up):MP_MoveEntity(camera,0,0.01,0)
ElseIf MP_KeyDown(#PB_Key_Down):MP_MoveEntity(camera,0,-0.01,0)
ElseIf MP_KeyDown(#PB_Key_A):MP_MoveEntity(camera,0,0,0.01)
ElseIf MP_KeyDown(#PB_Key_Z):MP_MoveEntity(camera,0,0,-0.01)
EndIf
MP_RenderWorld()
MP_Flip()
Wend
Code: Select all
MP_Graphics3D(640,480,0,3)
camera=MP_CreateCamera()
MP_PositionEntity(camera,0,0,0)
Debug "Camera Pitch/Yaw/Roll"
Debug MP_EntityGetPitch(camera)
Debug MP_EntityGetYaw(camera)
Debug MP_EntityGetRoll(camera)
MP_EntityLookAt(camera,0,0,3) ; <- Un-remark this line to see what happens
Debug "Camera Pitch/Yaw/Roll after lookat"
Debug MP_EntityGetPitch(camera)
Debug MP_EntityGetYaw(camera)
Debug MP_EntityGetRoll(camera)
MP_TurnEntity(camera, -90, -90,0) ; Now you turn the camera back to 0, but the relative space coords are different too...
light=MP_CreateLight(1)
mesh=MP_CreateCube()
MP_PositionEntity(Mesh,0,0,3)
While MP_KeyUp(#PB_Key_Escape) And WindowEvent()<>#PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Right):MP_MoveEntity(camera,0.01,0,0)
ElseIf MP_KeyDown(#PB_Key_Left):MP_MoveEntity(camera,-0.01,0,0)
ElseIf MP_KeyDown(#PB_Key_Up):MP_MoveEntity(camera,0,0.01,0)
ElseIf MP_KeyDown(#PB_Key_Down):MP_MoveEntity(camera,0,-0.01,0)
ElseIf MP_KeyDown(#PB_Key_A):MP_MoveEntity(camera,0,0,0.01)
ElseIf MP_KeyDown(#PB_Key_Z):MP_MoveEntity(camera,0,0,-0.01)
EndIf
MP_RenderWorld()
MP_Flip()
Wend
Code: Select all
UsePNGImageDecoder()
Define Direction.I
Define ImageSize.I
OpenWindow(0, 200, 100, 400, 320, "Multi Textured OpenGL Cube demo")
SetWindowColor(0, 0)
OpenGLGadget(0, 0, 0, WindowWidth(0) , WindowHeight(0))
For i=0 To 5
LoadImage(i, Str(i)+".bmp")
Next
Direction = -1
Dim *image(5)
Dim *imageHeader(5)
For i=0 To 5
If ReadFile(0, Str(i)+".bmp") = 0
MessageRequester("Error", "Loading of texture image failed!")
End
EndIf
*imageHeader(i) = AllocateMemory(54)
ReadData(0, *imageHeader(i), MemorySize(*imageHeader(i)))
ImageSize = PeekL(*imageHeader(i) + 34)
FreeMemory(*imageHeader(i))
*image(i) = AllocateMemory(ImageSize)
ReadData(0, *image(i), ImageSize)
Next
CloseFile(0)
Dim texturePTR(5)
glGenTextures_(6, @texturePTR())
For i = 0 To 5
glBindTexture_(#GL_TEXTURE_2D, texturePTR(i))
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST)
;gluBuild2DMipmaps_(#GL_TEXTURE_2D, 3, 512, 512, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, *image(i))
glTexImage2D_(#GL_TEXTURE_2D, 0, 3, ImageWidth(i), ImageHeight(i), 0, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, *image(i))
FreeMemory(*image(i))
Next
;glMatrixMode_(#GL_PROJECTION)
gluPerspective_(30.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 500.0)
Repeat
xRotation.f + 1.5
yRotation.f - 2.5
zRotation.f + 3.5
glMatrixMode_(#GL_MODELVIEW)
glEnable_(#GL_CULL_FACE)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(0, 0, -7.5)
glRotatef_(xRotation, 1, 0, 0)
glRotatef_(yRotation, 0, 1, 0)
glRotatef_(zRotation, 0, 0, 1)
glEnable_(#GL_TEXTURE_2D)
glBindTexture_(#GL_TEXTURE_2D, texturePTR(0))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(1, 1, -1)
glTexCoord2f_(0, 1) : glVertex3f_(-1, 1, -1)
glTexCoord2f_(0, 0) : glVertex3f_(-1, 1, 1)
glTexCoord2f_(1, 0) : glVertex3f_(1, 1, 1)
glEnd_()
glBindTexture_(#GL_TEXTURE_2D, texturePTR(1))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(-1, 1, 1)
glTexCoord2f_(0, 1) : glVertex3f_(-1, 1, -1)
glTexCoord2f_(0, 0) : glVertex3f_(-1, -1, -1)
glTexCoord2f_(1, 0) : glVertex3f_(-1, -1, 1)
glEnd_()
glBindTexture_(#GL_TEXTURE_2D, texturePTR(2))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(1, 1, 1)
glTexCoord2f_(0, 1) : glVertex3f_(-1, 1, 1)
glTexCoord2f_(0, 0) : glVertex3f_(-1, -1, 1)
glTexCoord2f_(1, 0) : glVertex3f_(1, -1, 1)
glEnd_()
glBindTexture_(#GL_TEXTURE_2D, texturePTR(3))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(-1, 1, -1)
glTexCoord2f_(0, 1) : glVertex3f_(1, 1, -1)
glTexCoord2f_(0, 0) : glVertex3f_(1, -1, -1)
glTexCoord2f_(1, 0) : glVertex3f_(-1, -1, -1)
glEnd_()
glBindTexture_(#GL_TEXTURE_2D, texturePTR(4))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(1, 1, -1)
glTexCoord2f_(0, 1) : glVertex3f_(1, 1, 1)
glTexCoord2f_(0, 0) : glVertex3f_(1, -1, 1)
glTexCoord2f_(1, 0) : glVertex3f_(1, -1, -1)
glEnd_()
glBindTexture_(#GL_TEXTURE_2D, texturePTR(5))
glBegin_(#GL_QUADS)
glTexCoord2f_(1, 1) : glVertex3f_(1, -1, 1)
glTexCoord2f_(0, 1) : glVertex3f_(-1, -1, 1)
glTexCoord2f_(0, 0) : glVertex3f_(-1, -1, -1)
glTexCoord2f_(1, 0) : glVertex3f_(1, -1, -1)
glEnd_()
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
Until WindowEvent() = #PB_Event_CloseWindow
glDeleteTextures_(6, @texturePTR())