Camera scroll

Blitz3D Forums/Blitz3D Beginners Area/Camera scroll

airborne(Posted 2012) [#1]
so I'm pretty new to programming in blitz, and I've been searching how to make the camera scroll in and out in a 3rd person view. It was my original intent to make it scroll using the mouse wheel, but I don't know if that's possible. Even using page up page down to scroll in and out at this point would help immensely... anyone have any experience on this? Current code is as follows:

;opening settings
Graphics3D 1240,800,16,2
SetBuffer BackBuffer()
HidePointer

;camera and light settings
light=CreateLight()
camera=CreateCamera()
AmbientLight 50,50,50
RotateEntity light,90,0,0

;create plane
;ground
plane=CreatePlane()
grass_tex=LoadTexture( "texture2.jpg" )
EntityTexture plane,grass_tex
PositionEntity plane,0,-1,0

;sky
sky = CreateSphere(50)
EntityParent sky,sphere
pitch#=pitch# + 1
RotateEntity sky,pitch#,yaw#,roll#
PositionEntity sky,0,50,0
FlipMesh sky
ScaleEntity sky,900,900,900
sky_tex = LoadTexture("sky_107.bmp")
EntityTexture sky,sky_tex
EntityFX sky,1
pitch#=pitch# + 1
RotateEntity sky,pitch#,yaw#,roll#


;player object
cylinder=CreateCylinder()
PositionEntity cylinder,0,0,5
EntityColor cylinder,255,255,255
cone=CreateCone()
PositionEntity cone,0,0,7
RotateEntity cone,90,0,0
ScaleEntity cone,0.5,2,0.5
EntityColor cone,50,100,255
EntityParent cone,cylinder


;directional key and mouse move
While Not KeyDown( 1)

If KeyDown(205)=True Then TurnEntity cylinder,0,-1,0
If KeyDown(203)=True Then TurnEntity cylinder,0,1,0
If KeyDown(208)=True Then MoveEntity cylinder,0,0,-0.05
If KeyDown(200)=True Then MoveEntity cylinder,0,0,0.05

PositionEntity camera,EntityX(cylinder),EntityY(cylinder),EntityZ(cylinder)
MoveEntity camera,0,0,-5



mxs# = mxs# + MouseXSpeed()
mys# = mys# + MouseYSpeed()

If msx# > 45 Then mxs# = 0
If msx# < 0 Then Msx# = 45

If Mys# > 45 Then mys# = 45
If mys# < -45 Then mys# = -45

RotateEntity camera,mys#,-mxs,0
MoveMouse 100,100
If MouseDown(3) Then MoveEntity cylinder,0,0,0.5


RenderWorld
Text 10,10, "x: " + EntityX(camera) +" y: " + EntityY(camera) + " z: " + EntityZ(camera)
Flip
Wend
End


airborne(Posted 2012) [#2]
problem solved... if keydown blah blah... move entity camera desired amount :)


Imperium(Posted 2012) [#3]
Glad you figured it out. I love it when I solve problems myself though it's a sort of a rare event.

Any screenies of what you're working on? :)


airborne(Posted 2012) [#4]
seems more and more common for me lately lol... not much chatter on these forums as i suppose there used to be...

As for game images? I have my first zone of my game up and operating normally within basic functionality... It is still lacking in a few aspects, concerning things such as trees/bushes/flowers. All my scenery I write up in google sketchup, the problem i encounter is that any additional things i add such as 3d trees are too large for blitz to load properly and smoothly (file content is too large i assume)

The biggest hurdle I'm staring down right now is being able to walk into a door and have it load a room (such as an item store)the code required to do this is giving me no end of headaches, been beating my face on my computer desk for roughly two days now (maybe this explains the headaches? :))

If you're interested in what it looks like, perhaps when i get it running a little better i'll post a youtube vid, let me know...

And thanks for the response I was starting to think these forums were nothing more than a barren wasteland of text archives now days lol.


airborne(Posted 2012) [#5]
I figured this would be an easier way to test code to make this function work, before hack and slashing the code i have, so i'm running a test program... basically green floor/black sky there is 2 different colored cubes... the intent of this experiment is that when the player object (sphere) collides with 1 of the cube entities, then the sphere object will be moved/transferred/teleported to the other sphere that wasn't contacted. I was thinking this could be a idea for positioning certain rooms outside of the normal open world play area, once a door in this area was contacted, the player object could therefore be teleported into that room outside of the play area, when the player touches the door inside this room (outside normal area) the player would then be teleported back down to the main open world. I don't know if this is the best way to perform this, but it seems to be the most logical. I don't want to have these rooms open with the rest of the world, as it would be more demanding on blitz memory. So essentially, i could unload/load new environments on room location change saving valuable information.

This is what i'm doing with the test program:

;opening settings
Graphics3D 1240,800,16,2
SetBuffer BackBuffer()
HidePointer

;camera and light settings
light=CreateLight()
camera=CreateCamera()
AmbientLight 50,50,50
RotateEntity light,90,0,0

;Misc. Object transparency/gravity/collision
alpha#=1
type_plane=1
type_player=2
type_scenery=3

;create plane
;ground
plane=CreatePlane()
PositionEntity plane,0,-1,0
EntityColor plane,0,255,0
EntityType plane,type_scenery
EntityRadius plane,2
EntityBox plane,-2,-2,-2,4,4,4

;player object
sphere=CreateSphere()
ScaleEntity sphere,0.1,0.1,0.1
EntityColor sphere,255,0,0
PositionEntity sphere,30,0,0
PositionEntity camera,30,0,0
ScaleEntity sphere,0.1,0.1,0.1
EntityParent camera,sphere
EntityType sphere,type_player
EntityType camera,Type_player

;building objects
cube=CreateCube()
PositionEntity cube,0,0,0
EntityType cube,type_scenery
EntityColor cube,255,0,0

cube1=CreateCube()
PositionEntity cube1,25,0,0
EntityType cube1,Type_scenery
EntityColor cube1,0,0,255

;directional key and mouse move
While Not KeyDown(1)
If KeyDown(32)=True Then TurnEntity sphere,0,-1,0
If KeyDown(30)=True Then TurnEntity sphere,0,1,0
If KeyDown(31)=True Then MoveEntity sphere,0,0,-0.05
If KeyDown(17)=True Then MoveEntity sphere,0,0,0.05
If KeyDown(207)=True Then MoveEntity camera,0,0,1
If KeyDown(199)=True Then MoveEntity camera,0,0,-1
If KeyDown(57)=True Then MoveEntity sphere,0,1,0
If KeyDown(208)=True Then MoveEntity sphere,0,-1,0

mxs# = mxs# + MouseXSpeed()
mys# = mys# + MouseYSpeed()

If msx# > 90 Then mxs# = 0
If msx# < 0 Then Msx# = 90

If Mys# > 45 Then mys# = 45
If mys# < -45 Then mys# = -45

RotateEntity camera,mys#,-mxs,0
MoveMouse 100,100
If MouseDown(3) Then MoveEntity sphere,0,0,0.5

;Set Collision Method and Response Values
method=2
response=2

method_info$="ellipsoid-to-polygon"
response_info$="slide1"

MoveEntity sphere,0,-0.50,0 ;Gravity


;Change Collision Method
If KeyHit( 50 )=True
method=method+1
If method=4 Then method=1
If method=1 Then method_info$="ellipsoid-to-sphere"
If method=2 Then method_info$="ellipsoid-to-polygon"
If method=3 Then method_info$="ellipsoid-to-box"
EndIf

;Change Collision Response
If KeyHit( 19 )=True
response=response+1
If response=4 Then response=1
If response=1 Then response_info$="stop"
If response=2 Then response_info$="slide1"
If response=3 Then response_info$="slide2"
EndIf
;Enable collisions between type_character and type_ground
Collisions type_player,type_player,2,2


;Enable collisions between type_character and type_scenery
Collisions type_player,type_scenery,method,response

;Enable player transfers between different zones/rooms
If EntityCollided with (cube1)=True Then MoveEntity (cube)
If EntityCollided with (cube)=True Then MoveEntity (cube1)

UpdateWorld
RenderWorld
Text 10,10, "x: " + EntityX(sphere) +" y: " + EntityY(sphere) + " z: " + EntityZ(sphere)
Flip
Wend
End


airborne(Posted 2012) [#6]
P.S. the sphere is located ontop of the camera due to a careless set location of the camera, to see the sphere simply use the home/end buttons to scroll camera in/out. This also presents another issue i'm facing that the camera can move independently from the sphere even though it is the parent object