Basic functions to interact with the terrain such computing the normals and points on the terrain.
More...
Basic functions to interact with the terrain such computing the normals and points on the terrain.
Terrain Objects holds information about the model of the terrain as well as containing the internal mechanism for conducting collisions.
Here is an example of how to access the terrain within a game object to clamp the Tank to the terrain by getting the position on the terrain. As well as using the collision callback. IMPORTANT: You must include SceneManager.h, Scene.h, and Terrain.h
#include "SceneManager.h"
#include "Scene.h"
#include "Terrain.h"
void Tank::update()
{
Vect terrainPosition = pTerrain->computePointOnTerrainObject();
this->setPosition(terrainPosition);
Vect terrainNormal = pTerrain->computePointOnTerrainObject();
this->setOrientation(terrainPosition);
pTerrain->visualizeCellAt(getPosition());
}
void Bullet::terrainCollision()
{
this->destroy();
}
static Scene * GetCurrentScene()
Gets the current scene.
Definition: SceneManager.h:130
const Terrain * getTerrain() const
Gets the current terrain from the scene.
Definition: Scene.cpp:83
◆ computeNormalOnTerrainObject()
Vect TerrainObject::computeNormalOnTerrainObject |
( |
const Vect & |
position | ) |
const |
computes the normal on the terrain given a position in 3D space
- Parameters
-
◆ computePointOnTerrainObject()
Vect TerrainObject::computePointOnTerrainObject |
( |
const Vect & |
position | ) |
const |
computes the point on the terrain given a position in 3D space
- Parameters
-
◆ getTerrain()
const Terrain * Scene::getTerrain |
( |
| ) |
const |
Gets the current terrain from the scene.
- Returns
- The terrain.
◆ visualizeCellAt() [1/2]
void TerrainObject::visualizeCellAt |
( |
const Collidable & |
collidable | ) |
const |
Visualizes the cell on the terrain that the collidable is currently above/below.
Collidables uses BSphere center for its position.
- Parameters
-
◆ visualizeCellAt() [2/2]
void TerrainObject::visualizeCellAt |
( |
const Vect & |
position | ) |
const |
|
overridevirtual |
Visualizes the cell on the terrain given a position.
- Parameters
-