Sign in to follow this  
wxbzxzx

How to use D3DXVec3ProjectArray ?

Recommended Posts

wxbzxzx    122
D3D10_VIEWPORT vp; vp.Width = 720; vp.Height = 576; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; D3DXMATRIXA16 matRot,g_World ,g_Projection,g_View; D3DXMatrixIdentity( &g_World ); g_World._11 = 10.0f; D3DXMatrixRotationY(&matRot,D3DXToRadian(30)); g_World *= matRot; D3DXVECTOR3 Eye( 0.0f, 0.0f, -0.5f / tanf(D3DX_PI / 8.0f)); D3DXVECTOR3 At( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 Up( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &g_View, &Eye, &At, &Up ); // Initialize the projection matrix D3DXMatrixPerspectiveFovLH( &g_Projection, (float)D3DX_PI * 0.25f, 1.0f, 0.1f, 100.0f ); D3DXVECTOR3 vMesh[] = { D3DXVECTOR3(-0.5f,-0.5f,0.0f), D3DXVECTOR3(-0.5f,0.5f,0.0f), D3DXVECTOR3(0.5f,-0.5f,0.0f), D3DXVECTOR3(0.5f,0.5f,0.0f), }; D3DXVECTOR3 vRect[4]; D3DXVec3ProjectArray(vRect,sizeof(D3DXVECTOR3),vMesh,sizeof(D3DXVECTOR3),&vp,&g_Projection,&g_View,&g_World,4); D3DXVECTOR3 vMin,vMax; D3DXComputeBoundingBox(vRect,4,sizeof(D3DXVECTOR3),&vMin,&vMax); RECT rcImage; SetRect(&rcImage,vMin.x,vMin.y,vMax.x,vMax.y); Result : rcImage = {top=19 bottom=556 left=-1968 right=-452},But it is error.Left and right less zero. rcImage.Left and rcImage.Right of rcImage is error,how to get right rcImage? [Edited by - wxbzxzx on August 11, 2008 10:20:43 PM]

Share this post


Link to post
Share on other sites
ET3D    810
What you need is to do some debugging. Things you can try:

Use D3DXVec3Project in a loop, instead of D3DXVec3ProjectArray, if you suspect your use of D3DXVec3ProjectArray is the problem.

Do your own multiplication of the view and projection, and transform your vectors. See if you get (once you divide by w) x and y which are outside the -1 to 1 range.

You can try to render this quad. See if part of it is outside the viewport.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this