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.

Dark GDK / face a turret to another object?

Author
Message
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 23rd Sep 2008 05:03
Hi guys, my problem is how make to pointing a tank turret to another object automatically, same as a tank turret rts to an enemy target.
This is possible in dark gdk?
sorry for my bad english

thx
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 23rd Sep 2008 18:45 Edited at: 23rd Sep 2008 18:48
You can use Trigonometry (SohCahToa) to work it out.
You'll need to work out the distances between them by taking away the coordinates of one from the other, then use atan to work out the angle.

EDIT: or just use dbPointObject ^^
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 24th Sep 2008 01:29
thanks jezza, but the problem isn't point all tank to another object, but rotate the turret of the tank (then only a part of the tank) must target the enemy object (do you know rts tanks? so is the same).
pls someone help me
thx
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 24th Sep 2008 17:14
sounds like a limb/bone issue to me.

~you can call me lantz~
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 24th Sep 2008 18:55
If the tank turret is part of the model fixed on top of the tank, and there is no animation with different turret rotations, then i dont think you can
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 25th Sep 2008 00:12
so for to that i can import 2 object files, one for turret and one for body tank?
or there is another method for animate in-game an object?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 27th Sep 2008 00:29
direction = (position1 - position2).unit

position1 and position2 are 3D vectors.

I have something you might find useful for this, but I'm still debugging it.
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 27th Sep 2008 13:10
thx Zuke, but where i can define the vector?
pls post me a command for do that.
thx again
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 27th Sep 2008 21:02
What about makeing the turret as one object and the rest of the tank as one? Then it should be easy to turn turret.

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
hayer_p
16
Years of Service
User Offline
Joined: 24th Sep 2008
Location: Norway, Trondheim
Posted: 27th Sep 2008 23:56
Quote: "What about making the turret as one object and the rest of the tank as one? Then it should be easy to turn turret."


Why the turret as an object? I would rather use and limb for the turret

WTF is this textarea used for? <.< Signature? WTF is that?
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 30th Sep 2008 10:57
So, someone can post here a code of dark gdk, for that problem pls?
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 27th Oct 2008 19:01
Have you figured it out yet. I am still working on it myself. I got the turret mounted on my vessel. I have gotten some pretty interesting and odd rotations, though I still got to get it to point to the target object.

My test vehicle is put together using in game models. I used glueobject command to place the turret onto the vehicle. I am trying to use the rotatelimb command.

I am also using Ezrotate library for some of the basic vehicle control.

There are many answers but just one question" ~ Jerilith the Mad
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 27th Oct 2008 22:14
Quote: "Why the turret as an object? I would rather use and limb for the turret "


Im a limb noob

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 28th Oct 2008 02:47
Quote: "Im a limb noob "


YES ... So am I , but most of us will have to come to understand this area some time or other.

It would be so helpful if some kind soul were to write a simple tutorial about this important topic.

Just putting some random thoughts together about the topic.....
If a person creates a model of something like a tank in a 3D modeling program.
It has one rectangular cube(1) with an origin point. This is the body of the tank.
It has a separate rectangular cube(2). That is the turret of the tank. This cube(2) would have its origin point also in its center.
It has a tube(1) as a barrel. This tube would have its origin point at the position where the barrel would pivot.

These 3 parts would be 3 independent meshes in the model.
cube(1) would be layer 1.
cube(2) would be layer 2.
tube(1) would be layer 3.

Now for a huge guess about what I would expect *****BUT CAN BE TOTALLY WRONG*****

When this 3D model gets loaded into the game, surely cube(1) as it is the first layer would become the primary object of the model (primary limb), and all the other layers become a limb of the primary object mesh.

All one should have to do is move the tube(1) limb from the cube(1) primary object and tie it to the cube(2) limb, with the dbLinkLimb() command. ???????

This way cube(1) is tha tank body.
Cube(2) is the turret and is tied to the tank body and follows it. It can now be rotated with the dbRotateLimb() command to make it swing left and right through it origin point.

The barrel, tube(1), is tied to the turret so it will follow the turret around, and it can be made to move up and down relatively to its origin point also with the dbRotateLimb() command.

Surely something like that would be close to the procedure used.

