About Store Forum Documentation Contact



Post Reply 
[SOLVED] Converting screendir.v2() to a radian/degree?
Author Message
Dandruff Offline
Member

Post: #1
[SOLVED] Converting screendir.v2() to a radian/degree?
Oh my god, i just wrote a smoking hot paragraph describing my problem and i accidentally hit the backspace button outside the form. Christ, now i forgot what i was going to say. Ugh.. going to write everything in notepad from now on.

Anways, short, sweet and to the point:
I need help combining screendir.x and screendir.z so i could compare it with Players[0].angle.x;.

Code:
ScreenToPosDir(Vec2(0,0), tpos, screendir);
angle.set(tpcamera(screendir.xz(),angle.x),Players[0].angle.y);
...
Flt tpcamera(Vec2 screen, Flt chrangle)//does nothing right now
{
    //need screen to be of same type of directional value as chrangle before
    //i can do anything else in this function..
    chrangle=AngleNormalize(chrangle);//radian

    return chrangle;
}

I hope my question is clear enough. It would suck to have to re-write the whole thing again.
(This post was last modified: 01-20-2011 06:39 AM by Dandruff.)
01-20-2011 05:16 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Converting screendir.v2() to a radian/degree?
(01-20-2011 05:16 AM)Dandruff Wrote:  Oh my god, i just wrote a smoking hot paragraph describing my problem and i accidentally hit the backspace button outside the form.

For future reference, if you were to hit the forward button, everything you just typed should still be there (at least if you are using Firefox).

(01-20-2011 05:16 AM)Dandruff Wrote:  I hope my question is clear enough.

I'm not so sure that it is. Are you trying to make it so that the player rotates to face the point where the player clicked at?

Use DegToRad(chrangle) to convert from degrees to radians.
01-20-2011 05:34 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #3
RE: Converting screendir.v2() to a radian/degree?
(01-20-2011 05:34 AM)Driklyn Wrote:  everything you just typed should still be there
I thought so too, but the message wasn't there. My subject was there though. Using Firefox version 3.6.13.


I am trying to compare screendir.x and screendir.z with chr::angle but screendir is not a typical radian or degree. screendir.x is between 1 and -1 but screendir.z is also between 1 and -1; i think they depend on each other to give a direction.

I tried this before..
Code:
Flt tpcamera(Vec2 screen, Flt chrangle)
{
    Flt temp = -screen.x;//negative because im not using screen.z
    return temp;
}
but this only rotates the character to a certain degree, it can't rotate beyond 1 and -1, and because chrangle is a radian from -pi to pi (-3,3) it only turns (about) a quarter way before stopping.
(This post was last modified: 01-20-2011 05:51 AM by Dandruff.)
01-20-2011 05:44 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Converting screendir.v2() to a radian/degree?
(01-20-2011 05:44 AM)Dandruff Wrote:  I thought so too, but the message wasn't there. My subject was there though. Using Firefox version 3.6.13.

Same version I'm using. Perhaps since you were typing for a very long time it couldn't cache it or something, maybe due to the length of your post too. Seems like they should change backspace from going back a page for this very reason, perhaps make it ctrl+backspace.

(01-20-2011 05:44 AM)Dandruff Wrote:  I am trying to compare screendir.x and screendir.z with chr::angle but screendir is not a typical radian or degree. screendir.x is between 1 and -1 but screendir.z is also between 1 and -1; i think they depend on each other to give a direction.

screendir is a direction vector (-1 to 1 for xyz), whereas chr::angle is an angle (-PI to PI). Try Angle(screendir) to convert the direction into an angle (I assume that's what it does).
01-20-2011 06:01 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #5
RE: Converting screendir.v2() to a radian/degree?
Yes yes yes, it's working! But i think i need to offset it a bit, its 90 degrees off.

I swore i tried that function before but i think i might have used the vec3 not vec2/vec2 with x and y floats. Thanks Driklyn you're awesome!

edit:offset is -1.571. It works perfectly now
edit2: haha i just realized why Angle() didn't work with me before. I used Vec::v2() and it used the x and y members not x and z grin.
(This post was last modified: 01-20-2011 06:38 AM by Dandruff.)
01-20-2011 06:07 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Converting screendir.v2() to a radian/degree?
Sweet, glad it is working!

Angles are in radians, so roughly -1.571 is equivalent to -90 degrees. You could also use DegToRad(-90) or -PI_2.
01-20-2011 06:37 AM
Find all posts by this user Quote this message in a reply
Post Reply