(Question) How to make Circle Minimap?

Started by
16 comments, last by unbird 9 years ago

Hello, I have small question.. I have game and.. I had there Square Minimap, but now I need Circle minimap. I tried something on internet, but when I used Filled Minimap, it have just color of minimap, and when I used normal rendering, it´s circle, but there is just one circle line, and in that circle isn´t anything, it´s empty. I´m using Device->SetTexture(0, pMINIMAP);

Working one : (square)


int nRng;int nPos; m_pTZOOMSCROLL->GetScrollPos(nRng, nPos);m_pTMAP->m_fTSCALE = TMINIMAP_INIT_SCALE / powf(TMINIMAP_SCALE_FACTOR, (FLOAT)nPos); CRect rect(0, 0,TMINIMAPTEX_SIZE,TMINIMAPTEX_SIZE); rect.OffsetRect(m_rc.left + m_rcAREA.left - (190 - m_rcAREA.Width()) / 0.85,  m_rc.top + m_rcAREA.top - (190 - m_rcAREA.Height()) / 0.65); TNLVERTEX vRECT[4] = {{ FLOAT(rect.left), FLOAT(rect.top), 0.5f, 1.0f, 0xFFFFFFFF, 0.0f, 0.0f},{ FLOAT(rect.right), FLOAT(rect.top), 0.5f, 1.0f, 0xFFFFFFFF, 1.0f, 0.0f},{ FLOAT(rect.left), FLOAT(rect.bottom), 0.5f, 1.0f, 0xFFFFFFFF, 0.0f, 1.0f},{ FLOAT(rect.right), FLOAT(rect.bottom), 0.5f, 1.0f, 0xFFFFFFFF, 1.0f, 1.0f}};FLOAT fMIP = 0.0f; m_pDevice->m_pDevice->SetSamplerState( 0, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD) &fMIP));m_pDevice->m_pDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);m_pDevice->m_pDevice->SetTexture( 0, m_pTMINIMAP);m_pDevice->m_pDevice->SetFVF(T3DFVF_TNLVERTEX);m_pDevice->m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2, vRECT, sizeof(TNLVERTEX));

Not working one :


int nRng;int nPos; m_pTZOOMSCROLL->GetScrollPos(nRng, nPos);m_pTMAP->m_fTSCALE = TMINIMAP_INIT_SCALE / powf(TMINIMAP_SCALE_FACTOR, (FLOAT)nPos); CPoint rect(TMINIMAPTEX_SIZE); rect.Offset(m_rc.left + m_rcAREA.left - (190 - m_rcAREA.Width()) / 0.85, m_rc.top + m_rcAREA.top - (190 - m_rcAREA.Height()) / 0.65);    const int NUMPOINTS = 30;     TNLVERTEX Circle[NUMPOINTS + 1];     float WedgeAngle = ( float )( ( 2 * D3DX_PI ) / NUMPOINTS ); FLOAT fMIP = 0.0f;      for( int i = 0; i m_pDevice->SetSamplerState( 0, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD) &fMIP));m_pDevice->m_pDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);m_pDevice->m_pDevice->SetTexture( 0, m_pTMINIMAP);m_pDevice->m_pDevice->SetFVF(D3DFVF_TL);    m_pDevice->m_pDevice->DrawPrimitiveUP( D3DPT_LINESTRIP, NUMPOINTS, Circle, sizeof( TNLVERTEX ) );Thanks for any help!
Advertisement

I guess you can use multi-texturing with a quad. Have a texture with the shape of what you want and use it as alpha. You may need to move away from fixed pipeline. Or use the stencil buffer.

I´m +- newbie in D3D programming, can you little help me? But thanks for help.

1. Use a triangle fan (D3DPT_TRIANGLEFAN).
2. Use correct tex coords, something like this:


Circle[i].m_fU = (float)( 0.5 + 0.5 * cos( Theta ) );
Circle[i].m_fV = (float)( 0.5 - 0.5 * sin( Theta ) );
(Edit: Copy paste fail correction)
3. Your primitive count is off by one. Use NUMPOINTS + 1. Hmmm, wait, no you don't need to duplicate the start point for a fan.

I edited both, but now it don´t appear, I can´t see anything. I tried just with TriangleFan and U and V same as before, and it don´t work too. If we will resolve it, I can give you some money.

Save the money for your girlfriend wink.png

Ok, general debugging hints:

1. Always check the HRESULT returned from API calls (With the FAILED/SUCCEEDED macro).
2. Use the D3D debug layer, for D3D9 this is enabled with the DirectX Control Panel. Then watch the output log in Visual Studio.
3. Use PIX or another graphics debugger.

Hmmm, I might have done a mistake with the primitive count. The amount is number_of_vertices - 2 for fans. Sorry 'bout that.

That is +- problem, because this game is really big and it can´t be debugged in VS, cause it have big datafolder. anyway, maybe it can be problem too, I´m using VS 2003. And I will give you money, I´m not rich, but something I can give you :D
And thanks for all your help!

PIX and the debug layer work without VS. You can grab debug messages with DebugView.

So it can look like this?


    const int NUMPOINTS = 30;     TNLVERTEX Circle[NUMPOINTS + 1];     float WedgeAngle = ( float )( ( 2 * D3DX_PI ) / NUMPOINTS ); FLOAT fMIP = 0.0f;      for( int i = 0; i m_pDevice->SetSamplerState( 0, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD) &fMIP));m_pDevice->m_pDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);m_pDevice->m_pDevice->SetTexture( 0, m_pTMINIMAP);m_pDevice->m_pDevice->SetFVF(D3DFVF_TL);    m_pDevice->m_pDevice->DrawPrimitiveUP( D3DPT_TRIANGLEFAN, NUMPOINTS-2, Circle, sizeof( TNLVERTEX ) ); 

The primitive count is probably fine, but the texcoords are bad again.

And seriously, start proper error checking of those HRESULTs.

Hmmm, maybe a culling problem: Try disable culling (SetRenderState) or reverse the winding of those points (negate Theta).

This topic is closed to new replies.

Advertisement