Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


building & rotating a 2d quad (directX)

This topic is 5345 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

im trying to build a quad based on my players position, heading and left facing vectors, and the size of the player. this is my code currently, and it draws the quad based on its size and position:
        point[0].position.x = vPosition.x + size;
	point[0].position.y = vPosition.y + size;
	point[0].position.z = 0;
	point[0].rhw = 1;
	point[0].tu = 0.0f; point[0].tv = 0.0f;

	point[1].position.x = vPosition.x - size;
	point[1].position.y = vPosition.y + size;
	point[1].position.z = 0;
	point[1].rhw = 1;
	point[1].tu = 1.0f; point[0].tv = 0.0f;

	point[2].position.x = vPosition.x + size;
	point[2].position.y = vPosition.y - size;
	point[2].position.z = 0;
	point[2].rhw = 1;
	point[2].tu = 0.0f; point[2].tv = 1.0f;
	point[3].position.x = vPosition.x - size;
	point[3].position.y = vPosition.y - size;
	point[3].position.z = 0;
	point[3].rhw = 1;
	point[3].tu = 1.0f; point[3].tv = 1.0f;
i try and pen and paper out how i am going to do these things and when it comes to rotating the players heading im confused about how i build my quad based on the new heading and position. main thing thats confusing me is that i have a 2d map for the player to walk around, with the top left corner being (0,0), and when i think i need a negative axis also to move my player around, or do i? its late and i mite not be thinking straight. could anyone help me on maybe how they would go about building this players quad depending on its heading and position please...i dont need to know how to rotate the heading or anything, i thinkk i have that down....just building a quad from it. any help is appreciated...cheers "take that space coyote!"

Share this post

Link to post
Share on other sites
Your vertices should be specified in clockwise or counter-clockwise order. Yours goes from lower-right to lower-left to upper-right to upper-left.

Share this post

Link to post
Share on other sites
i''ve specified them in this order because i am drawing my quad using a triangle strip, and this is the order they are mean to be in isnt it? my quad is coming up fine...clockwise and counter clcokwise for drawing a triangle list isnt it? thanks tho []

im not sure i have explained myself very well [] im trying to build my square/quad based on the direction my player is facing, so if my player is facing towards the bottom right corner of the screen then the quad will have rotated to face that way.

at the moment it doesnt draw it with the right orientation, how do other ppl do this for a 2D quad, using tranformed and lit vertices?

Share this post

Link to post
Share on other sites

  • 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!