Archived

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

Help with perspective, please.

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

I am getting really frustrated with my projection matrix. Almost anything I do results in a blank screen. I can draw an Iso3d view without perspective, rotate it around the vertical axis (z in my case) and everything, but I can simply not get perspective to work Here''s the code that I use to set up my matricies: // Initialize Matrices D3DXMatrixIdentity(&matWorld); D3DXMatrixIdentity(&matView); //init not really needed D3DXMatrixIdentity(&matProj); D3DXMatrixIdentity(&matTrans);//init not really needed D3DXMatrixIdentity(&matRot); //init not really needed D3DXMatrixIdentity(&matScale);//init not really needed D3DXMatrixTranslation(&matTrans,-MAPWIDTH/2.0,-MAPHEIGHT/2.0,0); D3DXMatrixRotationZ(&matRot,Angle); D3DXMatrixScaling(&matScale,TILEWIDTH,TILEHEIGHT,1); matView=matTrans*matRot*matScale; matProj._33=-1.0; matProj._43=1.0; matProj._34=1.0; matProj._11=2.0/(float)WINDOW_WIDTH; matProj._22=2.0/(float)WINDOW_HEIGHT; d3ddev->SetTransform(D3DTS_VIEW,&matWorld); d3ddev->SetTransform(D3DTS_VIEW,&matView); d3ddev->SetTransform(D3DTS_PROJECTION,&matProj); The matProj initialization works, but as soon as I tilt my view most of what I draw gets clipped, leaving me with only a thin horizontal strip of map on the screen. Does anybody have some suggestions, or perhaps a chunk of code that I could use to initialize my screen to an isometric-style format? I am looking forward more to coding game-related stuff, and not this initialization crap. Thanks for any and all help, Zen p.s. I don''t know if this relates to my problem, but all my textures get mirrored on the screen. Ie an F in a texture would come out flipped vertically. I could easily swap all of my vertex texture coordinates to fix this, but perhaps it is an indication of something else that''s wrong. It seems I am looking at my scene (currently just a flat surface) from underneath?

Share this post


Link to post
Share on other sites
Just curious - any reason why you''re not using the D3DX functions like D3DXMatrixPerspectiveFovLH or similar?

Your backwards problem may be caused by the projection matrix - bad FOV values cause wierdness...

Share this post


Link to post
Share on other sites
Using the d3dx functions causes my display to clip horribly, giving me perspective but only displaying a narrow horizontal band of tiles in the center of the display. The function I use now is basically just a top down view, and the isometrics view is achieved by the scaling matrix. I think I might be having some problems with z-clipping, but I can''t figure out how to correct that. There are several places where I specify min and max clipping planes: when setting the viewport, clearing the z-buffer, and in the d3dx perspective functions. Changing these has not changed anything on the display, I still get a narrow band rather than a full screens-worth,
Zen

Share this post


Link to post
Share on other sites
Try the following -

Use the D3DX functions to create a matrix that has a far clipping plane of something like 1000.0 and then look in the debugger at the actual values. Based on what I''m seeing above, it looks like you have bad values. (In your code - that wasn''t a statement about your ethics or morality)

I haven''t looked at your stuff closely, but this should be really easy. Aside from accidentally specifying values in degrees, I''ve never had an issue. Unless you are actually setting clipping planes, the proj. matrix should be the only thing doing the clipping (assuming you''re clearing Z to 1.0)

Share this post


Link to post
Share on other sites
Yay, it works :D

I trashed my entire matrix code and started over, and I didn''t have any problems. I think I hadn''t put in enough thought over where my axis pointed, so I was often displaying something, it was just scrolled off the edge of the screen. Thanks a bunch for the help CG,
Zen

Share this post


Link to post
Share on other sites