Advertisement

Sprites

Started by November 21, 2002 04:58 PM
17 comments, last by yaroslavd 21 years, 11 months ago
Mr. Bungle, You probably won''t want to do that because rotating an image takes MUCH more processing power than translating one. It may work depending on what kind of machine you are designing it for and how large your helicopter bitmap is though.


Excerpt from Tricks of the Windows Game Programming Gurus (Tell me if it works or not):

Direct draw supports both rotation and scaling. The HAL only supports rotation. Bitmap rotation is about 10-100 times slower than scaling. To perform rotation on a bitmap, your hardware must support it (very rare in 1999), and then set up a DDBLTFX structure.


DDBLTFX ddbltfx; //this holds our data

//initialize the structure
DDRAW_INIT_STRUCT(ddbltfx);

//set rotation angle (each unit is 1/100 of a degree of rotation)
ddbltfx.dwRotationAngle = angle;

//blit to destination surface
if (FAILED(lpddsback ->Blt(&dest_rect, lpdds_image, &source_rect, (DDBLT_WAIT | DDBLT_KEYSRC | DDBLT_ROTATIONANGLE), &ddbltfx)))
return(0);
Swacky, I tried implementing that code but it doesnt seem to want to work. Everything compiled but it wont display the sprite. I took a look at that book and found the code for the DDRAW_INIT_STRUCT marco, and also read something about checking hardware compatability with GetCaps(), so im gonna try that to see if its my graphics card. Its probably going to end up to be too slow of a function, but it would be nice to know how to use it anyway.


Advertisement
As far as I know, DirectDraw does NOT support rotation and scaling. I don''t think it even supports transparency... You have to use Direct3D for that...
Why do you say that it doesn''t support transparency? Maybe they changed it in DX8? This is DX7 code I believe. I can''t think of how else they would do blitting without that? I''m pretty sure the book doesn''t use any direct 3d libraries anywhere.
Check the MSDN docs, but around DX5, microsoft said that the rotate and scale fields were there for future implementation, and not supported yet. Every time I''ve tried to use those features, my sprite doesn''t get drawn.

well, in the dx7 sdk help it states that there are rotation and translation functions in the ddbltfx structure, however the rotation only works for certain hardware and is not widely supported. It also mentions some flags such as DBLTFX_ROTATE90, but I cant get those to work either and they are supposed to work for all hardware. However, my sprite displays when I use those flags its just not affected in anyway. I think id be better off just adding prerendered rotated sprites, itd probably run faster. Im not advanced enough to write my own rotation code yet. Thanks again for your guys'' help.

Advertisement
You are welcome Mr. Bungle. I wish I could be of more help, but alas, I am only a simple artist.
I have Poser3, Bryce4, and Lightwave 7 (I think) and I''m wanting to turn my 2d drawings into 3d cartoon-like mods, but I need to know how to create an unfolded space so I can properly apply the bit map textures.

For you people who know how to use wireframe mesh, what is the easiest way to make textures for a poser 3 character without going over the predefined space of the model''s suface area?
Now I shall systematicly disimboule you with a .... Click here for Project Anime
quote: Original post by skjinedmjeet
As far as I know, DirectDraw does NOT support rotation and scaling. I don''t think it even supports transparency... You have to use Direct3D for that...


Yes, it is not supported by Direct Draw. I wrote up a sprite engine and had to write a rotation algorithm for it. I may still have a tutorial at my website.

Found it, Rotation Tutorial. It''s crude, but works and might give you an idea on how to approach this problem.

A correction in the algo concerning 2 pixel edge buffer, that value would change according to sprite size. I never did go to the bother of mate,aticaly calculating that value. Also, this is for an non-animated graphic. To rotate an animated sprite, the animations have to be stored on separate surfaces, and each surface rotated in turn.


Guy

This topic is closed to new replies.

Advertisement