Code: Select all
InitEngine3D()
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"cam",#PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home+"examples/3d/Data/Textures",#PB_3DArchive_FileSystem)
Parse3DScripts()
#mascarapick=32
#mascaravisivilidad=32
; Luz, suelo, cielo y camara
luz.i=CreateLight(#PB_Any,RGB(160,160,254),4,4,-2,#PB_Light_Point)
camara.i=CreateCamera(#PB_Any,0,0,100,100,#mascaravisivilidad):pivotcamara.i=CreateNode(#PB_Any,0,0,0):CameraRange(camara.i,0.1,1000):CameraBackColor(camara.i,$181111)
AttachNodeObject(pivotcamara.i,CameraID(camara.i)):MoveCamera(camara.i,0,0,4,#PB_Absolute):RotateNode(pivotcamara.i,0,0,0,#PB_Relative)
; Texturas
varillatextura.i=LoadTexture(#PB_Any,"soil_wall.jpg")
; Materiales
varillamaterial.i=CreateMaterial(#PB_Any,TextureID(varillatextura.i))
; Entidades
varillamalla.i=CreateCube(#PB_Any,0.8)
; TransformMesh(varillamalla.i,0,0,0,1,1,1,0,0,0,0)
varilla.i=CreateEntity(#PB_Any,MeshID(varillamalla.i),MaterialID(varillamaterial.i),0,0,0,#mascarapick,#mascaravisivilidad)
Repeat
ExamineMouse():ExamineKeyboard()
CursorX.f=WindowMouseX(0):CursorY.f=WindowMouseY(0)
mdx.f=MouseDeltaX()/200:mdy.f=MouseDeltaY()/200:mdz.f=MouseWheel()/10
If KeyboardPushed(#PB_Key_LeftControl); <- move eye point
If mdx Or mdy Or mdz
If MouseButton(#PB_MouseButton_Right)
MoveNode(pivotcamara,mdx,-mdy,0,#PB_Relative|#PB_Local); <- How to use to displace the node relatively to its current orientation?. I find no way for it!
Else
RotateNode(pivotcamara,-mdy*60,-mdx*60,0,#PB_Relative)
If mdz
MoveCamera(camara,0,0,-mdz,#PB_Relative)
EndIf
EndIf
EndIf
ElseIf KeyboardPushed(#PB_Key_1)
MoveCamera(camara.i,0,0,4,#PB_Absolute); <- correct
ElseIf KeyboardPushed(#PB_Key_2)
MoveCamera(camara.i,0,0,4,#PB_Parent|#PB_Absolute); <- don't understand the behaviour of this one, looks like a non absolute movement
ElseIf KeyboardPushed(#PB_Key_3)
MoveCamera(camara.i,0,0,4,#PB_Local|#PB_Absolute); <- same here
ElseIf KeyboardPushed(#PB_Key_4)
MoveCamera(camara.i,0,0,4,#PB_World|#PB_Absolute); <- same here
ElseIf KeyboardPushed(#PB_Key_F3); <- restart
MoveNode(pivotcamara,0,0,0,#PB_Absolute); <- again!, with #PB_World|#PB_Absolute it does not work!!
RotateNode(pivotcamara.i,0,0,0,#PB_Absolute)
MoveCamera(camara.i,0,0,4,#PB_Absolute)
EndIf
TimeSinceLastFrame.i=RenderWorld(50)
FlipBuffers():Delay(9)
Until KeyboardPushed(#PB_Key_Escape)
CloseWindow(0)
Code: Select all
bolamalla.i=CreateSphere(#PB_Any,1,5,10)
TransformMesh(bolamalla.i,0.0,0.0,0.0,0.1,0.1,0.1,0,0,0,0)
Code: Select all
bolamalla.i=CreateSphere(#PB_Any,0.1,5,10)