Esempio n. 1
0
void ConvertMatrixToHL(const btTransform& transform, matrix3x4_t& hl) {
	Vector forward, left, up, pos;

	ConvertDirectionToHL(transform.getBasis().getColumn(0), forward);
	ConvertDirectionToHL(-transform.getBasis().getColumn(2), left);
	ConvertDirectionToHL(transform.getBasis().getColumn(1), up);
	ConvertPosToHL(transform.getOrigin(), pos);

	hl.Init(forward, left, up, pos);
}
Esempio n. 2
0
Vector CPhysicsObject::GetInvInertia() const {
	btVector3 btvec = m_pObject->getInvInertiaDiagLocal();
	Vector hlvec;
	ConvertDirectionToHL(btvec, hlvec);
	VectorAbs(hlvec, hlvec);
	return hlvec;
}
Vector CPhysicsObject::GetInvInertia( void ) const
{
	const IVP_U_Float_Point *pRI = m_pObject->get_core()->get_inv_rot_inertia();

	Vector hlInvInertia;
	ConvertDirectionToHL( *pRI, hlInvInertia );
	VectorAbs( hlInvInertia, hlInvInertia );
	return hlInvInertia;
}
Esempio n. 4
0
void CPhysicsObject::OutputDebugInfo() const {
	Msg("-----------------\n");

	if (m_pName)
		Msg("Object: %s\n", m_pName);

	Msg("Mass: %f (inv %f)\n", GetMass(), GetInvMass());

	Vector pos;
	QAngle ang;
	GetPosition(&pos, &ang);
	Msg("Position: %f %f %f\nAngle: %f %f %f\n", pos.x, pos.y, pos.z, ang.x, ang.y, ang.z);

	Vector inertia = GetInertia();
	Vector invinertia = GetInvInertia();
	Msg("Inertia: %f %f %f (inv %f %f %f)\n", inertia.x, inertia.y, inertia.z, invinertia.x, invinertia.y, invinertia.z);

	Vector vel;
	AngularImpulse angvel;
	GetVelocity(&vel, &angvel);
	Msg("Velocity: %f, %f, %f\nAng Velocity: %f, %f, %f\n", vel.x, vel.y, vel.z, angvel.x, angvel.y, angvel.z);

	float dampspeed, damprot;
	GetDamping(&dampspeed, &damprot);
	Msg("Damping %f linear, %f angular\n", dampspeed, damprot);

	Vector dragBasis;
	Vector angDragBasis;
	ConvertPosToHL(m_dragBasis, dragBasis);
	ConvertDirectionToHL(m_angDragBasis, angDragBasis);
	Msg("Linear Drag: %f, %f, %f (factor %f)\n", dragBasis.x, dragBasis.y, dragBasis.z, m_dragCoefficient);
	Msg("Angular Drag: %f, %f, %f (factor %f)\n", angDragBasis.x, angDragBasis.y, angDragBasis.z, m_angDragCoefficient);

	// TODO: Attached to x controllers

	Msg("State: %s, Collision %s, Motion %s, Drag %s, Flags %04X (game %04x, index %d)\n", 
		IsAsleep() ? "Asleep" : "Awake",
		IsCollisionEnabled() ? "Enabled" : "Disabled",
		IsStatic() ? "Static" : IsMotionEnabled() ? "Enabled" : "Disabled",
		IsDragEnabled() ? "Enabled" : "Disabled",
		m_pObject->getFlags(),
		GetGameFlags(),
		GetGameIndex()
	);

	
	const char *pMaterialStr = g_SurfaceDatabase.GetPropName(m_materialIndex);
	surfacedata_t *surfaceData = g_SurfaceDatabase.GetSurfaceData(m_materialIndex);
	if (surfaceData) {
		Msg("Material: %s : density(%f), thickness(%f), friction(%f), elasticity(%f)\n", 
			pMaterialStr, surfaceData->physics.density, surfaceData->physics.thickness, surfaceData->physics.friction, surfaceData->physics.elasticity);
	}

	Msg("-- COLLISION SHAPE INFO --\n");
	g_PhysicsCollision.OutputDebugInfo((CPhysCollide *)m_pObject->getCollisionShape()->getUserPointer());
}
	virtual void GetSurfaceNormal( Vector &out ) 
	{ 
		if ( m_pContact )
		{
			ConvertDirectionToHL( m_pContact->surf_normal, out ); 
		}
		else
		{
			out.Init();
		}
	}
Esempio n. 6
0
Vector CPhysicsObject::GetInertia() const {
	btVector3 btvec = m_pObject->getInvInertiaDiagLocal();

	// Invert the inverse inertia to get inertia
	btvec.setX(SAFE_DIVIDE(1.0f, btvec.x()));
	btvec.setY(SAFE_DIVIDE(1.0f, btvec.y()));
	btvec.setZ(SAFE_DIVIDE(1.0f, btvec.z()));

	Vector hlvec;
	ConvertDirectionToHL(btvec, hlvec);
	VectorAbs(hlvec, hlvec);
	return hlvec;
}
//-----------------------------------------------------------------------------
// Purpose:: Convert data to HL2 measurements, and test direction of raycast.
//-----------------------------------------------------------------------------
void CPhysics_Airboat::pre_raycasts_gameside( int nRaycastCount, IVP_Ray_Solver_Template *pRays,
											  Ray_t *pGameRays, IVP_Raycast_Airboat_Impact *pImpacts )
{
	for ( int iRaycast = 0; iRaycast < nRaycastCount; ++iRaycast )
	{
		// Setup the ray.
		Vector vecStart;
		ConvertPositionToHL( pRays[iRaycast].ray_start_point, vecStart );

		Vector vecEnd;
		Vector vecDirection;
		ConvertDirectionToHL( pRays[iRaycast].ray_normized_direction, vecDirection );
		float flRayLength = IVP2HL( pRays[iRaycast].ray_length );

		// Check to see if that point is in water.
		pImpacts[iRaycast].bInWater = IVP_FALSE;
		if ( m_pGameTrace->VehiclePointInWater( vecStart ) )
		{
			vecDirection.Negate();
			pImpacts[iRaycast].bInWater = IVP_TRUE;
		}

		vecEnd = vecStart + ( vecDirection * flRayLength );

		// Shorten the trace.
		if ( m_pGameTrace->VehiclePointInWater( vecEnd ) )
		{
			pRays[iRaycast].ray_length = AIRBOAT_RAYCAST_DIST_WATER;
			flRayLength = IVP2HL( pRays[iRaycast].ray_length );
			vecEnd = vecStart + ( vecDirection * flRayLength );
		}

		Vector vecZero( 0.0f, 0.0f, 0.0f );
		pGameRays[iRaycast].Init( vecStart, vecEnd, vecZero, vecZero );
	}
}
		CPhysicsCollisionData(btManifoldPoint *manPoint) {
			ConvertDirectionToHL(manPoint->m_normalWorldOnB, m_surfaceNormal);
			ConvertPosToHL(manPoint->getPositionWorldOnA(), m_contactPoint);
			ConvertPosToHL(manPoint->m_lateralFrictionDir1, m_contactSpeed);	// FIXME: Need the correct variable from the manifold point
		}
	virtual void GetSurfaceNormal( Vector &out ) { ConvertDirectionToHL( m_pContact->surf_normal, out ); }