|
-
Dec 30th, 2001, 06:31 AM
#1
Thread Starter
Addicted Member
DX8 problem - Perspective
Hiyas,
I've just started learning DX8, and IMO it's not that much harder than DX7. It's different, but not really harder...
I have a problem with it though. Whenever I try to blit something which isn't the same perspective as the original texture, the render will become sort-of distorted (I'm guessing it's to do with how the vectors form the polygons).
I've attached a BMP screenshot (zipped). It's supposed to be a trapezoid with straight lines from top to bottom, but the lines aren't straight. FYI the original texture was 64x64 pixels (I remember reading DX8 textures must be to a power of 2).
Here's my code for the render...
Code:
TileVertices(0) = CreateTLVertex(200, 50, 0, 1, RGB(255, 255, 255), 0, 0, 0)
TileVertices(1) = CreateTLVertex(440, 50, 0, 1, RGB(255, 255, 255), 0, 1, 0)
TileVertices(2) = CreateTLVertex(100, 430, 0, 1, RGB(255, 255, 255), 0, 0, 1)
TileVertices(3) = CreateTLVertex(540, 430, 0, 1, RGB(255, 255, 255), 0, 1, 1)
D3DDevice.SetTexture 0, TileTexture
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, TileVertices(0), Len(TileVertices(0))
Anyone know what's wrong with it?
BTW why aren't blits/renders anti-aliased in DX8, whenever the render size is different to the original texture size?
-
Dec 30th, 2001, 11:43 AM
#2
Good Ol' Platypus
I'm not sure, but have you made your triangles clockwise? If you think you have and it still isn't working, try setting the visibility test to Counter-Clockwise, and see if that makes any difference. Also, in a VRML book that I have it says if you have concave faces they will show up weird, but in VRML you can make faces up of more than traingles.. Oh well.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 30th, 2001, 11:58 AM
#3
Textures are mapped linearly across triangles, not quads. So, what is happening is that your smaller triangle (the one at the bottom, if im not mistaken) is getting mapped according to the angle of the side of the triangle. The same is happening at the top. To fix this, you have to adjust the texture, and texture coordinates.
Z.
PS: Just as a hint, you should never use DrawPrimitiveUP. It is far slower then using Vertex Buffers.
-
Dec 30th, 2001, 08:56 PM
#4
Thread Starter
Addicted Member
I'm not sure about whether it's clockwise or not... I had to fiddle with the vertex numbers and the other two values at the end to get it rotated the way I wanted, though. So, how do I fix the texture mapping/co-ords?
Thanks guys. =)
-
Dec 30th, 2001, 10:14 PM
#5
Make the texture the same shape you want it to be on the trapezoid, then figure out the texture coordinates that will map the texture correctly.
Z.
-
Dec 31st, 2001, 07:58 AM
#6
Thread Starter
Addicted Member
Only one problem there... The game I'm writing (which is suffering this problem) has a top-down 3D perspective, sortof like Grand Theft Auto. Each tile can be rendered in any form really - the trapezoid will not be the same shape/size all the time. So, unless I want to make a few thousand textures, this won't work...
Is there any other ways I can get around this problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|