Please help, How would you do this?
Blitz3D Forums/Blitz3D Programming/Please help, How would you do this?
| ||
| i need help on how you would do this on blitz3d.. using the mouse control to turn the head of model(b3d) the game is in 3rd person perspective *example i want the head to look up on a certain angle using my mouse |
| ||
| I would click on the search tab above, select code archives, type the term mouselook into the box and click the Search button. |
| ||
| Get the child bone/pivot of the neck/head of the model. Use turnentity/rotateentity after the updateworld command to rotate the bone. Rotate the bone by a calculated amount based on mouse input. That's a start...play around with it. |
| ||
| What Matty said, and for more infos search the forum about FindChild() |
| ||
| even if the b3d model is animated? i tried doing this but the 3d model stick to its animation |
| ||
| If I remember correctly, you have to change the position of the head after UpdateWorld() but before RenderWorld(). |
| ||
; initialize graphics mode
Graphics3D 800, 600, 32,1
; hide mouse pointer
HidePointer()
; create camera
camera = CreateCamera()
PositionEntity camera, 0, 2, -10
; loading skinned mesh
kuznec = LoadAnimMesh("../../../media/meshes/kuznec.b3d")
head = FindChild(kuznec, "Bone10")
RotateEntity kuznec, 0, 180, 0
; extract animation sequences
ExtractAnimSeq(kuznec, 99, 129)
; play idle animation
Animate kuznec, 1, 1.0, 1
Animate kuznec, 0, 1.0, 0, 0, "Bone10" ;disable animation for head
; create target sphere
target = CreateSphere()
ScaleEntity target, 0.1, 0.1, 0.1
PositionEntity target, 3, 2, -2
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
; main program loop
While Not KeyDown(KEY_ESCAPE)
; target control
MoveEntity target, MouseXSpeed() * 0.05, -(MouseYSpeed() * 0.05), 0.0
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
; check borders
If (EntityX(target) > 5.0) Then PositionEntity target, 5, EntityY(target), 0
If (EntityX(target) < -5.0) Then PositionEntity target, -5, EntityY(target), 0
If (EntityY(target) > 6.0) Then PositionEntity target, EntityX(target), 6, 0
If (EntityY(target) < -2.0) Then PositionEntity target, EntityX(target), -2, 0
; point head
PointEntity head, target
TurnEntity head, 0, -90, 90 ; fixing axis
; update animations
UpdateWorld()
; render scene
RenderWorld()
; draw texts
Text 10, 10, "FPS: " + FPS()
Text 10, 30, "Move mouse"
; switch back buffer
Flip()
Wend
![]() ;) |
| ||
; initialize graphics mode
Graphics3D 800, 600, 32,1
; hide mouse pointer
HidePointer()
; create camera
camera = CreateCamera()
PositionEntity camera, 0, 2, -10
; loading skinned mesh
kuznec = LoadAnimMesh("../../../media/meshes/kuznec.b3d")
head = FindChild(kuznec, "Bone10")
RotateEntity kuznec, 0, 180, 0
; extract animation sequences
ExtractAnimSeq(kuznec, 99, 129)
; play idle animation
Animate kuznec, 1, 1.0, 1
Animate kuznec, 0, 1.0, 0, 0, "Bone10" ;disable animation for head
; create target sphere
target = CreateSphere()
ScaleEntity target, 0.1, 0.1, 0.1
PositionEntity target, 3, 2, -2
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
; main program loop
While Not KeyDown(KEY_ESCAPE)
; target control
MoveEntity target, MouseXSpeed() * 0.05, -(MouseYSpeed() * 0.05), 0.0
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
; check borders
If (EntityX(target) > 5.0) Then PositionEntity target, 5, EntityY(target), 0
If (EntityX(target) < -5.0) Then PositionEntity target, -5, EntityY(target), 0
If (EntityY(target) > 6.0) Then PositionEntity target, EntityX(target), 6, 0
If (EntityY(target) < -2.0) Then PositionEntity target, EntityX(target), -2, 0
; point head
PointEntity head, target
TurnEntity head, 0, -90, 90 ; fixing axis
; update animations
UpdateWorld()
; render scene
RenderWorld()
; draw texts
Text 10, 10, "FPS: " + FPS()
Text 10, 30, "Move mouse"
; switch back buffer
Flip()
Wend
![]() ;) |
| ||
| @Yue thanks!!!! |
