• ### Popular Now

• 14
• 12
• 9
• 10
• 9

#### Archived

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

# Problems with D3DXSprite::Draw()

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

## Recommended Posts

Ok, i want to rotate the sprite when i render it, as far as i can tell, its fine to render it with draw and still rotate it (as opposed to DrawTransform) but it just plain doesnt work... heres what im useing to render HRESULT DROTATESPRITE::Render() { DROTATESPRITE::Sprite->Begin(); if (FAILED(DROTATESPRITE::Sprite->Draw(DROTATESPRITE::SpriteTex, NULL, NULL, &(DROTATESPRITE::RotationCenter), DROTATESPRITE::rotation, &(DROTATESPRITE::Transform), NULL)))return E_FAIL; DROTATESPRITE::Sprite->End(); return S_OK; } rotation center is a vector, and rotation is a float.... y wouldnt this work? or is it devident that the problem must lie elsewherre? -Dan Yes I realize im a n00b...

##### Share on other sites
Erm... Your code was a bit garbled, but are you using a radian for the rotation? You can''t just stuff in an angle...

Brandon

##### Share on other sites
oh...
radian? lol, dunno wut that is (sohpmore in highschool)
can yah help me out?

-Dan

Yes I realize im a n00b...

##### Share on other sites
alright sweet, thanx...btw, whats d3d's constant for pi?

-Dan

Yes I realize im a n00b...

also..are there any atan functions that return a radian value? because i assume mauding a normal atan's value by 2*(3.1416) aint gonna do much, well it will but not what i want :-D

edit: also, i tried putting in 0, and i still had nothign visible, i had one of my non-rotating sprites onscreen as well just for a test, and it rendered fine, but the other, however..did not...

[edited by - Ademan555 on December 14, 2003 1:30:48 AM]

[edited by - Ademan555 on December 14, 2003 1:41:01 AM]

##### Share on other sites
I just use:

(float)(angle * 0.0174532925199432957)

That pre-calculates what you need out to a rather high precision. Note that angle is still a decimal value (not a radian). In fact, angle is a double that goes from 0.0 to 360.0. Come to think of it, I prolly should cap it at 359.999999 or something... Here''s how It''s used:

Cannon.Sprite->Begin();Cannon.Sprite->Draw(Cannon.Texture1,NULL,NULL,NULL,(float)(angle * 0.0174532925199432957),&cannonVector,0xFFFFFFFF);Cannon.Sprite->End();

As angle increases, it rotates counter-clockwise. I find that irritating, but what the heck! It works!

Brandon

##### Share on other sites
argh, yah thats annoying... i wrote my LookAtPoint() function for rotating clockwise , o well, shouldnt be too incredibly hard to fix... oh btw...if u put a rotation center you dont put the other vector?

-Dan

Yes I realize im a n00b...

##### Share on other sites
responses? hermm?? sri i really need this, its a huge roadblock lol

-Dan

Yes I realize im a n00b...

##### Share on other sites
Sorry for the slow response... My wife pulled me away from the computer. Some things are more fun than programming!

Anyway... If I understand what you''re asking correctly, the answer is that if you leave the rotation center parameter as NULL, it rotates around the top left corner of the texture. I don''t have the docs open right now, but I think that''s how it goes anyway.... And in my example I''ve not done any scaling, just the rotation.

It really is all in the docs. Not that I mind helping out! But I''ve all but printed out that page of the documentation... In fact, come to think of it, that''s not a bad idea....

Brandon

##### Share on other sites
hehe, well, my problem is the docs that i have have a completely differnet d3dsprite... :-/ apparently one thats in 3d space,(all the stuff is D3DXVECTOR3) MY d3dsprite, has all D3DVECTOR2''s and well, the protos are completely differnt to boot :-/, oh and thanx, but i needa rotate around the center of the image, which shouldnt be hard.... but it is :-( but thanx, way way way better than nothing

-Dan

Yes I realize im a n00b...