How to use D3DXVec3ProjectArray ?

Started by
1 comment, last by wxbzxzx 15 years, 8 months ago
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]
Advertisement
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.
The ideal of ED3T is right,part of render result is outside the viewport,w < 0.When w < 0,how to do?

This topic is closed to new replies.

Advertisement