Hi,
I'm new in Spiderbasic and want to start using it with 3d, my question is : mesh animating is available or not yet ?
Thanks
!v_camera.keysUp.push(87); // W
!v_camera.keysDown.push(83); // S
!v_camera.keysLeft.push(65); // A
!v_camera.keysRight.push(68); // D
This feature exists with the current version :T4r4ntul4 wrote:I wanted to use WSAD keys to move the camera, i now use this piece of code: (but cant do that in SB BBjs) Maybe add a function that can do this with any key you specify?
;Camera movement : Redefine the camera keys
InitKey()
CameraMapKey(Camera, #PB_Key_Left, #PB_Key_A)
CameraMapKey(Camera, #PB_Key_Right, #PB_Key_D)
CameraMapKey(Camera, #PB_Key_Up, #PB_Key_W)
CameraMapKey(Camera, #PB_Key_Down, #PB_Key_S)
Yes No problem and useful ^-^T4r4ntul4 wrote:I have a few requests: ....
EnableExplicit
IncludeFile "babylon/babylon.sbi"
Global MouseDown, Scene, Camera, Material, Ground, Box
Declare LoadGame()
Declare MouseDown()
Declare MouseRelease()
Declare MouseMove()
Declare RenderGame()
;-Include
;Private
Procedure.f AngleRotation(Angle.f, Mode)
Protected n
If Mode = #PB_Absolute
n = Angle / 360
ProcedureReturn Angle - (360 * n)
ElseIf Mode = #PB_Relative
ProcedureReturn Angle
Else
ProcedureReturn -1
EndIf
EndProcedure
;Public
Procedure.f GetMeshRotX(Mesh, Mode = #PB_Absolute)
Protected Angle.f, n
!v_angle = v_mesh.rotation.x * 180 / Math.PI
n = Angle / 360
ProcedureReturn Angle - (360 * n)
EndProcedure
Procedure.f GetMeshRotY(Mesh, Mode = #PB_Absolute)
Protected Angle.f
!v_angle = v_mesh.rotation.y * 180 / Math.PI
ProcedureReturn AngleRotation(Angle, Mode)
EndProcedure
Procedure.f GetMeshRotZ(Mesh, Mode = #PB_Absolute)
Protected Angle.f
!v_angle = v_mesh.rotation.z * 180 / Math.PI
ProcedureReturn AngleRotation(Angle, Mode)
EndProcedure
Procedure.f GetCameraRotX(Camera, Mode = #PB_Absolute)
Protected Angle.f
!v_angle = v_camera.rotation.x * 180 / Math.PI
ProcedureReturn AngleRotation(Angle, Mode)
EndProcedure
Procedure.f GetCameraRotY(Camera, Mode = #PB_Absolute)
Protected Angle.f
!v_angle = v_camera.rotation.y * 180 / Math.PI
ProcedureReturn AngleRotation(Angle, Mode)
EndProcedure
Procedure.f GetCameraRotZ(Camera, Mode = #PB_Absolute)
Protected Angle.f
!v_angle = v_camera.rotation.z * 180 / Math.PI
ProcedureReturn AngleRotation(Angle, Mode)
EndProcedure
Procedure onMouseRelease(CallBack)
!v_bjscurrentscene.onPointerUp = function (evt) {
! v_callback(evt)
!}
EndProcedure
;-End Include
;-
UseModule BJS
InitEngine(@LoadGame())
Procedure LoadGame()
Scene = CreateScene()
If Scene
;Light and camera
CreateLight("Ambience", 0, 200, 0)
Camera = CreateCamera("camera", 0, 10, -20, #BJS_Free)
CameraLookAt(Camera, 0, 0, 0)
CameraBodySize(Camera, 1, 5, 1)
;Camera movement : Redefine the camera keys
InitKey()
CameraMapKey(Camera, #PB_Key_Left, #PB_Key_A)
CameraMapKey(Camera, #PB_Key_Right, #PB_Key_D)
CameraMapKey(Camera, #PB_Key_Up, #PB_Key_W)
CameraMapKey(Camera, #PB_Key_Down, #PB_Key_S)
;Ground
Ground = CreateGround("ground", 100, 100)
Material = CreateMaterial("Grass")
SetMaterialTexture(Material, #BJS_Diffuse, LoadTexture("data/textures/grass.png"))
ScaleMaterial(Material, 5, 5)
SetMeshMaterial(Ground, Material)
;Box
Box = CreateBox("My box", 4, 4, 4)
Material = CreateMaterial("crate")
SetMaterialTexture(Material, #BJS_Diffuse, LoadTexture("data/textures/crate.png"))
SetMeshMaterial(Box, Material)
MoveMesh(Box, 0, 2, 0)
onMouseDown(@MouseDown())
onMouseRelease(@MouseRelease())
onMouseMove(@MouseMove())
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure MouseDown()
MouseDown = #True
EndProcedure
Procedure MouseRelease()
MouseDown = #False
EndProcedure
Procedure MouseMove()
If MouseDown
Debug "Camera Rotation (x / y) " + StrF(GetCameraRotX(Camera), 2) + " / " + StrF(GetCameraRotY(Camera), 2)
EndIf
EndProcedure
Procedure RenderGame()
If KeyPushed(#PB_Key_Left)
RotateMesh(Box, 0, -2.5, 0, #PB_Relative)
Debug "Mesh Rotation (Y) " + StrF(GetMeshRotY(Box), 2)
EndIf
If KeyPushed(#PB_Key_Right)
RotateMesh(Box, 0, 2.5, 0, #PB_Relative)
Debug "Mesh Rotation (Y) " + StrF(GetMeshRotY(Box), 2)
EndIf
RenderWorld()
EndProcedure
Users browsing this forum: No registered users and 1 guest