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.

Author
Message
Red general
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 5th May 2003 00:50
At the moment i have returned to my lifelong passion, a 3D rts.

In this 3D rts so far I have MagicWindow windows and tanks you can move around.

the problem with it is such, I am unsure as to how to have the user click on a button to make a new object and if a building, position it where he want or to make a new unit (e.g. tank) at a specific point, and have it act like all the other tanks

Can anyone help me?
THANKS
RED GENERAL
My computer melts regulary - perhaps it likes being fondue
Furiousuk
23
Years of Service
User Offline
Joined: 10th Jan 2003
Location: United Kingdom
Posted: 5th May 2003 17:22
I had the same problem and after weeks of trying to convert 2D screen co-ordinates into 3D world co-ords I finally gave up and decided to find some tutorials on the matter.
Take a look at http://www.gametutorials.com for some tutorials. I think there's one in the OpenGL tutorials. I haven't looked at the tute yet, and its written for VC++ and OpenGL, but in theory all of the math should be portable to DarkBASIC. Other then that, there are a few books available from Amazon, or maybe you can find them at a library.

I did try to solve the problem by creating a custom cursor which was placed as a Cube object into the 3D world and then moved around by the mouse but this was not a great solution.
Also, I believe another way of doing it is to send out a plain from the camera position and check for a collision, but I'm not sure how this would work if you're trying to calculate a matrix position. I assume you are trying to get a matrix position as you would otherwise be using the 'Object Screen X()/Y()' commands.

Sorry about the lengthy reply, hope this is of some use to you.
Red general
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 5th May 2003 20:07
sorry, the proble is not the 3D co-ords (see my example to see), the problem is to create a new unit and include it in the actions of it
i think I have the solution though, increase the arrays and have the objects from 1 to x, and just increase x (and limit the x as well). The new object would be say number 5, and the x would become 5. 6,6. 7,7. etc. But the thing will stop at 50 (big array)

Anyway look at my example (use media form darkmatter) and you will see what I mean

RED GENERAL

My computer melts regulary - perhaps it likes being fondue
Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 6th May 2003 00:54
You have to think logically about these things, but I guess it's just something you have to get the hang of. Here is my idea...

When you create an object, eg. a tank... you want to be able to know when you click on it that it is a tank. So how we solve that is to have an array, eg. "vehicles(1000)". This array stores the type of vehicle that it is, in this case a tank. Lets work out the values for the vehicles...

1 = armoured car
2 = tank
3 = missile launcher
4 = gold collector

So the object that we want to make is a tank, so we make the tank, position it and assign the array slot corrisponding to the object number with the number 2...



"vehicle_num" is the number of the object that you are creating, you have to increase it each time so you can make a new object in the next slot next time. "construction_x#" and the others are the position that the vehicles will be made.

You would then have a tank. Now you want to be able to select and move the tank around, this is simple.

Now that you have your object type assigned to the array, when you select the object (by detecting if the mouse is near to it's screen position) you store the object type in a variable and all the following actions depend on the number stored...



Thats just an example, obviously you would have to adapt that a lot.

Hope I helped!


Hamish

Why the hell'd you ask me for crying out loud!?!

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM

Login to post a reply

Server time is: 2026-06-12 06:56:04
Your offset time is: 2026-06-12 06:56:04