Esempio n. 1
0
//*****************************************************************************
// Creator: JAM
// Calculates velocity needed for simple ballistic motion so that the object
// goes from pStartPos to pEndPos with the given gravity. The top of the arc
// is at MAX(in_startPos->y,in_endPos->y) + in_jumpHeight
// Note: Takes a positive gravity.
// Note: If you count up the timeElapsed, the jump will end when
// (totalTimeElapsed == out_totalJumpTime)
//
// Note: your update code should look like this:
// VEC_AddScaledXYZ(&pPvars->boulderShrapnel.pMoby->matrix.pos,&pContent->jumpVelocity,G_dtMultiplier);
// pContent->jumpVelocity.y -= gravity*G_dtMultiplier;
// pContent->elapsedJumpTime += timeElapsed;
//
// Note: For extra accuracy with landing, make sure you subtract off your timeElapsed when/if it
// goes above out_totalJumpTime
//
// Returns NOTHING!
//*****************************************************************************
void GU_LaunchToPoint(vec3* out_jumpVel, f32* out_totalJumpTime, const vec3* in_startPos, const vec3* in_endPos, f32 in_jumpHeight, f32 in_gravity)
{
	const f32 highestY = MaxF(in_startPos->y, in_endPos->y);
	const f32 apexY = highestY + in_jumpHeight;
	
	const f32 s1 = apexY - in_startPos->y;
	const f32 s2 = apexY - in_endPos->y;
	const f32 s3 = in_endPos->z-in_startPos->z;
	const f32 s4 = in_endPos->x-in_startPos->x;
	
	const f32 t1 = sqrtf(2.0f * s1 / in_gravity);
	const f32 t2 = sqrtf(2.0f * s2 / in_gravity);
	
	const f32 totalTime = t1 + t2;
	
	
	if(out_jumpVel)
	{
		out_jumpVel->y = in_gravity * t1;
		out_jumpVel->z = s3/totalTime;
		out_jumpVel->x = s4/totalTime;
	}
	
	if(out_totalJumpTime)
	{
		*out_totalJumpTime = totalTime;
	}
}
Esempio n. 2
0
	inline const C3DFLOAT32 FilterWidth() const
	{
		C3DVECTOR4 kDdx, kDdy;
		GetDerivatives(0, kDdx, kDdy);
		C3DFLOAT32 fChangeX = (*(C3DVECTOR2*)&kDdx).Length();
		C3DFLOAT32 fChangeY = (*(C3DVECTOR2*)&kDdy).Length();
		return MaxF(fChangeX, fChangeY);
	}
Esempio n. 3
0
	inline const C3DVECTOR2 BumpInt(const C3DVECTOR2& rkIn) const
	{
		C3DVECTOR2 kFloorVec(FloorF(rkIn.x * 0.5f), FloorF(rkIn.y * 0.5f));
		return C3DVECTOR2(kFloorVec.x + MaxF(rkIn.x - 2.0f * kFloorVec.x - 1.0f, 0.0f), 
						  kFloorVec.y + MaxF(rkIn.y - 2.0f * kFloorVec.y - 1.0f, 0.0f));
	}