Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Renegade Coordinates
Renegade Coordinates [message #434266] Thu, 05 August 2010 12:36 Go to next message
TechnoBulldog is currently offline  TechnoBulldog
Messages: 15
Registered: May 2010
Location: Texas
Karma: 0
Recruit
Could anyone help me with Renegade coordinates? I have no clue what they're doing lol. I know Algebra 1, so I know what some of it is, but most of it is completely unknown to me. I'm working with creating objects, and it would be nice to know how to spawn them in the correct place. What I have looks something like this:

Vector3 pos = Commands->Get_Position(Get_GameObj(ID));
pos.X = pos.X + 12 * cos(Commands->Get_Facing(Get_GameObj(ID))) * (PI / 180);
pos.Y = pos.Y + 7 * sin(Commands->Get_Facing(Get_GameObj(ID))) * (PI / 180);
pos.Z = pos.Z + 3;


From what I can tell, the position starts off at the player's position. Then it edits the X and Y (which I assume to be the ground plane) and sets the Z to three higher than the player. I haven't figured out what it's editing the X and Y to. I realize that this is probably just stuff from math classes I haven't taken yet, but I would really like to know what it's doing if anyone can explain. Pictures make it even easier lol.

By the way, if anyone can tell what the above code is doing, it isn't working for me lol. It's causing vehicles to spawn above me and kill me haha.


Cloud-Zone Gaming. Check it out.

^^ Awesome right?
Re: Renegade Coordinates [message #434271 is a reply to message #434266] Thu, 05 August 2010 14:41 Go to previous messageGo to next message
cnc95fan is currently offline  cnc95fan
Messages: 1261
Registered: July 2007
Karma: 0
General (1 Star)
I havn't a clue about any of this sort of stuff but I'm guessing where you have position z being equal to 3 or more that will spawn it 3 meters above (and since the characters are 2meters tall AFAIK you get killed)
Re: Renegade Coordinates [message #434272 is a reply to message #434271] Thu, 05 August 2010 14:59 Go to previous messageGo to next message
TechnoBulldog is currently offline  TechnoBulldog
Messages: 15
Registered: May 2010
Location: Texas
Karma: 0
Recruit
cnc95fan wrote on Thu, 05 August 2010 16:41

I havn't a clue about any of this sort of stuff but I'm guessing where you have position z being equal to 3 or more that will spawn it 3 meters above (and since the characters are 2meters tall AFAIK you get killed)

Yeah, I figured that much out.


Cloud-Zone Gaming. Check it out.

^^ Awesome right?
Re: Renegade Coordinates [message #434282 is a reply to message #434266] Thu, 05 August 2010 16:21 Go to previous messageGo to next message
a000clown
Messages: 363
Registered: May 2005
Location: Canada
Karma: 0
Commander
Vector3 Position = Commands->Get_Position(obj); //Gets position of an object
float Facing = Commands->Get_Facing(obj); //Gets facing of an object
Position.X += static_cast<float>(1.5*cos(Facing*(PI/180))); //Sets the previous position to be directly in front of the object
Position.Y += static_cast<float>(1.5*sin(Facing*(PI/180))); //^
Position.X += 0,Position.Y += 0,Position.Z += 0; //Depending on what you're spawning, you may want to manually change the position, so the object doesn't do something stupid like spawn partially in the ground/terrain
                                                 //Simply replace 0 where necessary, with however mugh change you feel is needed
                                                 //X is horizontal, increase to move right, or use a nagative number to move left
                                                 //Y is vertical, increase to move forward, or use a nagative number to move backward
                                                 //Z is height, increase to move up, or use a nagative number to move down
GameObject *Buggy = Commands->Create_Object("CnC_Nod_Buggy",Position); //Spawn your new object with the newly set Position (note: it's been a long time, not sure if that's the correct preset for a buggy)
Commands->Set_Facing(Buggy,Facing); //Set the facing of this new object to match the facing of the original object

I noticed you're on the nite-serv IRC, if you need anymore help you can PM me there (I'm usually under the nick Mike)
Re: Renegade Coordinates [message #434301 is a reply to message #434282] Fri, 06 August 2010 05:58 Go to previous messageGo to next message
TechnoBulldog is currently offline  TechnoBulldog
Messages: 15
Registered: May 2010
Location: Texas
Karma: 0
Recruit
I think I have it working, but I would greatly appreciate to know what it was doing. Can anyone explain exactly what it's doing?

Anyways, thanks Mike for the help with that.


Cloud-Zone Gaming. Check it out.

^^ Awesome right?
Re: Renegade Coordinates [message #434335 is a reply to message #434282] Sat, 07 August 2010 08:43 Go to previous message
BlueThen is currently offline  BlueThen
Messages: 2402
Registered: February 2006
Karma: 0
General (2 Stars)
The one in your quote looks a little broken, TechnoBulldog.

From what I can tell, Commands->Get_Facing(obj) gets the angle of which an object is facing in degrees. (Commands->Get_Position(obj) is self explanatory).

In the equations
Position.X += static_cast<float>(1.5*cos(Facing*(PI/180)));
Position.Y += static_cast<float>(1.5*sin(Facing*(PI/180)));
we're pretty much taking Facing, and converting it to Radians (multiplying by PI/180). We convert it to Radians because cosine and sine are both built to handle values between 0 and 2*PI, or -PI and PI, whichever you prefer. Radians just take the range of values from 0-360 and maps it to 0-2PI.

Cosine and Sine both return values between -1 and 1, which makes it simple for us to change the distance at which our object is plotted. Multiplying 1.5 to these 2 values puts our objected 1.5 units from the center. Then, after finding out the coordinates where the position should be from the origin, we translate it by Position.X and Position.Y by adding this value to them.

So all what this does is take our coordinate Position and moves it 1.5 units towards an angle (Facing).

I said that the formula in your message looks broken because you have the * (PI / 180) outside of the trig functions, when they should be inside.

After getting this position, you can spawn your object and face it towards/away/perpendicular to the initial Position, all in a000clown's post.

Edit: I'm also on Nite-Serv. You can ask me for help on the math part, but I don't really know Renegade's API as much as Mike does.

[Updated on: Sat, 07 August 2010 08:45]

Report message to a moderator

Previous Topic: Looking for a specific HUD
Next Topic: huds
Goto Forum:
  


Current Time: Sun Dec 15 14:40:38 MST 2024

Total time taken to generate the page: 0.00821 seconds