Jump to content
  • Advertisement
Sign in to follow this  
caesar4

lookat transformation

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

for my 3d project, i have 2 render windows, in one i have the main camera, in the other i want to see the frustum of the main camera the frustum is a pyramid calculated from the FOV, and near&far planes and the eye is at <0,0,0> looking into the z-axis (negative or positive, doesnt matter) the camera has 3 components, a position, a look at point, and an up vector my question is: how to construct a transfromation matrix for the renderable view frustum? i dont need any1 telling me this:
Quote:
zaxis = normal(At - Eye) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) xaxis.x yaxis.x zaxis.x 0 xaxis.y yaxis.y zaxis.y 0 xaxis.z yaxis.z zaxis.z 0 -dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1
because that doesnt do wut i need

Share this post


Link to post
Share on other sites
Advertisement
not wut i meant,

i want to transform a couple lines representing the view frustum in world space, not any later stage in the transform pipe

Share this post


Link to post
Share on other sites
woops, i had a typo

heres my finishd code, to save someone the headache ive been havin


int CCamera::DrawFrustum(){
if(!this->ppDev)
return 0;

IDirect3DDevice9 *dev = (IDirect3DDevice9 *)this->ppDev->GetDevice();
if(!dev)
return 0;

CMatrix mat;
CVector dir = this->cfCurrent.vecPosition-this->cfCurrent.vecLookAt;
dir.Normalize();

float cx = sqrtf(dir.z*dir.z+dir.x*dir.x);
float cy = dir.z/cx

float roll = acosf(vecYP.Dot(this->cfCurrent.vecUp));
float elevation = acosf(cx);
float heading = acosf(cy);

if(dir.y > 0.f)
elevation=-elevation;
if(dir.x < 0.f)
heading = -heading;

mat = matIdentity.GetRotateAxisZ(roll);
mat.RotateAxisX(elevation);
mat.RotateAxisY(heading);
mat.Translate(this->cfCurrent.vecPosition.x,this->cfCurrent.vecPosition.y,this->cfCurrent.vecPosition.z);

this->Frustum[8].vecPosition = this->cfCurrent.vecLookAt;
this->Frustum[9].vecPosition = this->cfCurrent.vecPosition;

dev->SetTransform(D3DTS_WORLD,&matIdentity);
dev->SetFVF(this->Frustum->FVF);
dev->DrawPrimitiveUP(D3DPT_LINELIST,1,&this->Frustum[8],sizeof(this->Frustum[0]));

dev->SetTransform(D3DTS_WORLD,&mat);

dev->SetStreamSource(0,this->vbf,0,sizeof(this->Frustum[0]));
dev->SetIndices(this->ibf);
dev->DrawIndexedPrimitive(D3DPT_LINELIST,0,0,8,0,12);

return 1;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!