Sign in to follow this  

Radar Rotate

This topic is 3098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I was thinking how to make my enemies radar rotating by the Yaw of the camera, but the problem is: I can rotate the sprite texture of the radar but not the points of enemies together. So i thought maybe there is a thing in DirectX which allow you draw on a temp buffer, draw the sprite, then draw the points, and then rotate the whole buffer then draw it. Is there a such thing ? Thanks.

Share this post


Link to post
Share on other sites
Ok, i seem to find a start point.

Rotate the sprite.

For the points in radar:

I take a point, create a line from the point to the center point on the radar.
Rotate that line by X degrees, the end of the line will be the new point.

But i have no clue on how to make this process with DirectX.

Could someone please help me ?

Thanks alot.

Share this post


Link to post
Share on other sites
Actually you should do something like:

- calculate each radar blip position
- rotate the radar blips based on the player's rotation
- draw the radar

Share this post


Link to post
Share on other sites
Wouldn't there be a way around this with multiplying the world defining matrix in a different order? Like Translate*Rotate*Scale or something?

If not your best solution is some mathematical equation based on radian movement.

Share this post


Link to post
Share on other sites
I did something like that time ago:

for(;max enemies;)
D3DXVECTOR2 dir = yourPos - enemiePos[];
D3DXMatrixTransformation2D(&Matrix,NULL,NULL,NULL,NULL,YAW_on_Radians,NULL);
SpriteObj->SetTransform(&Matrix);
D3DXVec2TransformCoord(&dir,&dir,&Matrix);
D3DXVECTOR2 FinalVect(dir.x+SCREENXOFFSET,dir.y+SCREENYOFFSET);
D3DXMatrixTransformation2D(&Matrix,&D3DXVECTOR2(0,0),0.0,NULL,NULL,0.0,&FinalVect);
SpriteObj->SetTransform(&Matrix);
DRAW YOUR ENEMY POINT ON THE RADAR

I mixed pseudo code and code because that are the directx 2d functions,
the variable YAW_on_Radians is the Yaw of your camera, yourPos are the
2D vector that represent your position, the enemiePos are the position of
each of your enemies, SCREENOFFSET for x and y are the offset of your screen
coordinates on pixels.

Hope that can help, my video with the radar:

http://www.youtube.com/watch?v=jMs0LiPAD2I

the graphics part is not good, but the radar works =P

Share this post


Link to post
Share on other sites

This topic is 3098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this