The Visualizer is used for visualizing many things such as the Collision Volume of a Game Object, points in space, line segments, and rays.
More...
|
static void | Visualizer::ShowCollisionVolume (const CollisionVolume &collisionVolume) |
| Shows the Collision Volume to be rendered. More...
|
|
static void | Visualizer::ShowCollisionVolume (const CollisionVolume &collisionVolume, const Vect &color) |
| Shows the Collision Volume to be rendered. More...
|
|
static void | Visualizer::ShowCollisionVolume (const CollisionVolume &collisionVolume, const Vect &color, int depth) |
| Shows the Collision Volume to be rendered. More...
|
|
static void | Visualizer::ShowRay (const Vect &start, const Vect &direction, float length, const Vect &color=Visualizer::DEFAULT_COLOR) |
| Shows a ray in space to be rendered. More...
|
|
static void | Visualizer::ShowRay (const Vect &start, const Vect &direction, const Vect &color=Visualizer::DEFAULT_COLOR) |
| Shows a ray in space to be rendered. More...
|
|
static void | Visualizer::ShowPointAt (const Vect &position, const Vect &color=Visualizer::DEFAULT_COLOR) |
| Shows a point in space to be rendered. More...
|
|
static void | Visualizer::ShowLineSegment (const Vect &position_1, const Vect &position_2, const Vect &color=Visualizer::DEFAULT_COLOR) |
| Shows a line segment in space to be rendered. More...
|
|
The Visualizer is used for visualizing many things such as the Collision Volume of a Game Object, points in space, line segments, and rays.
The Visualizer is a tool for the user to use to for visualzing collider model. This can aid in debugging collisions. To use it you must include Visualizer.h header file. You may pass in a Vector for the color or use the Colors namespace for using preset color.
Here are some methods that you may want to call (shown with some input examples)
-
Visualizer::ShowRay(myPosition, moveDirection, Colors::Red) -> ray length based on moveDirection vector length
-
Visualizer::ShowRay(myPosition, moveDirection, 8, Colors::Red) -> ray length set to 8 due to extra length parameter
const CollisionVolume & getCollisionVolume() const
Gets the current collsion volume being used.
Definition: Collidable.cpp:32
static void ShowRay(const Vect &start, const Vect &direction, float length, const Vect &color=Visualizer::DEFAULT_COLOR)
Shows a ray in space to be rendered.
Definition: Visualizer.h:211
static void ShowCollisionVolume(const CollisionVolume &collisionVolume)
Shows the Collision Volume to be rendered.
Definition: Visualizer.h:168
static void ShowPointAt(const Vect &position, const Vect &color=Visualizer::DEFAULT_COLOR)
Shows a point in space to be rendered.
Definition: Visualizer.h:238
static void ShowLineSegment(const Vect &position_1, const Vect &position_2, const Vect &color=Visualizer::DEFAULT_COLOR)
Shows a line segment in space to be rendered.
Definition: Visualizer.h:252
Here is an example of how this can be used for debugging collisions.
#include "Visualizer.h"
#include "Colors.h"
Tank::Tank()
{
GameObject::setCollidableGroup<Tank>();
}
void Tank::update()
{
this->move();
if(_hasCollidedDebug)
{
}
else
{
}
_hasCollidedDebug = false;
}
void Tank::collision(Tank* pTank)
{
_hasCollidedDebug = true;
}
void Tank::collision(Bullet* pBullet)
{
_hasCollidedDebug = true;
}
void submitCollisionRegistration()
Submit collision registration to current scene.
Definition: Collidable.cpp:80
void setColliderModel(Model *pColliderModel, VolumeType volumeType)
Sets collider model and Collision Volume type.
Definition: Collidable.cpp:37
void updateCollisionData(const Matrix &world)
Updates the collision data described by world matrix.
Definition: Collidable.cpp:71
void submitUpdateRegistration()
Submit update registration to current scene.
Definition: Updatable.cpp:24
Here is an example of how this can be used for debugging collisions with Octree.
#include "Visualizer.h"
#include "Colors.h"
#include "MathTools.h"
WindMill::WindMill()
{
GameObject::setCollidableGroup<WindMill>();
submitKeyRegistration(AZUL_KEY::KEY_1, InputEvent::KEY_PRESS);
submitKeyRegistration(AZUL_KEY::KEY_2, InputEvent::KEY_PRESS);
_renderLevel = 0;
}
void WindMill::update()
{
if(_hasCollidedDebug)
{
}
else
{
}
_hasCollidedDebug = false;
}
void WindMill::collision(Tank* pTank)
{
_hasCollidedDebug = true;
}
void WindMill::collision(Bullet* pBullet)
{
_hasCollidedDebug = true;
}
void WindMill::keyPressed(AZUL_KEY key)
{
if (key == AZUL_KEY::KEY_1) _renderLevel -= 1;
if (key == AZUL_KEY::KEY_2) _renderLevel += 1;
_renderLevel =
MathTools::Clamp(_renderLevel, 0, getCollisionVolume().getMaxDepth());
}
Here is another example of how the visualizing the point, line segment, and ray could be used.
#include "Visualizer.h"
#include "Colors.h"
Tank::Tank()
{
GameObject::setCollidableGroup<Tank>();
}
void Tank::update()
{
Vect moveDirection = getMoveDirection();
Vect position = getPosition();
Tank* pTarget = getTarget();
Vect leadingPoint = computeLeadingPoint(pTarget);
Vect myPosition = getPosition();
Vect targetPosition = pTarget->getPosition();
}
◆ ShowCollisionVolume() [1/3]
static void Visualizer::ShowCollisionVolume |
( |
const CollisionVolume & |
collisionVolume | ) |
|
|
inlinestatic |
Shows the Collision Volume to be rendered.
Depth is only used for Octree Collision models. All other collsion volumes ignore depth value.
- Parameters
-
collisionVolume | The collision volume. |
◆ ShowCollisionVolume() [2/3]
static void Visualizer::ShowCollisionVolume |
( |
const CollisionVolume & |
collisionVolume, |
|
|
const Vect & |
color |
|
) |
| |
|
inlinestatic |
Shows the Collision Volume to be rendered.
- Parameters
-
collisionVolume | The collision volume. |
color | The color. |
◆ ShowCollisionVolume() [3/3]
static void Visualizer::ShowCollisionVolume |
( |
const CollisionVolume & |
collisionVolume, |
|
|
const Vect & |
color, |
|
|
int |
depth |
|
) |
| |
|
inlinestatic |
Shows the Collision Volume to be rendered.
Depth is only used for Octree Collision models. All other collsion volumes ignore depth value.
- Parameters
-
collisionVolume | The collision volume. |
color | The color. |
depth | The depth. |
◆ ShowLineSegment()
static void Visualizer::ShowLineSegment |
( |
const Vect & |
position_1, |
|
|
const Vect & |
position_2, |
|
|
const Vect & |
color = Visualizer::DEFAULT_COLOR |
|
) |
| |
|
inlinestatic |
Shows a line segment in space to be rendered.
- Parameters
-
position_1 | The position of the segment. |
position_2 | The position of the segment. |
color | (Optional) The color. |
◆ ShowPointAt()
static void Visualizer::ShowPointAt |
( |
const Vect & |
position, |
|
|
const Vect & |
color = Visualizer::DEFAULT_COLOR |
|
) |
| |
|
inlinestatic |
Shows a point in space to be rendered.
- Parameters
-
position | The position of the point. |
color | (Optional) The color. |
◆ ShowRay() [1/2]
static void Visualizer::ShowRay |
( |
const Vect & |
start, |
|
|
const Vect & |
direction, |
|
|
const Vect & |
color = Visualizer::DEFAULT_COLOR |
|
) |
| |
|
inlinestatic |
Shows a ray in space to be rendered.
The length is determined by the direction.
- Parameters
-
start | The position of the segment. |
direction | The position of the segment. |
color | (Optional) The color. |
◆ ShowRay() [2/2]
static void Visualizer::ShowRay |
( |
const Vect & |
start, |
|
|
const Vect & |
direction, |
|
|
float |
length, |
|
|
const Vect & |
color = Visualizer::DEFAULT_COLOR |
|
) |
| |
|
inlinestatic |
Shows a ray in space to be rendered.
By using the length, direction is normalized
- Parameters
-
start | The position of the segment. |
direction | The position of the segment. |
length | length of ray. |
color | (Optional) The color. |