![]() |
Castle Battle
1.0
|
Cannon handles the cannon object. More...
#include <cannon.h>
Public Member Functions | |
Cannon (IrrlichtDevice *device, scene::ISceneManager *smgr, video::IVideoDriver *driver, core::vector3df position, Physics *physics) | |
~Cannon () | |
f32 | refreshAngle () |
Set angle variable and calculate the angle between the plane and the initBarrelVector. More... | |
core::aabbox3df | getBoundingBox () |
Get bounding box of the cannon. More... | |
scene::IMeshSceneNode * | getCannon () |
Get meshnode of the cannon. More... | |
core::matrix4 | getInclinateValues (ACTION_KEYBOARD key) |
Handle user input to change cannon rotations. More... | |
core::vector3df | getRange () |
With some randomness get a position Z based on the cannon power- So there always be a trajectory to hit something in that position(e.g Target). More... | |
Camera * | getCamera () |
Get camera of the cannon. More... | |
void | setRotation (core::vector3df rotation) |
Set rotation of the cannon. More... | |
void | shoot (f32 power) |
Based on the angles vector: initBarrelVector and the cannon power, this will shoot a Ball. More... | |
void | setCamera (core::vector3df offset, core::vector3df rotation, scene::ISceneManager *smgr, scene::ISceneNode *node) |
Set camera of the cannon. More... | |
void | setPosition (core::vector3df position) |
Set position of the cannon. More... | |
bool | moveCannon (ACTION_KEYBOARD action) |
Handle moves in cannon left or right top and down (only angles ) More... | |
bool | moveCamera () |
Move projectile camera. More... | |
void | initAngles () |
Calculate init angles,. More... | |
void | initCannon (core::vector3df position, core::vector3df rotation) |
Initialize with desired position and rotation. More... | |
Public Attributes | |
core::vector3df | rotation |
core::vector3df | rotationconstraint |
Default constructor initialize the angles, setup meshes. More... | |
Private Attributes | |
scene::ISceneManager * | smgr |
IrrlichtDevice * | device |
video::IVideoDriver * | driver |
scene::IMeshSceneNode * | cannon |
Cannon scene node. More... | |
scene::IMeshBuffer * | barrel |
Barrel (cane) of the cannon. More... | |
scene::IMeshBuffer * | wagon |
Wagon is the bottom part of the 3d cannon object. More... | |
f32 | angle |
Angle of the cannon. More... | |
Camera * | camera |
Fixed Camera of the cannon. More... | |
Ball * | btBall |
Projectile of the cannon. More... | |
Physics * | physics |
Physics instance More... | |
core::vector3df | initialBarrelVector |
Initial vector ray. More... | |
core::vector3df | initBarrelVector |
See ::initialBarrelVector. More... | |
core::vector3df | plane |
The plane of the cannon. More... | |
Cannon handles the cannon object.
All things like shoot, moving, camera effects are handled by this class. See also Player, Camera, Ball
Cannon::Cannon | ( | IrrlichtDevice * | device, |
scene::ISceneManager * | smgr, | ||
video::IVideoDriver * | driver, | ||
core::vector3df | position, | ||
Physics * | physics | ||
) |
Cannon::~Cannon | ( | ) |
core::aabbox3df Cannon::getBoundingBox | ( | ) |
Get bounding box of the cannon.
Camera * Cannon::getCamera | ( | ) |
Get camera of the cannon.
scene::IMeshSceneNode * Cannon::getCannon | ( | ) |
Get meshnode of the cannon.
core::matrix4 Cannon::getInclinateValues | ( | ACTION_KEYBOARD | key | ) |
Handle user input to change cannon rotations.
ACTION | related to the key pressed |
core::vector3df Cannon::getRange | ( | ) |
With some randomness get a position Z based on the cannon power- So there always be a trajectory to hit something in that position(e.g Target).
void Cannon::initAngles | ( | ) |
Calculate init angles,.
void Cannon::initCannon | ( | core::vector3df | position, |
core::vector3df | rotation | ||
) |
Initialize with desired position and rotation.
bool Cannon::moveCamera | ( | ) |
Move projectile camera.
I didnt use a parent-child camera related to the Ball becaouse there are some trouble to set a desired position. So i make another camera based on the fixed cannon camera whenever the user shoot. While in this new camer is moved. When the camera reaches the terrain it is deleted
bool Cannon::moveCannon | ( | ACTION_KEYBOARD | action | ) |
Handle moves in cannon left or right top and down (only angles )
f32 Cannon::refreshAngle | ( | ) |
Set angle variable and calculate the angle between the plane and the initBarrelVector.
void Cannon::setCamera | ( | core::vector3df | offset, |
core::vector3df | rotation, | ||
scene::ISceneManager * | smgr, | ||
scene::ISceneNode * | node | ||
) |
Set camera of the cannon.
offset | vector3df offset from the position |
position | vector3df position of the camera |
smgr | ISceneManager Irrlciht scenemanaer |
node | ISceneNode ICameraSceneNode object |
void Cannon::setPosition | ( | core::vector3df | position | ) |
Set position of the cannon.
void Cannon::setRotation | ( | core::vector3df | rotation | ) |
Set rotation of the cannon.
void Cannon::shoot | ( | f32 | power | ) |
Based on the angles vector: initBarrelVector and the cannon power, this will shoot a Ball.
The method also will instance the camera related to the ball while this will be in the air
power | f32 power |
|
private |
Angle of the cannon.
|
private |
Barrel (cane) of the cannon.
IMeshBuffer
|
private |
Projectile of the cannon.
|
private |
Cannon scene node.
|
private |
|
private |
|
private |
See ::initialBarrelVector.
This is the same.
|
private |
Initial vector ray.
The vector represent the initial raytrace of the barrel. Since the barrel in the 3d model is angled the Cannon::initAngles() will setup this vector. That means if the user change the angle, the barrel vector will change too, so the start position of the projectile will be correct
|
private |
The plane of the cannon.
core::vector3df Cannon::rotation |
core::vector3df Cannon::rotationconstraint |
|
private |
|
private |
Wagon is the bottom part of the 3d cannon object.
IMeshBuffer