Target Reticules - calculating the size of one

Problems building or running the engine, queries about how to use features etc.
Post Reply
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am
Contact:

Target Reticules - calculating the size of one

Post by Van »

Working on a space simulator. I have the reticule and I can target objects (nodes). However, the size of the reticule isn't what it suppose to be.

What I do is get the bounding radius of a node and use that size to determine how large to make the redicule.

Two things are happening:

1. With distance objects, sometimes the size of the ring is the same size as if I were right next to the object (i.e. the ring should be smaller because of the distance and its not).

2. Some objects, the ring is so small I can't see it, even when I am next to the object (i.e. the ring should be bigger and its not).

Code: Select all

	Node = TargetObj->Node;
	mTargetRadius = TargetObj->Entity->getBoundingRadius();	// need to get the 2d coordinates for the target
	get2DScreenCoordinates(Node->getWorldPosition(), TargetPosX, TargetPosY);
	
	// Set the position of the target reticule frame
	if (mTargetRadius < 50) mTargetRadius = 50;			// so its visible
	if (mTargetRadius > 300) mTargetRadius = 300;		// so its visible
	mHudTarget->setDimensions(mTargetRadius, mTargetRadius);
	TargetBoxPosX = TargetPosX - (mHudTarget->getWidth() * 0.5);
	TargetBoxPosY = TargetPosY - (mHudTarget->getHeight() * 0.5);
	mHudTarget->setPosition(TargetBoxPosX, TargetBoxPosY);
	mTargetRadius = MySpaceShip->DistanceFrom(Node->getWorldPosition());
	GuiHudTargetDistanceVelocityText->setCaption("D:" + StringConverter::toString(mTargetRadius));
	mHudTarget->show();
What am I doing wrong?
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

When you are doing:

Code: Select all

mTargetRadius = TargetObj->Entity->getBoundingRadius();
you get a constant mTargetRadius (provided the Entity doesn't change). You'll have to make this radius dependent on distance, maybe by dividing it by MySpaceShip->DistanceFrom(Node->getWorldPosition()) which you call later in the function, or something like that. Maybe there's a better way to get the right size?
Post Reply