Jump to content
  • Advertisement
Sign in to follow this  

DX transformed (rotated) 2D line drawing

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

This line gets drawn...
// Line width = 1
	D3DXVECTOR2 line[2];
	line[0].x = displayleft;
	line[1].x = displayright;
	line[0].y = displaytop;
	line[1].y = displaybottom;
	d3dxline->Draw(line, 2, linecolours[0]);

But these don't at all. So I'm wondering what I'm doing wrong here and how to use the rotation variable? If for example I wanted to rotate the line 45 degrees, would rotation value have to be 45.0f or something between 0 and 1?
		D3DXVECTOR3 line_z[2];
		line_z[0].x = displayleft;
		line_z[1].x = displayright;
		line_z[0].y = displaytop;
		line_z[1].y = displaybottom;
		line_z[0].z = 1.0f; // Also tried 0.5f and 0.0f
		line_z[1].z = 1.0f; // Also tried 0.5f and 0.0f
		D3DXVECTOR2 beamcenter(7, current_line.bottom - current_line.top);
		float rotation = 0.3f;
		D3DXMATRIX matrix; // Build our matrix to rotate, scale and position our sprite
		for(; i < 7; ++i)
			D3DXVECTOR2 translation(line_z[0].x, displaytop); // Screen position of the beam
			// out, scaling center, scaling rotation, scaling, rotation center, rotation, translation
			d3dxline->DrawTransform(line_z, 2, &matrix, linecolours);

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!