Exemplo n.º 1
0
void Bullet_Update(Object *pObject)
{
	Projectile *pProjectile=(Projectile *)pObject;

	Matrix mat;
	Matrix *pLast;

	Object_GetMatrix(pObject,&mat);
	mat.SetColumn(3, mat.GetColumn(3) + pProjectile->vecVel);

	Object_GetMatrixPtrLast(pObject,&pLast);

	if(Level_TestLineCollide( pLast->GetColumn(3), mat.GetColumn(3) ))
	{
		ColData Data;

		// Get the collision data
		Collision_GetColData(&Data);

		// Create particle effect at collision position
		Particles_Create( 1, Data.vecPoint );

		pProjectile->fLife = -1.f;
	}

	Object_SetMatrix(pObject, &mat);
}
Exemplo n.º 2
0
void Rocket_GetRenderTrans(void *pData, Vec3 *pVec)
{
	Object *pObj = (Object*)pData;
	Matrix *pMat;

	Object_GetInterpMatrix(pObj, &pMat);
	*pVec = pMat->GetColumn(3);
}
Exemplo n.º 3
0
Projectile* Projectile_Create( PROJECTILE_TYPES type, Object *pCreator, Vec4 *pvecOffset )
{
	Projectile *pProjectile;
	ObjectCreate Create;

	memset(&Create,0,sizeof(Create));
	Create.exitfunc=Projectile_Exit;
	Create.renderfunc=Projectile_Render;
	Create.updatefunc=Projectile_Update;
	Create.iType=OBJECT_Projectile;
	Create.pName="Projectile";

	pProjectile = (Projectile*)Object_Create(&Create, sizeof(Projectile));

	pProjectile->type = type;
	pProjectile->pCreator = pCreator;

	Matrix *pMat;
	Matrix Mat;

	Object_GetMatrixPtr((Object *)pCreator, &pMat);

	Mat = *pMat;
	Mat.SetColumn(3, *pMat * (*pvecOffset));
	Object_SetAllMatrix((Object *)pProjectile, &Mat);

	Vec3 vecDir;

	switch(type)
	{
	case PROJECTILE_BULLET:
		pProjectile->fLife = 1.f;
		pProjectile->vecVel = Mat.GetColumn(2) * 7.f; 
		break;

	case PROJECTILE_ROCKET:
		pProjectile->fLife = 3.f;
		pProjectile->vecVel = Mat.GetColumn(2) * 5.f; 

		pProjectile->pTrails[0] = Trail_Create( 0.08f, false, SWITCHCOL(0x1faaaaaa), "data/textures/stream.tga" );
		pProjectile->pTrails[1] = Trail_Create( 0.08f, false, SWITCHCOL(0x1faaaaaa), "data/textures/stream.tga" );

		vecDir = (Mat.GetColumn(0)*0.25f);

		Trail_AddPoint((Object*)pProjectile->pTrails[0], Mat.GetColumn(3), vecDir);

		vecDir = (Mat.GetColumn(1)*0.25f);
		Trail_AddPoint((Object*)pProjectile->pTrails[1], Mat.GetColumn(3), vecDir);

		pProjectile->pTrails[0]->leadingPointCallback = Rocket_GetRenderTrans;
		pProjectile->pTrails[0]->pSendData = pProjectile;

		pProjectile->pTrails[1]->leadingPointCallback = Rocket_GetRenderTrans;
		pProjectile->pTrails[1]->pSendData = pProjectile;
		break;
	}

	return pProjectile;
}
Exemplo n.º 4
0
void Rocket_Update(Object *pObject)
{
	Projectile *pProjectile=(Projectile *)pObject;

	Matrix mat;
	Matrix *pLast;

	Object_GetMatrix(pObject,&mat);
	mat.SetColumn(3, mat.GetColumn(3) + pProjectile->vecVel);

	Object_GetMatrixPtrLast(pObject,&pLast);

	Vec3 vecDir(mat.GetColumn(0)*0.25f);

	Trail_AddPoint((Object*)pProjectile->pTrails[0], pLast->GetColumn(3), vecDir);

	vecDir = (mat.GetColumn(1)*0.25f);
	Trail_AddPoint((Object*)pProjectile->pTrails[1], pLast->GetColumn(3), vecDir);

	if(Level_TestLineCollide( pLast->GetColumn(3), mat.GetColumn(3) ))
	{
		pProjectile->fLife = -1.f;

		ColData Data;

		// Get the collision data
		Collision_GetColData(&Data);

		vecDir = (mat.GetColumn(0)*0.25f);

		Trail_AddPoint((Object*)pProjectile->pTrails[0], Data.vecPoint, vecDir);

		vecDir = (mat.GetColumn(1)*0.25f);
		Trail_AddPoint((Object*)pProjectile->pTrails[1], Data.vecPoint, vecDir);

		// NIK: Create particle effect at collision position
		Particles_Create( 0, Data.vecPoint );
	}

	Object_SetMatrix(pObject, &mat);
}
Exemplo n.º 5
0
void Mesh_Light(Model *pModel, Matrix &mat)
{
	i32 i;
	i32 j;
	float *pNormal=pModel->p_fNormals;
	u8 *pCol=(u8*)pModel->p_uColours;
	float xNormal;
	float yNormal;
	float zNormal;
	float xLightDot;
	u8 uCol;
	for(j=0;j<pModel->iMeshes;j++)
	{
		for(i=0;i<pModel->pMesh[j]->iNumVerts;i++)
		{
			// get rotated normal
			xNormal=mat.GetColumn(0).GetX()*pNormal[0] + 
				mat.GetColumn(0).GetY()*pNormal[1] + 
				mat.GetColumn(0).GetZ()*pNormal[2];
			yNormal=mat.GetColumn(1).GetX()*pNormal[0] + 
				mat.GetColumn(1).GetY()*pNormal[1] + 
				mat.GetColumn(1).GetZ()*pNormal[2];
			zNormal=mat.GetColumn(2).GetX()*pNormal[0] + 
				mat.GetColumn(2).GetY()*pNormal[1] + 
				mat.GetColumn(2).GetZ()*pNormal[2];

			// get dot product of normal and light
			xLightDot=xNormal*LightDir[0] + yNormal*LightDir[1] + zNormal*LightDir[2];
			if(xLightDot<0.f)
			{
				uCol=-(u8)(xLightDot*255);
				pCol[0]=uCol;
				pCol[1]=uCol;
				pCol[2]=uCol;
			}
			else
			{
				pCol[0]=0;
				pCol[1]=0;
				pCol[2]=0;
			}
			
			pNormal+=3;
			pCol+=4;
		}
	}
}