Not New, just confused...

Blitz3D Forums/Blitz3D Beginners Area/Not New, just confused...

FBEpyon(Posted 2006) [#1]
Hello,

Been a while sense I used Blitz3D been playing around in BlitzMax, but anyways I was tyring to figure out how I could make a Camera System in Blitz3D that mimiced the one found in RollerCoaster Tycoon 3 (prospective with iso aspect). My attemps have failed, I have used a pivot to contorl the camera location and the rotation of the world, but I can seem to get the Mouse to move the camera, around the world like found in RCT3..

Bases I looking for..

- When Zoomed and looking at a object (Rotated and Facing Object) and holding the Right Mouse Button (MouseDown(2)) and moving the mouse forward. ( Im assuming that I use MouseYSpeed() ) it will move the camera forward into the object im looking at, and if Im Zoomed Out and rotated over the top of the object the camera will move Up, but not into the Object (World Terrain).

- Rotation works fine, but Im looking for a better way to do this if Im not doing it right already..

There isn't much else I can do with my engine until I get the camera right, I planning on making my own terrain system once the camera works and I can move around the screen to see the meshing system better...

Code Below THX!!


;these are to show the gobals different in code..

global Piv_Main 
global Cam_Main

global xangle#, yangle#
global msx#, msy#

Function CameraContorls()
	
	If xangle > 128  Or xangle < 128
	
		xangle = 128
		
	EndIf
	
	If MouseDown(3)
	
		MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
		
		yangle = yangle + (msx / 4)
		xangle = xangle - (msy / 4)
		
		RotateEntity Piv_Main,xangle,yangle,0
	
	EndIf
	
	If KeyDown(200) Then MoveEntity Piv_Main,0,-.1,0
	If KeyDown(208) Then MoveEntity Piv_Main,0,.1,0
	If KeyDown(205) Then MoveEntity Piv_Main,-.1,0,0
	If KeyDown(203) Then MoveEntity Piv_Main,.1,0,0
	
	MoveEntity Cam_Main,0,0,msz

End Function




_PJ_(Posted 2006) [#2]
You could combine the MoveEntity statements:

	MoveEntity Piv_Main,(Keydown(203)-Keydown(205))/10,(KeyDown(200)-Keydown(208))/10,0

Im not totally sure what ytou're trying to achieve because the " (prospective with iso aspect) " Jargon means nothing to me!

However, as a suggestion, try looking at the TranslateEntity commands instead of MoveEntity (for the up / down camera motion)


jfk EO-11110(Posted 2006) [#3]
I take it msx and msy are determined from the mouse speed somehow. Seems like you forgot to add that line there. However, I would suggest not to use a variable for the angle and then RotateEntity with the angle, but use TurnEntity instead, with msx and msy directly.


FBEpyon(Posted 2006) [#4]
Well

Im not using msx and msy directly Im putting that value into the anglex and angley...

but with a little help from a friend I have manage to get the camera to move right but its not always moving in the foward and back direction.. it follows the turn on the pivot..

 

Function CameraContorls()
	
	If MouseDown(3)
	
		MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
		
		angley = angley + (msx / 4)
		anglex = anglex - (msy / 4)
		
		RotateEntity Piv_Main,anglex,angley,0
	
	EndIf
	
	If MouseDown(2)
	
		MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
		
		targetx = targetx - (msx / 4)
		targetz = targetz - (msy / 4)
		
		PositionEntity Piv_Main,targetx,0,targetz
	
	End If
	
	MoveEntity Cam_Main,0,0,msz

End Function





octothorpe(Posted 2006) [#5]
Here's the camera code for my isometric tactics game. I remember being really happy with the UI, except for zooming, which is obviously a quick hack. There are a few magic numbers in there that I hadn't factored out yet. I believe this was tested only on 800x600.




FBEpyon(Posted 2006) [#6]
hmm thanks I will look into this, but whatz the old_mouse stuff I see nothing that goes into it


octothorpe(Posted 2006) [#7]
Apparently some globals I hadn't factored into a singleton yet. Oops.

global mouse_x, mouse_y, old_mouse_x, old_mouse_y
function update_game()
	marquee_update()	; flash the marquee

	old_mouse_x = mouse_x : old_mouse_y = mouse_y
	mouse_x = mousex() : mouse_y = mousey()



FBEpyon(Posted 2006) [#8]
so your using MouseX() and MouseY() as 2D cords and not 3D... I was using mouseSpeed would using MouseX() and Y be better..?

the only thing is your still missing functions like MouseMove() and what not, it hard to understand what you got going on in that...?


octothorpe(Posted 2006) [#9]
I believe MouseSpeed functions exactly the same under the hood as my method of keeping track of the previous mouse coordinates. Either way, make sure you only call the polling functions once per update.

MoveMouse() is a built-in Blitz3d function. constrain(x, min, max) is my own dirt-simple function which returns x, or min if x < min, or max if x > max.


FBEpyon(Posted 2006) [#10]
okay I know what your talking about now, I was being stupid.. but can you better explain your system there... I need a few more commenting in there being that Im not master the art of the all mighty sin and cos..

Let you know im using a Prosepctive mode, not a isometric using ortho

I changed the code a bit to use two pivots one for the rotation of the camera, and the other for the movment.. my question is now, how can I move in a single direction without following the rotation...

Not sure if I need to use something like a SIn and Cos in the code to keep track of the direction of the facing..

 ;Camera Test


Global mx#, my#, mz#
Global msx#, msy#, msz#
Global rx#, ry#, rz#

Graphics3D 640,480
SetBuffer BackBuffer()

Global MovePivot = CreatePivot()
PositionEntity MovePivot,0,0,0

Global RotatePivot = CreatePivot(MovePivot)
PositionEntity RotatePivot,0,0,0

Global Camera = CreateCamera(RotatePivot)
PositionEntity Camera,0,0,-10

PointEntity Camera,RotatePivot

Global Cube = CreateCube()
PositionEntity Cube,0,0,0

While Not KeyHit(1)

	AmbientLight 255,255,255
	
	UI_Camera()

	RenderWorld
	
		Text 0,0,rz
		Text 0,16,my
	
	Flip
	
Wend : End

Function UI_Camera()

	msx = MouseXSpeed()
	msy = MouseYSpeed()
	msz = MouseZSpeed()

	If MouseDown(2)
	
		MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
		
		mx = mx + (msx/4)
		my = 0
		mz = mz + (msy/4)
		
		PositionEntity MovePivot,mx,my,mz
				
	ElseIf MouseDown(3)
	
		MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
		
		rx = rx - (msy/4)
		ry = ry + (msx/4)
		rz = 0
		
		RotateEntity RotatePivot,rx,ry,rz
	
	EndIf

End Function 


AS you can see im trying to break the Rotation and Move apart so that you have a set direction you move.. like a compass you turn you move into the facing object, but the this system is just moving the MovePivot, it the mousexspeed and mouseyspeed and incress the MovePivots X,Z... how can I tell the X,Z of the Movepivot there has been a rotation but keep moving in the same direction as that of a 90* rotation...

I hope this makes better sense of what im trying ot do..