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.

Code Snippets / rts camera + mouse coordinates on a flat matrix

Author
Message
JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 31st May 2003 00:04
Since yesterday D-M@n and I have been trying to work out the maths for getting the matrix coordinates of the mouse. It was quite a frustrating time, but after I've actually built a model out of some sticks I finaly got it (I couldn't imagine the scene by only drawing it out on paper... ).

- leftclick to position the sphere under the mouse
- rightclick and move to rotate the camera
- use the cursorkeys or move the mouse to the edges of the screen to move the camera
- hold both mouse buttons and move to zoom in or out
- press "+" or "-" to change the field of view
Smile and be happy, things could be worse!
So I smiled and was happy, and things got worse...
Red general
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 1st Jun 2003 00:23
Here is a similar rts thing, I will test both to see which works best.

This comes directly from my old mark 1 model for rts. You will need a tank model, texture for matrix and a sound for the tank. It might be helpful. Enjoy.


RED GENERAL


By the way later versions can be found on this forum in different places.

My computer melts regulary - perhaps it likes being fondue
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 1st Jun 2003 01:13
What you made is something different from what we made.
You created a clickable zone around the selectable object.
Think of a tree with wide branches.
If you click next to the stem, your tree will be selected.
With our function you can easily click next to it, without it beeing selected, because we calculate the "real" 3D coordinates.

God is real, unless declared integer.
TeePee
21
Years of Service
User Offline
Joined: 18th Apr 2003
Location: Australia
Posted: 26th Jun 2003 03:26
hey fellas

im gonna start making a game soon but i need to do all the planning and stuff first of course. i cant tell you what the game is yet coz its top secret lol but the code here is the exact code that ill be needing. its perfect in everyway except one. it only deals with a flat matrix. with my game i need it to deal with a matrix that has different heights. im still in school tho and theyve just been teaching me easy stuff in maths so far....nothing thatll help me with this of course, so its vvvvv difficult for me to tweak it myself. i tried changing

position object 1,x#,y#,z#

to

position object 1,x#,get ground height (1,x#,z#),z#

and i also randomized the matrix

but this still did not suit my requirements. after examining the code further i realised that the click deals only with y=0 and therefore with this code the sphere is on top of the matrix, but not under the mouse anymore, rather it is over the point on y=0 where the mouse is being clicked. if someone could tweak jamesblonds code just a bit i would be forever in their debt.

red general: i had a look at your code too but unfortunately i didnt have 1 .x model on my comp so i couldnt run it plus there was also lots of stuff in there i didnt need so it would also be really useful if someone could just filter out that code for me?????

sorry if this is any trouble but i would really really appreciate it if someone could give me a hand here

cheers,
Teepee

Login to post a reply

Server time is: 2024-11-24 03:15:04
Your offset time is: 2024-11-24 03:15:04