Просмотр сообщений

В этом разделе можно просмотреть все сообщения, сделанные этим пользователем.


Темы - Saint

Страницы: [1]
1
всем привет, как некоторые может знаю может нет, работаю над мультиплеерным модом для вайса https://vk.com/vicemultiplayer (аналог samp)
за основу были взяты исходники vc-mp 0.1c часть кода используется от samp
решил попробовать реализовать 3d текст в игре, но вот что-то не получается никак


функция отрисовки
void CNameTags::Draw()
{//------------------------------------------------------------------------------------------------------------------------

if (!bbfont)
{
bbfont = new CBBFont(m_pD3DDevice, "vmpfnt"); // RC 3 Update // наименование шрифта vmpfnt.png / .dat
bbfont->Initialise();
}

//---------------------------------------------------------------------------------------------------------------------

if (!BarOldStateBlock)
{
m_pD3DDevice->BeginStateBlock();

m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
m_pD3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, 3);
m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, 1);
m_pD3DDevice->SetRenderState(D3DRS_WRAP0, 0);
m_pD3DDevice->SetRenderState(D3DRS_CLIPPING, 1);
m_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
m_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
m_pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 15);
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, 5);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, 6);
m_pD3DDevice->SetRenderState(D3DRS_BLENDOP, 1);

m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 4);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, 1);

m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
m_pD3DDevice->SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE);
m_pD3DDevice->SetStreamSource(0, NULL, 0);

m_pD3DDevice->EndStateBlock(&BarOldStateBlock);
}

//---------------------------------------------------------------------------------------------------------------------

if (!BarNewStateBlock)
{
m_pD3DDevice->BeginStateBlock();

m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
m_pD3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, 3);
m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, 1);
m_pD3DDevice->SetRenderState(D3DRS_WRAP0, 0);
m_pD3DDevice->SetRenderState(D3DRS_CLIPPING, 1);
m_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
m_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
m_pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 15);
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, 5);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, 6);
m_pD3DDevice->SetRenderState(D3DRS_BLENDOP, 1);

m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 1);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, 1);

m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
m_pD3DDevice->SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE);

m_pD3DDevice->EndStateBlock(&BarNewStateBlock);
}

//---------------------------------------------------------------------------------------------------------------------

m_pD3DDevice->CaptureStateBlock(BarOldStateBlock);
m_pD3DDevice->ApplyStateBlock(BarNewStateBlock);

//---------------------------------------------------------------------------------------------------------------------

D3DXMATRIX matTransposed;
D3DXMatrixTranspose(&matTransposed, (D3DXMATRIX*)&matView);
matTransposed._14 = matTransposed._24 = matTransposed._34 = 0.0f;

//---------------------------------------------------------------------------------------------------------------------

