示例#1
0
void drawESP()
{
	    for ( unsigned int i = 0; i <= 64; i ++ )
        {
            fb::ClientPlayer* localPlayer;
            fb::ClientPlayer* targetPlayer;
			BOSS* cheats = &BOSS();

            localPlayer  = cheats->getLocalPlayer( );
            targetPlayer = cheats->getPlayerById( i );

			if ( VALID( localPlayer ) && VALID( targetPlayer ) && localPlayer != targetPlayer )
            {
                fb::ClientSoldierEntity* localSoldier;
                fb::ClientSoldierEntity* targetSoldier;

                localSoldier  = cheats->getSoldier( localPlayer );
                targetSoldier = cheats->getSoldier( targetPlayer );

                if ( VALID( localSoldier ) && VALID( targetSoldier ) )
                {
                    fb::DebugRenderer2* engineRender = fb::DebugRenderer2::Singleton( );

                    if ( VALID( engineRender ) )
                    {
                        float screenX, screenY;
						engineRender->drawText( 5, i*20, fb::Color32( 255, 0, 255, 255 ), targetPlayer->m_name.GetString( ), 1 );
						if( VALID(targetSoldier->m_characterPhysicsentity) )
						{
							fb::AxisAlignedBox AABB = targetSoldier->m_characterPhysicsentity->m_collisionShapes->m_aabbs[0]; 
							fb::AxisAlignedBox R;

							R.min = Vec3Transform( AABB.min, targetSoldier->m_characterPhysicsentity->m_gameWorldTransform);

							engineRender->drawSphere(R.min,5,fb::Color32(0,0,255,255));
						}
						/*						
                        if ( cheats->worldToScreen( targetSoldier, &screenX, &screenY ) )
                        {
                            engineRender->drawText( screenX, screenY, fb::Color32( 255, 0, 255, 255 ), targetPlayer->m_name.GetString( ), 1 );
                        }*/
                    }

                }
            }
        }  
}
示例#2
0
void FbxModel::NonTextureAnimationDraw()
{
	if (m_pFbxModelData->Animation->SkinNum != 0)
	{
		m_pDevice->SetTexture(0, NULL);
		m_pDevice->SetTexture(1, NULL);
		m_pDevice->SetTexture(2, NULL);


		//-------- アニメーション処理 --------//

		for (int i = 0; i < m_pFbxModelData->ControlPointCount; i++)
		{
			m_pDrawVertex[i].Vec.x = 0.f;
			m_pDrawVertex[i].Vec.y = 0.f;
			m_pDrawVertex[i].Vec.z = 0.f;
		}

		for (int i = 0; i < m_pFbxModelData->Animation->pSkinData[0].ClusterNum; i++)
		{
			D3DXMATRIX InvMat;
			D3DXMatrixInverse(&InvMat, NULL, &m_pFbxModelData->Animation->pSkinData[0].pCluster[i].InitMatrix);

			for (int j = 0; j < m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointNum; j++)
			{
				D3DVECTOR TmpVertex;
				Vec3Transform(
					&TmpVertex,
					&m_pVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
					&InvMat
					);

				Vec3Transform(
					&m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
					&TmpVertex,
					&(m_pFbxModelData->Animation->pSkinData[0].pCluster[i].pMat[m_FrameCount] * m_pFbxModelData->Animation->pSkinData[0].pCluster[i].WeightAry[j])
					);


				m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x;
				m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y;
				m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z;
			}
		}


		if (m_FrameCount == m_pFbxModelData->Animation->pSkinData[0].EndFrame - 1)
		{
			m_FrameCount = 0;
		}
		else
		{
			m_FrameCount++;
		}

		m_pDevice->DrawIndexedPrimitiveUP(
			D3DPT_TRIANGLELIST,
			0,
			m_pFbxModelData->pIndex.IndexCount,
			m_pFbxModelData->pIndex.IndexCount / 3,
			m_pFbxModelData->pIndex.IndexAry,
			D3DFMT_INDEX16,
			m_pDrawVertex,
			sizeof(UserVertex));
	}
}
示例#3
0
void FbxModel::AnimationDraw()
{
	if (m_pFbxModelData->Animation->SkinNum != 0)
	{
		for (unsigned int n = 0; n < m_pFbxModelData->pTextureData.size(); n++)
		{
			m_pDevice->SetTexture(n, m_pFbxModelData->pTextureData[n]->pTexture);
		}

		//-------- アニメーション処理 --------//


		switch (m_pFbxModelData->CustomUser.m_Type)
		{
		case USERVERTEX_1:


			for (int i = 0; i < m_pFbxModelData->ControlPointCount; i++)
			{
				m_pDrawVertex[i].Vec.x = 0.f;
				m_pDrawVertex[i].Vec.y = 0.f;
				m_pDrawVertex[i].Vec.z = 0.f;
			}

			for (int i = 0; i < m_pFbxModelData->Animation->pSkinData[0].ClusterNum; i++)
			{
				D3DXMATRIX InvMat;
				D3DXMatrixInverse(&InvMat, NULL, &m_pFbxModelData->Animation->pSkinData[0].pCluster[i].InitMatrix);

				for (int j = 0; j < m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointNum; j++)
				{
					D3DVECTOR TmpVertex;
					Vec3Transform(
						&TmpVertex,
						&m_pVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&InvMat
						);

					Vec3Transform(
						&m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&TmpVertex,
						&(m_pFbxModelData->Animation->pSkinData[0].pCluster[i].pMat[m_FrameCount] * m_pFbxModelData->Animation->pSkinData[0].pCluster[i].WeightAry[j])
						);


					m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x;
					m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y;
					m_pDrawVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z += m_pTmpVertex[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z;
				}
			}

			m_pDevice->DrawIndexedPrimitiveUP(
				D3DPT_TRIANGLELIST,
				0,
				m_pFbxModelData->pIndex.IndexCount,
				m_pFbxModelData->pIndex.IndexCount / 3,
				m_pFbxModelData->pIndex.IndexAry,
				D3DFMT_INDEX16,
				m_pDrawVertex,
				sizeof(UserVertex));


			break;
		case USERVERTEX_2:



			for (int i = 0; i < m_pFbxModelData->ControlPointCount; i++)
			{
				m_pDrawVertex2[i].Vec.x = 0.f;
				m_pDrawVertex2[i].Vec.y = 0.f;
				m_pDrawVertex2[i].Vec.z = 0.f;
			}

			for (int i = 0; i < m_pFbxModelData->Animation->pSkinData[0].ClusterNum; i++)
			{
				D3DXMATRIX InvMat;
				D3DXMatrixInverse(&InvMat, NULL, &m_pFbxModelData->Animation->pSkinData[0].pCluster[i].InitMatrix);

				for (int j = 0; j < m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointNum; j++)
				{
					D3DVECTOR TmpVertex;
					Vec3Transform(
						&TmpVertex,
						&m_pVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&InvMat
						);

					Vec3Transform(
						&m_pTmpVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&TmpVertex,
						&(m_pFbxModelData->Animation->pSkinData[0].pCluster[i].pMat[m_FrameCount] * m_pFbxModelData->Animation->pSkinData[0].pCluster[i].WeightAry[j])
						);


					m_pDrawVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x += m_pTmpVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x;
					m_pDrawVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y += m_pTmpVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y;
					m_pDrawVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z += m_pTmpVertex2[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z;
				}
			}

			m_pDevice->DrawIndexedPrimitiveUP(
				D3DPT_TRIANGLELIST,
				0,
				m_pFbxModelData->pIndex.IndexCount,
				m_pFbxModelData->pIndex.IndexCount / 3,
				m_pFbxModelData->pIndex.IndexAry,
				D3DFMT_INDEX16,
				m_pDrawVertex2,
				sizeof(UserVertex2));


			break;
		case USERVERTEX_3:



			for (int i = 0; i < m_pFbxModelData->ControlPointCount; i++)
			{
				m_pDrawVertex3[i].Vec.x = 0.f;
				m_pDrawVertex3[i].Vec.y = 0.f;
				m_pDrawVertex3[i].Vec.z = 0.f;
			}

			for (int i = 0; i < m_pFbxModelData->Animation->pSkinData[0].ClusterNum; i++)
			{
				D3DXMATRIX InvMat;
				D3DXMatrixInverse(&InvMat, NULL, &m_pFbxModelData->Animation->pSkinData[0].pCluster[i].InitMatrix);

				for (int j = 0; j < m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointNum; j++)
				{
					D3DVECTOR TmpVertex;
					Vec3Transform(
						&TmpVertex,
						&m_pVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&InvMat
						);

					Vec3Transform(
						&m_pTmpVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec,
						&TmpVertex,
						&(m_pFbxModelData->Animation->pSkinData[0].pCluster[i].pMat[m_FrameCount] * m_pFbxModelData->Animation->pSkinData[0].pCluster[i].WeightAry[j])
						);


					m_pDrawVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x += m_pTmpVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.x;
					m_pDrawVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y += m_pTmpVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.y;
					m_pDrawVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z += m_pTmpVertex3[m_pFbxModelData->Animation->pSkinData[0].pCluster[i].PointAry[j]].Vec.z;
				}
			}

			m_pDevice->DrawIndexedPrimitiveUP(
				D3DPT_TRIANGLELIST,
				0,
				m_pFbxModelData->pIndex.IndexCount,
				m_pFbxModelData->pIndex.IndexCount / 3,
				m_pFbxModelData->pIndex.IndexAry,
				D3DFMT_INDEX16,
				m_pDrawVertex3,
				sizeof(UserVertex3));
			break;
		}

		
	}
}
void ProcessVertexDataNoSSE(uint32_t dwAddr, uint32_t dwV0, uint32_t dwNum)
{

    UpdateCombinedMatrix();

    // This function is called upon SPvertex
    // - do vertex matrix transform
    // - do vertex lighting
    // - do texture coordinate transform if needed
    // - calculate normal vector

    // Output:  - g_vecProjected[i]             -> transformed vertex x,y,z
    //          - g_vecProjected[i].w           -> saved vertex 1/w
    //          - g_dwVtxFlags[i]               -> flags
    //          - g_dwVtxDifColor[i]            -> vertex color
    //          - g_fVtxTxtCoords[i]            -> vertex texture coordinates

    uint8_t *rdram_u8 = (uint8_t*)gfx_info.RDRAM;
    FiddledVtx * pVtxBase = (FiddledVtx*)(rdram_u8 + dwAddr);
    g_pVtxBase = pVtxBase;

    for (uint32_t i = dwV0; i < dwV0 + dwNum; i++)
    {
        SP_Timing(RSP_GBI0_Vtx);

        FiddledVtx & vert = pVtxBase[i - dwV0];

        g_vtxNonTransformed[i].x = (float)vert.x;
        g_vtxNonTransformed[i].y = (float)vert.y;
        g_vtxNonTransformed[i].z = (float)vert.z;

        Vec3Transform(&g_vtxTransformed[i], (XVECTOR3*)&g_vtxNonTransformed[i], &gRSPworldProject); // Convert to w=1

        g_vecProjected[i].w = 1.0f / g_vtxTransformed[i].w;
        g_vecProjected[i].x = g_vtxTransformed[i].x * g_vecProjected[i].w;
        g_vecProjected[i].y = g_vtxTransformed[i].y * g_vecProjected[i].w;
        if ((g_curRomInfo.bPrimaryDepthHack || options.enableHackForGames == HACK_FOR_NASCAR ) && gRDP.otherMode.depth_source )
        {
            g_vecProjected[i].z = gRDP.fPrimitiveDepth;
            g_vtxTransformed[i].z = gRDP.fPrimitiveDepth*g_vtxTransformed[i].w;
        }
        else
        {
            g_vecProjected[i].z = g_vtxTransformed[i].z * g_vecProjected[i].w;
        }

        if( gRSP.bFogEnabled )
        {
            g_fFogCoord[i] = g_vecProjected[i].z;
            if( g_vecProjected[i].w < 0 || g_vecProjected[i].z < 0 || g_fFogCoord[i] < gRSPfFogMin )
                g_fFogCoord[i] = gRSPfFogMin;
        }

        RSP_Vtx_Clipping(i);

        if( gRSP.bLightingEnable )
        {
            g_normal.x = (float)vert.norma.nx;
            g_normal.y = (float)vert.norma.ny;
            g_normal.z = (float)vert.norma.nz;

            Vec3TransformNormal(g_normal, gRSPmodelViewTop);
            g_dwVtxDifColor[i] = LightVert(g_normal, i);
            *(((uint8_t*)&(g_dwVtxDifColor[i]))+3) = vert.rgba.a; // still use alpha from the vertex
        }
        else
        {
            if( (gRDP.geometryMode & G_SHADE) == 0 && gRSP.ucode < 5 )  //Shade is disabled
            {
                //FLAT shade
                g_dwVtxDifColor[i] = gRDP.primitiveColor;
            }
            else
            {
                register IColor &color = *(IColor*)&g_dwVtxDifColor[i];
                color.b = vert.rgba.r;
                color.g = vert.rgba.g;
                color.r = vert.rgba.b;
                color.a = vert.rgba.a;
            }
        }

        if( options.bWinFrameMode )
        {
            g_dwVtxDifColor[i] = COLOR_RGBA(vert.rgba.r, vert.rgba.g, vert.rgba.b, vert.rgba.a);
        }

        ReplaceAlphaWithFogFactor(i);

        // Update texture coords n.b. need to divide tu/tv by bogus scale on addition to buffer

        // If the vertex is already lit, then there is no normal (and hence we
        // can't generate tex coord)
        if (gRSP.bTextureGen && gRSP.bLightingEnable )
        {
            TexGen(g_fVtxTxtCoords[i].x, g_fVtxTxtCoords[i].y);
        }
        else
        {
            g_fVtxTxtCoords[i].x = (float)vert.tu;
            g_fVtxTxtCoords[i].y = (float)vert.tv; 
        }
    }
}
uint32_t LightVert(XVECTOR4 & norm, int vidx)
{
    float fCosT;

    // Do ambient
    register float r = gRSP.fAmbientLightR;
    register float g = gRSP.fAmbientLightG;
    register float b = gRSP.fAmbientLightB;

    if( options.enableHackForGames != HACK_FOR_ZELDA_MM )
    {
        for (register unsigned int l=0; l < gSP.numLights; l++)
        {
            fCosT = norm.x*gRSPlights[l].x + norm.y*gRSPlights[l].y + norm.z*gRSPlights[l].z; 

            if (fCosT > 0 )
            {
                r += gRSPlights[l].fr * fCosT;
                g += gRSPlights[l].fg * fCosT;
                b += gRSPlights[l].fb * fCosT;
            }
        }
    }
    else
    {
        XVECTOR4 v;
        bool transformed = false;

        for (register unsigned int l=0; l < gSP.numLights; l++)
        {
            if( gRSPlights[l].range == 0 )
            {
                // Regular directional light
                fCosT = norm.x*gRSPlights[l].x + norm.y*gRSPlights[l].y + norm.z*gRSPlights[l].z; 

                if (fCosT > 0 )
                {
                    r += gRSPlights[l].fr * fCosT;
                    g += gRSPlights[l].fg * fCosT;
                    b += gRSPlights[l].fb * fCosT;
                }
            }
            else //if( (gRSPlights[l].col&0x00FFFFFF) != 0x00FFFFFF )
            {
                // Point light
                if( !transformed )
                {
                    Vec3Transform(&v, (XVECTOR3*)&g_vtxNonTransformed[vidx], &gRSPmodelViewTop);    // Convert to w=1
                    transformed = true;
                }

                XVECTOR3 dir(gRSPlights[l].x - v.x, gRSPlights[l].y - v.y, gRSPlights[l].z - v.z);
                //XVECTOR3 dir(v.x-gRSPlights[l].x, v.y-gRSPlights[l].y, v.z-gRSPlights[l].z);
                float d2 = sqrtf(dir.x*dir.x+dir.y*dir.y+dir.z*dir.z);
                dir.x /= d2;
                dir.y /= d2;
                dir.z /= d2;

                fCosT = norm.x*dir.x + norm.y*dir.y + norm.z*dir.z; 

                if (fCosT > 0 )
                {
                    //float f = d2/gRSPlights[l].range*50;
                    float f = d2/15000*50;
                    f = 1 - MIN(f,1);
                    fCosT *= f*f;

                    r += gRSPlights[l].fr * fCosT;
                    g += gRSPlights[l].fg * fCosT;
                    b += gRSPlights[l].fb * fCosT;
                }
            }
        }
    }

    if (r > 255) r = 255;
    if (g > 255) g = 255;
    if (b > 255) b = 255;
    return ((0xff000000)|(((uint32_t)r)<<16)|(((uint32_t)g)<<8)|((uint32_t)b));
}