Need help from all the math pros

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

Need help from all the math pros

Post by Nekoneko » May 10th, 2011, 7:51 pm

Sorry, I have another problem :/

I spawn a model with the angles (0,0,0) (facing x, so its normal is (1,0,0)).
Now I want the model to be facing the same way the surface normal of a trace is.
So the model.angles should be the same as trace["normal"]

If you cant imagine what I exactly mean, my model should be like a 'shoot-decal' if you shoot at a wall,the decal should have the same angles as the wall, thus being right on the wall.
Basically I need a conversion from a normal to an angle.

For those, who dont know what a normal is:
If I make a Trace on the ground and look at Trace["normal"], it will be (0,0,1)(x,y,z), so facing upwards, the z-axis.


It would be great help if anyone could help me on this. :(

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Need help from all the math pros

Post by IzNoGoD » May 10th, 2011, 8:32 pm

Try

Code: Select all

model.angles=vectortoangles(trace["normal"]);
Or, if that doesnt work, try one of the following combinations:

Code: Select all

model.angles=vectortoangles(anglestoright(vectortoangles(trace["normal"])));
or

Code: Select all

model.angles=vectortoangles(anglestoup(vectortoangles(trace["normal"])));
But im pretty sure the first one will just work, or you could try rotating your model until it fits (the other 2 options have some problems with what way is "up", so they might be placed upside down. Although this is not much of a problem for a decal, the first solution is easier.

Portal 2 spoilerquote below-select on own risk
You know, deleting Caroline just now taught me a valuable lesson; The best solution to a problem is usually the easiest one.

So i would just go with the first one
LMGTFY!

Its not a glitch... Its the future!

Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

Re: Need help from all the math pros

Post by Nekoneko » May 10th, 2011, 8:45 pm

Wow.
I didnt expect anyone to know that, even though now it seems so simple lol.
Been trying for hours on some mathematical equasions haha.
Thank you very much, solved a big problem ^^

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Need help from all the math pros

Post by IzNoGoD » May 10th, 2011, 9:07 pm

Well, lets just say ive been there, done that

Took me a long time though xD, but managed to port c4 to cod2 with it :D
LMGTFY!

Its not a glitch... Its the future!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest