Jump to content
  • Advertisement
Sign in to follow this  
Frisker

Transformation problem

This topic is 4501 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'm currently programming MDX with C#, I'm doin a 2D game to learn the language better. In the sprites I have my character face east, I Want him to face west if I'm going west. If I spin him 180 degrees he will be up-side-down, any1 know if it's possible to 'shift' him with transformation matrices?.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Zahlman
You presumably want a reflection in the vertical (north-south) axis.


Well.. I dont know what that's, can u post it with code?. Doesnt matter which language.

Share this post


Link to post
Share on other sites
Try scaling him -1 in the X direction, and 1 in the Y and Z directions. In OpenGL it would be done with

glScalef(-1.0f, 1.0f, 1.0f);

I think this will work, but I am not sure.

Share this post


Link to post
Share on other sites
Quote:
Original post by Frisker
Well.. I dont know what that's, can u post it with code?. Doesnt matter which language.
A reflection about the y axis would look like this in matrix form:
[-1 0]
[ 0 1]

Share this post


Link to post
Share on other sites
I try to use

<CODE>
D3DSprite = Matrix.Scaling(-1.0F, 1.0F, 1.0F);
</CODE>

But everything just dissapears :/

Share this post


Link to post
Share on other sites
Quote:
Original post by Frisker
I try to use

<CODE>
D3DSprite = Matrix.Scaling(-1.0F, 1.0F, 1.0F);
</CODE>

But everything just dissapears :/
You're probably applying the transformations in the wrong order. For example, if the reflection is being applied after the translation, the sprite could be getting 'reflected' right off the screen.

If you're still having problems with this, post the code where you set up the transform for rendering the sprite.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
Original post by Frisker
I try to use

<CODE>
D3DSprite = Matrix.Scaling(-1.0F, 1.0F, 1.0F);
</CODE>

But everything just dissapears :/
You're probably applying the transformations in the wrong order. For example, if the reflection is being applied after the translation, the sprite could be getting 'reflected' right off the screen.

If you're still having problems with this, post the code where you set up the transform for rendering the sprite.


public void FillPos(int x, int y)
{
Pos.X = x;
Pos.Y = y;
}

public void Draw(Sprite D3DSprite)
{
Rectangle rect = (Rectangle)Desc[aFrame];

Center.X = rect.Width / 2;
Center.Y = rect.Height / 2;

D3DSprite.Transform = Matrix.Scaling(-1.0F, 1.0F, 1.0F);

D3DSprite.Draw(tex, (Rectangle)Desc[aFrame], Center, Pos, Color.FromArgb(255,255,255,255));
}

I dont move my sprites with translation, D3D does move it with D3DSprite.Draw. Pos is the Position... I'm really clueless atm

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!