Quick question about mousex() and mousey()

Blitz3D Forums/Blitz3D Beginners Area/Quick question about mousex() and mousey()

Verminaard(Posted 2003) [#1]
hi folks,
just a quickie this one. I am playing about with 3d now and am creating a FPS style camera that turns and pans in accordance with the mouse x and y.
I am storing the mousex and y co-ordinates in a temp variable then comparing these to teh new mouse x and y values on the next frame. if they change then the camera turns accordingly. IE:


Global tempmx = 0
Global xdiff = 0


While Not KeyDown( 1 )

xdiff = tempmx - MouseX()

TurnEntity camera,0,xdiff* speed,0

RenderWorld
Flip

tempmx = mousex()

wend

i have only cut the relevent bits from my code here, so i know there is no graphics set up etc in this example, but u get the idea :D. anyway, the problem is, when the mouse goes off the screen, it doesnt seem to register the mousex() anymore, so it will only turn about 45 degrees from full left to full right. Can anyone tell me how to compensate for this easily? I could write a small function to do it, but i was wondering if there was a built in command or such that could do it. Thanks for any help (again :D)
~V~

Oh, and while i am here, can anyone tell me what the units are that blitz measures 3d space in? ie:
translateEntity 0,5,0
5 what? feet, inches? elephants lol.... thanks


Binary_Moon(Posted 2003) [#2]
use mousexspeed and mouseyspeed instead of the mousex and mousey. And reposition the mouse (movemouse) in the center of the viewport before you updateworld

Graphics 320,240

SetBuffer BackBuffer()

Repeat

	Cls

	Text 10,10,MouseXSpeed()+" : "+MouseYSpeed()
	MoveMouse 160,120
	
	Flip

Until KeyHit(1)



Verminaard(Posted 2003) [#3]
thanks binary,
i'll give it a go now. what about blitz's measurement units? anyone know?

[EDIT]
Lo again :)
i have been trying the mousexspeed() like you suggested and that has fixed that problem, but now when i turn, the camera tilts left and right too :(, heres the snippet of code i think is causeing it:

TurnEntity camera,0,(MouseXSpeed()/2) * -speed,0

TurnEntity camera,(MouseYSpeed()/2),0,0

i think it might be because i am using the local co-ords to turn it, but i dont know how to use the global ones. what do i add the the end of the TurnEntity command to use them? I have tried ,0 and ,1 but although i got no error it made no diff. help plz :D thanks


morduun(Posted 2003) [#4]
Add
RotateEntity EntityPitch(camera), EntityYaw(camera), 0, True
directly after.


BlitzSupport(Posted 2003) [#5]
Verm: the units are whatever you want them to be. If it suits your game world, it's handy to consider them metres.

As you generally need to stay within -/+ 10000 units to avoid floating point accuracy 'issues', you might want to scale everything down in order to have a larger world and so you might consider the units, say, 10 metres... or kilometres/miles, or whatever. Elephants is a perfectly valid unit of measurement if you decide on a standard fixed size of elephant... :)


Verminaard(Posted 2003) [#6]
hmmm,
thanks. i was wondering because i use 3ds max to create my models, and it has the ability to set the units to metres,ft. inches etc, and i wanted to know how they....ummmm, measured up (sorry for the pun :D) with blitz's units. Nm tho, i'll go create some meshes and work it out myself. Thanks for all the help folks
~V~