PLEASE somebody, help us poor souls out on this topic.

Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 29th Oct 2008 18:25
Quote: "PLEASE somebody, help us poor souls out on this topic. "

Right!
Pls someone make a guide pls!!
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 29th Oct 2008 23:47
@sydbod - oh.. thanks... it helped me a lot...

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 30th Oct 2008 04:36
After a bit more research, it appears that one can make 3D models and with a feature called "Parenting" one can assign what mesh is the parent of what other mesh.

This means that when the model is created, one can assign "cube(1) is the tank body" as the parent.
Then assign "cube(2) is the turret" as a limb to cube(1).
Then assign "tube(1) is the barrel" as a limb to "cube(2) is the turret.

Provided the pivot points (origin points) were set as above, the tank should be pre-rigged and ready to code.

I have been looking at making a small tutorial based on this, but I just can not create the 3D object. I can't model even if my life depended on it.

If any one can knock together a simple 3D model for me I would be more than happy to create a basic tutorial for this once I figure it out properly.
go2none
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location: London
Posted: 30th Oct 2008 10:44
How about dbGlueObjectToLimb? Will this get the job done?

jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 30th Oct 2008 13:51
You know this whole thing should be possible without limbs. In DirectX, when rendering a model, you only render one subset of it at a time, and each of those subsets cans have a different position, material texture etc even though they are part of the same .x file. I don't know whether this is possible in DarkGDK, because all the rendering is done automatically, but the command would be something like:

If you could work out the name of the mesh object, you might be able to do this.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 30th Oct 2008 15:52
Quote: "you only render one subset of it at a time, and each of those subsets cans have a different position,"


Can you imagine how many subsets you would require to cover all possibilities of Gun Elevation combined with all possibilities of turret rotation.

Once one adds in something like tank track movement, then it becomes a huge job.



@ go2none,

YES a great little demo for what is going on.
Have just made the barrel a little more barrel like.
Have moved the pivot point of the barrel to its inner end.
Provided barrel motion capability.

When one moves the tank a little closer to a screen corner it is very easy to see what is going on.



If only we could get a proper 3D model, we would have the making of a great little tutorial here.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 30th Oct 2008 18:12
Quote: "Can you imagine how many subsets you would require to cover all possibilities of Gun Elevation combined with all possibilities of turret rotation.

Once one adds in something like tank track movement, then it becomes a huge job.
"

No! you can rotate the subsets separately.
Adanf
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location: Italy!!!!!!!!!
Posted: 30th Oct 2008 18:19
Ok, thank all, but my initial questions was how i how can point a tank turret to ANOTHER OBJECT automatically like RTS thanks/turrets.
Can someone do that?

thx
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 31st Oct 2008 09:36
Quote: "i how can point a tank turret to ANOTHER OBJECT automatically like RTS thanks/turrets"


You will probably not get an answer to that question for the following reasons.
1) It takes a lot of mathematics and thus takes a huge amount of time to explain it.
2) You have not provided enough code for people to be able to advise what approach would be most suitable.
3) It takes a lot of code to do what you want, if it is properly integrated into your project.

You will have to do it yourself, but here are a few suggestions.

1) write code to determine the x,y,z game world location of your tank and of your target.
2) write code to determine the x,y,z game world location of the tank turret determined by the tank shape, tank facing direction and turret positioning on the tank.
3) calculate the targeting_vector between the now determined center point of the tank turret and the target.
4) determine the current pointing_vector of the tank turret.
5) write code to rotate the tank turret from its any pointing_vector to a predefined targeting_vector.

Procedure is all very simple, when it is broken down into its relative steps ....... but it will be substantial code ...... and use a bit of secondary school mathematics (trig).

Hope that gets you started.
go2none
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location: London
Posted: 31st Oct 2008 19:54
This should be enough for a small project. Making something more complex would require another approach. Just put the .X models in the game folder where your Main.cpp is. They're in the attachment.

Attachments

Login to view attachments
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 5th Nov 2008 03:30 Edited at: 5th Nov 2008 03:36
Hey Thanks "go2none". Here is a non media version of your Code Snippet. The green block is the turret.



Thanks just what I was looking for.

There are many answers but just one question" ~ Jerilith the Mad

Login to post a reply

Server time is: 2024-09-30 09:26:33
Your offset time is: 2024-09-30 09:26:33