Quote:Original post by jrmiller84
Alrigght, so I've got three questions. I'll start with my texture questions. I am developing a 2d scroller and I'm about 4/5 done with it but there's a problem I've been avoiding for a while (denial maybe? hah) that I need to take care of. Ok, so I have a texture sheet that I've put together that works fine but the problem is that all the textures face right. So when my character is moving left, the animation itself is running right! So I did a little research and the only thing I could find is this line of code that apparently mirrors a texture
g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
Problem is, I'm using DX8, not DX9 and apparently this is a DX9 method. I can't seem to find the equivelent DX8 method if there is one. I am not opposed to just making my texture sheet larger and mirroring the textures for the different directions. I don't particularly like that idea as it is not very elegant and is extremely time consuming.
This wouldn't do what you think it would. See
this.
This is what I use for flipping images before rendering:
//Note: I use DirectX 9, but this ought to work in DirectX 8 unless some big//changes were made inbetween. If so however, it should be simple to convert.D3DXMatrix finalMatrix;if(image.flipped()) { D3DXVECTOR3 textureCenter(0.0f, 0.0f, 0.0f); D3DXVECTOR3 translation(static_cast<float>(image.width()), 0.0f, 0.0f); D3DXMATRIX flippedMatrix; D3DXMatrixRotationY(&flippedMatrix, D3DX_PI); D3DXQUATERNION rotationQuaternion; D3DXQuaternionRotationMatrix(&rotationQuaternion, &flippedMatrix); D3DXMatrixTransformation(&finalMatrix, NULL, NULL, NULL, &textureCenter, &rotationQuaternion, &translation); }
This makes "finalMatrix" the "flipping matrix" to be SetTransform()'d or matrix multiplied with the final transformation matrix.
Quote:Next question is quick and to the point. Is there a way to tile textures on one polygon? For example, I have a texture I am using on the floor of one of my levels that I would like to tile and not stretch across the entire floor of my level, nor would I like to create a couple hundred proportional polygons to line across the bottom so that it creates a pattern. Is there a way around this, I'm guessing there must be but I can't find anything on it.
I haven't deal with texture addressing myself in a while, so someone else will come along and give you a better explanation, but IIRC you set your texture coordinates in a range greater than [0.0, 1.0] and it'll repeat the texture accordingly. There should be more detailed info in the DX docs.
Quote:Final problem and maybe a small bit more involved. I am keeping track of my objects within a linked list and looping through them to render them as well as check for collisions, etc. I have found a way to delete items off of the list using this bit of code:
*** Source Snippet Removed ***
Does the erase method of the linked list actually destroy the class as well? As you can see, that bit of code is controlling the destruction of projectiles that go off of the screen and I would hate to have a few hundred active classes after they have actually gone off of the screen. I couldn't find a definitive "Yes, this destroys the class pointed to" anywhere so I am curious. Thanks everyone!
You probably mean "object", not the class. Assuming you're not storing pointers to new'd memory that you never free, yes, that destroys the object(s).