Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Wanna know screen coordinates without matrix!

Author
Message
PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 10th Aug 2003 21:28 Edited at: 10th Aug 2003 21:29
Hi guys! Need help at this one:
I have a plain at certain Z coordinate and camera flowing above it, looking straight at this plain. Nor matrix used. Using a simple code i can retrive my mouse pointer coordinates according SHPERE object moving on that plain (following pointer accordingly). There is a problem: if i change camera's Z coordinate - this system crashes!! As you see i've tried to calculate camera.value coefficient - but i can't do it quiet precious! It only works with little Z deviations!
And if i pitch my camera it fails too! Any suggestions i'll read with pleasure!!!

This code also works if camera moving in any direction (but not rotating!!)

Here is the parts of the code:


Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 10th Aug 2003 22:47
` Get value for camera zooming
function getval()
res as float
oz=-300;oo#=1.7 <<<<<<<<******CHANGE SEMICOLON TO COLON*******
res=(oz-cam.z)*0.0035
cam.value=oo#-res
endfunction

as for the rest, this isn`t ZX81 basic, you can give your variables meaningful names, I am not too sure what you hope to do other than just track the cursor, the code is hard to follow, is it meant to track the cursor from above?

position camera object position x(object_number),0,object position z(object_number)

where object_number is the number of the object you use as the cursor

or does it track it like a security camera would?

point camera object position x(object_number),0,object position z(object_number)

or does it track like a security camera and keep the image zoomed in so it is clearly visible?

point camera object position x(object_number),0,object position z(object_number)
distance_to_object=sqrt(abs(camera position x()-object position x(object_number))^2+abs(camera position y()-object position y(object_number))^2)
set camera fov (1/distance_to_object)*45:rem this is a fudge, can`t recall scalar for this

or does it do it some other way?, cheers.

Mentor.

PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 11th Aug 2003 03:18
I'm sorry for so curious explanation! All i want - is to track XY coordinate on XY plain dimension according to my mouse pointer. I want to track the reflection of my mouse pointer on that plain
independently of camera position and angle! I'm using a system there a SPHERE object moves on the XY plain according my mouse pointer - i can find out coordinates of that SPHERE - therefore i can find out what coordinates corresponds my mouse pointers on-screen coordinates!
Z coordinate represent DEPTH value, so changing it i'm zooming in or out of my XY plain. Camera moving along this plain as standard strategic-game camera with capability to pitch and turn. I need all of this to show my UNIT object where to move on the map!

PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 12th Aug 2003 23:03
HEEEEYYY!!! PEOPLE!!!! Answer please! It's very important! Does anyone somehow done smth like this one??? Extracting 3D coords without a matrix? Damn, it's interesting enough - i'll post entire code if sombody will help me this this problem!

I'm think i need some formula? but i have not!! Still thinking...

Login to post a reply

Server time is: 2024-09-20 19:43:45
Your offset time is: 2024-09-20 19:43:45