Ejemplo n.º 1
0
void TestTank::Render()
{


	//Call parent render.
	BaseTank::Render();

	//Draw the left cannon.

	if (mDrawTarget)
		mTargetSprite->Render(Vector2D(mTargetPos.x + mTargetSprite->GetWidth() / 2, mTargetPos.y + mTargetSprite->GetHeight() / 2)); //+ 16


																																	  //DrawDebugCircle(Vector2D(GetCentrePosition().x - mHeading.x * 20, GetCentrePosition().y - mHeading.y* 20), 10);

	Vector2D normVel = Vec2DNormalize(mVelocity);

	DrawDebugCircle(Vector2D(GetCentrePosition().x + normVel.x * 20, GetCentrePosition().y + normVel.y * 20), 10);
	if (mShowingDebug)
	{

		for (int i = 50; i > 44; i--)
		{
			DrawDebugCircle(Vector2D(mMouseX, mMouseY), i);
		}
		// drawing the heading vector line
		//Start position will be the front of the tank
		//the End position will be the tanks heading vector 
		SDL_SetRenderDrawColor(mRenderer, 255, 0, 0, 255);
		//heading end = centreposition - mHeading * by some length
		SDL_RenderDrawLine(mRenderer, GetCentrePosition().x, GetCentrePosition().y, GetCentrePosition().x - mHeading.x * 50, GetCentrePosition().y - mHeading.y * 50);

		//Render the Steering Force
		SDL_SetRenderDrawColor(mRenderer, 0, 255, 0, 255);
		SDL_RenderDrawLine(mRenderer, GetCentrePosition().x, GetCentrePosition().y, GetCentrePosition().x + mSteeringForce.x * 5, GetCentrePosition().y + mSteeringForce.y * 5);
	}

	Vector2D ahead = Vec2DNormalize(mVelocity);
	if (ahead.Length() == 0)
		ahead = mHeading;

	Vector2D cenPos = GetCentralPosition();
	Vector2D aheadDistance = cenPos + ahead * 30;
	DrawDebugCircle(Vector2D(aheadDistance.x, aheadDistance.y), 5);


}
Ejemplo n.º 2
0
/**
 * Render a debug sphere on the screen
 *
 * @param inLocation		World space location of the sphere
 * @param inRadius			The radius of the sphere
 * @param withColor			The color of the cylinder
 * @param inSegments		Number of segments to divide the sphere into
 */
