Jump to content
  • Advertisement

Archived

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

ibolcina

Radar

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

Hello. I have a problem. I have a camera and an object in space. For both I know their world transformation matrix. I would like to have a wing commander style radar. I tried this, but... Basically I am looking for somekind of function like VECTOR2D vec=Point(D3DXMATRIX camera,D3DXMATRIX ship); Radar Any help would be great! Ivan //drawing radar IDirect3DTexture8 * text=radar->GetTexture(); D3DLOCKED_RECT rect; text->LockRect(0,&rect,NULL,0); WORD* pPixel = (WORD*)rect.pBits; for( WORD j=0; j<100; j++ ) { for( WORD i=0; i<100; i++ ) { *(pPixel+(256*j+i)) = 0x832A; } //(pPixel)+=(256-100); } m_Camera->ComputeWorldMatrix(); D3DXMATRIX mat=m_Camera->GetWorldMatrix(); D3DXVECTOR3 vec; vec.x=-m_Camera->GetPosition().x; vec.y=-m_Camera->GetPosition().y; vec.z=-m_Camera->GetPosition().z; D3DXMATRIX tran; D3DXMATRIX mat1; D3DXMatrixTranslation(&tran,vec.x,vec.z,vec.z); mat=mat*tran; D3DXMatrixInverse(&mat1,NULL,&mat); //D3DXMATRIX mat; //m_Camera->ComputeViewMatrix(mat); //D3DXMATRIX mat1; //m_Camera->ComputeViewMatrix(mat1); for (Iterator * itr=ships->getIterator();itr->hasNext() { CObject * tmp=(CObject *) itr->getNext(); D3DXMATRIX mtr2=tmp->GetWorldMatrix(); //D3DXMatrixLookAtLH(&mtr,&(m_Camera->GetPosition()),&(tmp->GetPosition()),&(m_Camera->m_vy)); D3DXMATRIX mtr=mtr2*tran*mat1; //mtr*=mat1; float x=mtr(3,0); float y=mtr(3,1); float z=mtr(3,2); float y1=atan2f(y,z); y1*=50.0f; y1/=3.14f; y1+=50; float x1=atan2f(x,z); x1*=50.0f; x1/=3.14f; x1+=50; *(pPixel+((int)y1)*256+((int)x1))=0xFFFF; //m_pd3dDevice->SetTransform(D3DTS_WORLD, &tmp->GetWorldMatrix()); //tmp->Draw(m_pd3dDevice); } text->UnlockRect(0); radar->Draw(m_pd3dDevice,NULL,350,400);

Share this post


Link to post
Share on other sites
Advertisement

  • 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!