I've recently started by using PureBasic so i'm still experimenting with it and until now, I like very much.
However, I got some issues to bypass and one of them is related to terrain & camera rotation.
This is what I have coded until now:
Code: Select all
;
; ------------------------------------------------------------
;
; DeXtr0's Terrain Test
;
; based on examples purebasic
; ------------------------------------------------------------
UsePNGImageDecoder()
TerrainHeight = 30
TerrainZPos = -10
YPos = 0
XRotateSpeed = 3
YRotateSpeed = 0
If InitEngine3D()
InitSprite()
InitSprite3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
OpenScreen(800,600,32,"DeXtr0")
CatchSprite(10, ?Pic_Logo, 0)
ClearScreen(255,255,255)
CreateMaterial (0, LoadTexture(0, "dex_terrain_texture.jpg"))
AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1)
CreateTerrain("terrain.png", MaterialID(0), 4, 0.6, 4, 4)
;------------------------------------------------
; Create camera , width = 300, heigh = 300
;------------------------------------------------
CreateCamera(0, 0, 0, 100, 100)
;------------------------------------------------
; Set initial camera position
;------------------------------------------------
;CameraLocate(0, 128, 25, 128)
CameraLocate(0, 128, 30, 400)
MoveCamera (0, 0, TerrainHeight, TerrainZPos)
Repeat
;------------------------------------------------
; Rotate camera
;------------------------------------------------
RotateCamera(0, XRotateSpeed, YPos, YRotateSpeed)
RenderWorld()
;------------------------------------------------
; Show logo
;------------------------------------------------
DisplayTransparentSprite(10,90,-50)
FlipBuffers()
If GetAsyncKeyState_(#VK_ESCAPE)
Break
EndIf
ForEver
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
DataSection
Pic_Logo: IncludeBinary "Data/dextro24gc.png"

If you should run this code the terrain is rotation and the logo is shown above, which is correct.
However the rotation effect gives me the feeling that I'm in the center of the rotation (hard to explain?).
The effect I'm trying to code is that I see the terrain rotating but further away in the depth, so I don't want to be in the center of the rotation but the center of the rotation should be further away into the screen (I think Z-axis but i'm not sure

Is anybody able to help me a hand with this one ?
The whole source, incl. pictures can be downloaded here:
http://www.glftpdsitemanager.com/downlo ... ources.zip
All help is appreciated...
Regards,
DeXtr0