void RenderManager::DrawDebugSphere(const Vec4f& inLocation, const float inRadius, const ColorVector& withColor, const int inSegments) 
{
	// Render the longitudes
	const float deltaAngle = 360.f/inSegments;
	for(float theta=0.f; theta<360.f; theta += deltaAngle)
	{
		DrawDebugCircle(inLocation, Quaternion(90,theta,0), inRadius, withColor, inSegments);
	}

	// Render the latitudes
	const float deltaHeight = 2.f*inRadius/inSegments;
	float radius;
	int segments;
	Vec4f yAxis(0,1,0,0);
	for(float height=-inRadius; height<inRadius; height += deltaHeight)
	{
		radius = sqrt(inRadius*inRadius - height*height);
		segments = (int)(inSegments/inRadius)*radius;
		DrawDebugCircle(inLocation + height*yAxis, Quaternion::Zero, radius, withColor, segments);
	}
}
Ejemplo n.º 3
0
void S013010C_Aaron_Smith_Tank::Render()
{
	

	//Call parent render.
	BaseTank::Render();

	//Draw the left cannon.
	
	if(mDrawTarget)
		mTargetSprite->Render(Vector2D(mTargetPos.x + mTargetSprite->GetWidth()/2  , mTargetPos.y + mTargetSprite->GetHeight() / 2)); //+ 16
	
																
	//DrawDebugCircle(Vector2D(GetCentrePosition().x - mHeading.x * 20, GetCentrePosition().y - mHeading.y* 20), 10);

	Vector2D normVel = Vec2DNormalize(mVelocity);
	
	//DrawDebugCircle(Vector2D(GetCentrePosition().x + normVel.x *20 , GetCentrePosition().y + normVel.y * 20 ), 10);
	if (mShowingDebug)
	{

		for (int i = 50; i > 44; i--)
		{
			DrawDebugCircle(Vector2D(mMouseX, mMouseY), i);
		}
		// drawing the heading vector line
		//Start position will be the front of the tank
		//the End position will be the tanks heading vector 
		SDL_SetRenderDrawColor(mRenderer, 255, 0, 0, 255);
		//heading end = centreposition - mHeading * by some length
		SDL_RenderDrawLine(mRenderer, GetCentrePosition().x, GetCentrePosition().y, GetCentrePosition().x - mHeading.x * 50, GetCentrePosition().y - mHeading.y * 50);

		//Render the Steering Force
		SDL_SetRenderDrawColor(mRenderer, 0, 255, 0, 255);
		SDL_RenderDrawLine(mRenderer, GetCentrePosition().x, GetCentrePosition().y, GetCentrePosition().x + mSteeringForce.x * 5, GetCentrePosition().y + mSteeringForce.y * 5);
	}


	SDL_Rect* boundingRect = new SDL_Rect();
	boundingRect->h = GetAdjustedBoundingBox().height;
	boundingRect->w = GetAdjustedBoundingBox().width;
	boundingRect->x = GetAdjustedBoundingBox().x;
	boundingRect->y = GetAdjustedBoundingBox().y;
	SDL_RenderDrawRect(mRenderer, boundingRect);
	
	

	SDL_SetRenderDrawColor(mRenderer, 0, 255, 0, 255);

	for (Vector2D feelerPoint : mLeftFeelers)
	{
		DrawDebugCircle(feelerPoint, 5);
	}
	for (Vector2D feelerPoint : mRightFeelers)
	{
		DrawDebugCircle(feelerPoint, 5);
	}
	for (Vector2D feelerPoint : mStraightFeelers)
	{
		DrawDebugCircle(feelerPoint, 5);
	}
	for (Vector2D feelerPoint : mLeftSideFeelers)
	{
		DrawDebugCircle(feelerPoint, 5);
	}

	SDL_SetRenderDrawColor(mRenderer, 255, 0, 0, 255);
	for (Vector2D feelerPoint : mRightSideFeelers)
	{
		DrawDebugCircle(feelerPoint, 5);
	}
	/*DrawDebugCircle(mLeftAhead2Distance, 5);
	DrawDebugCircle(mAhead2Distance, 5);
	DrawDebugCircle(mRightAhead2Distance, 5);


	SDL_SetRenderDrawColor(mRenderer, 255, 0, 0, 255);
	DrawDebugCircle(mLeftAhead1Distance, 5);
	DrawDebugCircle(mAhead1Distance, 5);
	DrawDebugCircle(mRightAhead1Distance, 5);*/


	vector<GameObject * > obs = ObstacleManager::Instance()->GetObstacles();
	for (GameObject* obj : obs)
	{
		double radius = obj->GetCollisionRadius();

		for (auto i = radius; i > radius - 5; i--)
		{
			SDL_Rect* rect = new SDL_Rect();
			rect->h = obj->GetAdjustedBoundingBox().height;
			rect->w = obj->GetAdjustedBoundingBox().width;
			rect->x = obj->GetAdjustedBoundingBox().x;
			rect->y = obj->GetAdjustedBoundingBox().y;

			//DrawDebugCircle(obj->GetCentralPosition(), i);
			SDL_RenderDrawRect(mRenderer, rect);
		}
		
	}

	
	
}
Ejemplo n.º 4
0
void ASensor::SetSelected() {
	DrawDebugCircle(GetWorld(), SensorActor->GetActorLocation(), 150.0, 360, FColor(0, 255, 0), false, 0.3, 0, 5, FVector(0.f,1.f,0.f), FVector(0.f,0.f,1.f), false);
}