if (pNetGame)
{
CPlayerPool * pPlayerPool = pNetGame->GetPlayerPool();

for (int x = 0; x < MAX_PLAYERS; x++)
{
if (pPlayerPool->GetSlotState(x) == TRUE) // player is in use
{
CRemotePlayer * pRemotePlayer = pPlayerPool->GetAt(x);

if (pRemotePlayer)
{
// in samp -> m_fNameTagDrawDistance = 70.0f;
if ( pRemotePlayer->IsActive() && (pRemotePlayer->m_bRemotePlayerPedVisible) && (pRemotePlayer->m_bRemotePlayerPedVisibleVW) && (pRemotePlayer->GetDistanceFromLocalPlayer() <= 70.0f) ) // Active and within reasonable distance
{
CPlayerPed * pRemotePlayerPed = pRemotePlayer->GetRemotePlayerPed();
                   
if (pRemotePlayerPed->IsOnScreen())
{
// They're onscreen // если пед на Экране

MATRIX4X4 matPlayer; // VECTOR vPos;
pRemotePlayerPed->GetMatrix(&matPlayer); // PlayerPed->GetPosition(&vPos);

// Set the matrix position
matTransposed._41 = matPlayer.vPos.X;
matTransposed._42 = matPlayer.vPos.Y;
matTransposed._43 = matPlayer.vPos.Z + 1.0f;

// Set the world transformation
m_pD3DDevice->SetTransform(D3DTS_WORLD, &matTransposed);

//---------------------------------------------------------------------------------------------

float Health = pRemotePlayer->GetRemotePlayerHealth(); // RC 3 T3 Update
float Armour = pRemotePlayer->GetRemotePlayerArmour(); // RC 3 T3 Update

if (Health > 100.0f) Health = 100.0f;
if (Armour > 100.0f) Armour = 100.0f; // New Saint Add

// Set the health bar offsets
BarBGVertices[0].x = BarBGVertices[1].x = (0.0058f * Health) - 0.29f;

// Set the health bar color
BarVertices[0].c = BarVertices[1].c = BarVertices[2].c = BarVertices[3].c = HEALTH_BAR_COLOR;

m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarBDRVertices, sizeof(BarVertices_s)); // Draw the health bar border
m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarVertices,    sizeof(BarVertices_s)); // Draw the health bar fill
m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarBGVertices,  sizeof(BarVertices_s)); // Draw the health bar background

if (Armour > 0.0f)
{
matTransposed._41 = matPlayer.vPos.X;
matTransposed._42 = matPlayer.vPos.Y;
matTransposed._43 = matPlayer.vPos.Z + 1.1f;

// Set the world transformation
m_pD3DDevice->SetTransform(D3DTS_WORLD, &matTransposed);

// Set the armour bar offsets
BarBGVertices[0].x = BarBGVertices[1].x = (0.0058f * Armour) - 0.29f;

// Set the armour bar color
BarVertices[0].c = BarVertices[1].c = BarVertices[2].c = BarVertices[3].c = ARMOUR_BAR_COLOR;

m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarBDRVertices, sizeof(BarVertices_s)); // Draw the armour bar border
m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarVertices,    sizeof(BarVertices_s)); // Draw the armour bar fill
m_pD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, BarBGVertices,  sizeof(BarVertices_s)); // Draw the armour bar background
}

//---------------------------------------------------------------------------------------------

if (bbfont)
{
bbfont->Begin();

sprintf(szBuffer, "%s(%d)", pPlayerPool->GetPlayerName(x), x); // name + player id

bbfont->Draw(szBuffer, 0.100f, pRemotePlayer->GetPlayerColorAsARGB());

bbfont->End();
}
/*
D3DXVECTOR3 NamePos;
//NamePos.x = matPlayer.vPos.X;
//NamePos.y = matPlayer.vPos.Y;
//NamePos.z = matPlayer.vPos.Z;
NamePos.x = matTransposed._41;
NamePos.y = matTransposed._42;
NamePos.z = matTransposed._43;

D3DVIEWPORT8 Viewport;
m_pD3DDevice->GetViewport(&Viewport);

D3DXVECTOR3 Out;
D3DXMATRIX matIdent;
D3DXMatrixIdentity(&matIdent);

D3DXVec3Project(&Out, &NamePos, &Viewport, &matProj, &matView, &matIdent);

if (Out.z > 1.0f)
return;

RECT rect = {(int)Out.x, (int)Out.y, (int)Out.x+1, (int)Out.y+1}; // определяем прямоугольник

SIZE size = pDefaultFont->MeasureText(szBuffer);
rect.left -= size.cx/2;

//rect.left += 200;
//rect.top += 100;
//rect.right += pGame->GetScreenWidth(); // ширина
//rect.bottom += pGame->GetScreenHeight(); // высота

pDefaultFont->RenderText(szBuffer, rect, pRemotePlayer->GetPlayerColorAsARGB());
*/
}
}
}
}
}
}

m_pD3DDevice->ApplyStateBlock(BarOldStateBlock);

}//------------------------------------------------------------------------------------------------------------------------

суть в том что закоменнтированная часть кода в SA работает, а вот в Вайсе нет
кто что подскажет?

2
Общие вопросы / RoadBlock
« : Декабрь 26, 2013, 04:01:11 am »
как запретить игре создавать такие дорожные блокады??
(при условии что уровень розыска игрока будет != 0)



3
Общие вопросы / CheckPoint (Marker) Size
« : Октябрь 05, 2013, 11:59:42 pm »
как изменить/задать/поменять размер этого жёлтого чекпоинта (маркера)?


Страницы: [1]