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 mouse and camera interface.[DBPro/DBC?]

Author
Message
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Feb 2004 17:12
Really just the mouse, camera, and push scroll system from OIE.

Would work in DBC with a little modification. Note that this does not use the Pick Object command set, it just positions an object wherever you click, easy to impliment though.




Van-B


The nature of Monkey was irrepressible!.
Figment
20
Years of Service
User Offline
Joined: 14th Feb 2004
Location:
Posted: 14th Feb 2004 21:12
Whoa this is cool! How could I add a texture to the terrain?

...
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Feb 2004 10:39
To add a texture, you'd just load in the image instead of generating it at the start, look for the GET IMAGE command and load an image instead.


Van-B


The nature of Monkey was irrepressible!.
Mitch
20
Years of Service
User Offline
Joined: 28th Sep 2003
Location: The Netherlands
Posted: 16th Feb 2004 17:46
This was exactly what I was looking for, for I was going to do this in a way that's probably way more stupid and difficult. Though it doesn't work in DBC..

[error]:

`Globalised variables for MUS function
global musx#
global musy#
global musz#

Does anyone know how to change that into DBC code?

Me vs. The World...
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Feb 2004 10:36
Yeah, you could just make simple arrays for them instead, like:

Dim musx#(1)

Then, you use the variable musx#(0) instead of musx#.

I would have converted it and posteb both versions, but I don't have DBC installed on my PC just now.


Van-B


The nature of Monkey was irrepressible!.
Jess T
Retired Moderator
20
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 19th Feb 2004 23:39
That looks like some nice code there Van B

One thing I'm not too sure I understand is the lines;


What exactly are they calculating? Are they just converting the mouse positoin into a float between 0 and 1?

Thanks,
Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Feb 2004 10:22
Well, they sorta convert the 3D mouse location into a constrained 2D area - it does generate 0.0-1.0 floating points - but it has to adjust the coordinates to get the illusion of a 2D mouse pointer from the 3D object movement.


Van-B


The nature of Monkey was irrepressible!.
Jess T
Retired Moderator
20
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 21st Feb 2004 11:15
Oh, I get it now... Sheesh, don't I feel like a dits, lol...

Thanks for the ( brief ) explanation Van B

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
GuruSY
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location:
Posted: 10th Mar 2004 02:42
Wow! This code is just what I was looking for! Thanks alot!

I was trying to do exactly what you did only with an object for the terrain, but by looking at your code I have decided to go with a matrix for the terrain as it has the "get ground height" command which is extremely useful.

Thanks!
genius
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: Utah, USA
Posted: 10th Mar 2004 04:56 Edited at: 10th Mar 2004 04:57
GuruSY, you can use a terrain that is an object by using ???'s code(don't know his name, lol). It has all of the matrix commands and it is an object. The only problem with and object matrix is that it takes up LOTS of polygons, if you look at a matix in wireframe, each triangle is a polygon, matrices don't count very many polygons though.

Bye,
Colin

Be happy, tomorrow is another day
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 10th Mar 2004 17:00
Whoa VanB thats ... well ... complicated! I like it!

Heres another, somewhat simpler, way of doing the same thing, although I haven't bothered with any nice graphics like pulsing white spheres or nice randomised green matrix textures.

http://darkbasicpro.thegamecreators.com/?m=forum_view&t=27536&b=6

I'm just a simple bear at heart.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
GuruSY
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location:
Posted: 11th Mar 2004 08:53
VanB...

I have been experimenting with your code. It is very acurate in the object placement.

but...

I have no idea how you did the formulas for the camera placement.

I say this because I was trying to adjust your code to work at different x-angles, and I have no idea how you do it. If you change the angle to anything but 55, the camera controls do not work. I thought it was something to do with your camera control formulas, but when I put my own camera control in, I had the same problem. So I think it might have to do with where the actual mouse is in relation to where the mouse object is.

Any ideas on how to adjust this to any x-angle?

P.S.
Can you explain these lines that JessTicular pointed out a little more, they seem like magic to me.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Mar 2004 12:21
Hehe, that line took a good 2 days to come up with, unfortunately it's trial and error - just messing about with the values until it was roughly 2D - with other X camera angles the formulae has to be changed so that the mouse becomes 2D again, not easy.

I'll have a mess around and see if I can simplify that, maybe have it so it can calculate the formulae values depending on the X angle. I'll get back to you.

Kevil made some great code snippets, go looking for Kevin Verbeeks memblock matrice examples in the codebase - it is very easy to replace that get ground height with Kevils interpolated version for mesh matrices. I hate the standard matrices and only use them for quick examples or editors (they're good for terrain editors etc because they're stable and quick enough for that).


Van-B


The nature of Monkey was irrepressible!.
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Mar 2004 14:02
Personally I think my code as compared to VanB's demonstrates the ease of vector math over trig math for this sort of problem.

Mind you it also demonstrates that VanB has the bigger brain. But I'm happily to come second in that department. Remember: like Winnie the Pooh I am but a bear of little brain.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Mar 2004 15:15
Well my small brained bear friend, you got them damn vectors working and I could'nt! - remember your Yogi, who is traditionally smarter than the average bear .

I could'nt really fathom how I could use the vectors and restrict it to a Y height of 0 (the terrain could go below 0, but 0 is the water height in OIE). Just ended up doing it the hard way because I could control it and not have to worry too much about it once it's done. Plus it let me control the collision for myself, like I could ignore certain objects like bushes - OIE still isn't great in that respect but nobody said RTS coding was easy .


Van-B


The nature of Monkey was irrepressible!.
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Mar 2004 15:44
Hopefully after my vector tutorials are written then everyone will be able to use them! RTS game frenzy, here we come!

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
B1rD
20
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 5th Apr 2004 01:12
Here's the code for DBC, i modified it a little bit, but i cant get the mouse-relocating done.

I dont really know how to work with vectors and arrey's in dbc, but the code is done.
you can execute the code without any bugs, and do everything as the original code, except for the mouse functions.

Login to post a reply

Server time is: 2024-05-13 16:22:02
Your offset time is: 2024-05-13 16:22:02