#include <body_controller.hpp>
Inheritance diagram for irr::newton::CharacterController:
Public Member Functions | |
void | adjustRotationForDirectionFunctions () |
void | canSetVelocityWhileMove () |
void | cantSetVelocityWhileMove () |
CharacterController (irr::newton::CharacterController *body) | |
irr::core::vector3df | FRIgetDirectionAbsolutePositionXY (irr::core::vector3df direction) |
irr::core::vector3df | FRIgetDirectionAbsolutePositionY (irr::core::vector3df direction) |
irr::core::vector3df | FRIgetDirectionPositionXY (irr::core::vector3df direction) |
irr::core::vector3df | FRIgetDirectionPositionY (irr::core::vector3df direction) |
irr::core::vector3df | getDirectionAbsolutePositionXY (irr::core::vector3df direction) |
irr::core::vector3df | getDirectionAbsolutePositionY (irr::core::vector3df direction) |
irr::core::vector3df | getDirectionPositionXY (irr::core::vector3df direction) |
irr::core::vector3df | getDirectionPositionY (irr::core::vector3df direction) |
irr::core::vector3df | getPositionDifference () |
bool | getRotationUpdate () |
bool | isPositionChanged () |
void | newRotationX (float value) |
void | rotateFromMouse (irr::SEvent &event, float mouse_sensitive) |
void | rotateX (irr::f32 value) |
void | rotateY (irr::f32 value) |
void | rotateZ (irr::f32 value) |
void | setRotationUpdate (bool value) |
virtual void | setVelocity (irr::core::vector3df velocity) |
~CharacterController () | |
Protected Member Functions | |
virtual void | reserved_destroy () |
Protected Attributes | |
bool | apply_force_if_not_air_borne |
irr::u32 | can_set_velocity |
bool | center_mouse |
irr::core::vector3df | position_difference |
bool | update_rotation |
Friends | |
void __cdecl | CharacterControllerSetForceAndTorqueEvent (const NewtonBody *body) |
void __cdecl | CharacterControllerSetTransformEvent (const NewtonBody *body, const float *matrix) |
irr::newton::CharacterController::CharacterController | ( | irr::newton::CharacterController * | body | ) |
constructor. don't call this directly. use World::createCharacterController() to create a character controller
irr::newton::CharacterController::~CharacterController | ( | ) | [inline] |
void irr::newton::CharacterController::adjustRotationForDirectionFunctions | ( | ) |
Call this function if you rotate the body using setOmega, addTorque or setTorque (not advised for character controlling). If you control the character with (FRI)getDirection(Absolute)Position(Y\XY) functions, please use CharacterController::rotateY() and\or CharacterController::rotateX() to rotate the body, and not setOmega or addTorque. using rotateX you don't need to call this function
void irr::newton::CharacterController::canSetVelocityWhileMove | ( | ) | [inline] |
This function is inverse to CharacterController::cantSetVelocityWhileMove() function Call this function to able a body to move using setVelocity independently from the applied forces the character will be able to move immediately
void irr::newton::CharacterController::cantSetVelocityWhileMove | ( | ) | [inline] |
Call this function to avoid that a setVelocity call blocks the effect of a force The character will be able to move only after a force will stop its effects
irr::core::vector3df irr::newton::CharacterController::FRIgetDirectionAbsolutePositionXY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::FRIgetDirectionAbsolutePositionY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::FRIgetDirectionPositionXY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::FRIgetDirectionPositionY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::getDirectionAbsolutePositionXY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::getDirectionAbsolutePositionY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::getDirectionPositionXY | ( | irr::core::vector3df | direction | ) |
irr::core::vector3df irr::newton::CharacterController::getDirectionPositionY | ( | irr::core::vector3df | direction | ) |
getDirectionPositionY, getDirectionPositionXY,getDirectionAbsolutePositionY ,getDirectionAbsolutePositionXY and FRI* functions documentation These are high level functions.
These move the body in a direction indipendent of its rotation. This mean that the body move in the same direction whatever is its rotation. For example if the body has got a -90 rotation on Y, using one of this function properly the body move forward If the rotation of the body is -180 on y, the body move forward also
As you can see every function has a Y or a XY at its end. The letter indicates the body axis\aces rotation. Y indicates that the body rotates only on y, every rotation on X and\or z aces will be ignored (useful for character control for example in a FPS game), XY indicates that the body rotates on X and Y aces, every rotation on Z axis will be ignored for moving calculation (useful for a FPS camera)
Every function takes a vector called 'direction'. This vector indicates the direction in wich the body must move on. A +x value indicates a forward moving, a -x value indicates a backward moving, a +z value indicates a strafe left moving a - z value indicates a strafe right moving. Vector must be indicates also the velocity and not only the direction For example pass a core:.vector3df(5,0,0) to move the body on 5 untis forwards, a core::vector3df(-2,0,0) for move the body of 2 untis backward, a core::vector3df (-3,0,-1) for moving the body on 3 units backward and strafing rigth of 1 untis at the same time (as you can see the value can be combined)
Every function returns the body destination. As you can see some function has got a 'absolute' string in its name (getDirectionAbsolutePositionY and getDirectionAbsolutePositionXY) and some other functions not(getDirectionPositionY,getDirectionPositionXY) The functions wich NOT CONTAIN 'absolute' in its name return the "body position destination" considerating body position at (0,0,0).
For example we call getDirectionPositionY with the vector (5,0,0) (the body rotate only on y, move of 5 units forward). The returned vector is called "A" Afterwards we translate the body into a new position different than the current position and we re-call getDirectionPositionY passing the same direction vector ( (5,0,0) ). The returned vector is called "B". In this case A is always equal to B, because the functions wich NOT CONTAIN 'absolute' in its name considerating the body position at (0,0,0). Generally you pass the returned vector to setVelocity or addForce functions
Some other functions has 'absolute' in their name.In This case the function considerating the position of the body like its current position. In the example above, if we use getDirectionAbsolutePositionY instead of getDirectionPositionY, A and B is always different For example with getDirectionAbsolutePositionY(core::vector3df(1,0,0)) you will get the vector in front of the body in the real 3d coordinates WARNING: you can't pass this vector to setVelocity or addForce, using 'not absolute' function for doing that for example you can use an 'absolute' function to positiong an object in front of your body. Simply pass the returned vector to setPosition()
Some functions has got a sintax like FIRgetDirection(Absolute)Position. This function has equal to respective function without FRI pre fix ( FRIgetDirectionPositionY is equal to getDirectionPositionY, exc..) except of 1 thing only. The 'non FRI' functions multiplied the vector by the frame rate the 'FRI functions' don't do that. This mean that the 'non FRI' function return a vector that is depends on the frame rate. This make possible to move a body at the same velocity on all kind of computers (and whatever is the frame rate) you will see the body move at the same velocity at high frame rate and at low frame rate useful for moving a character
The 'FRI functions' retur a vector non multiplied by the frame rate This mean that the vector is the same at all frame rate (and don't change if the frame rate change) DON'T USE THESE FUNCTIONS FOR MOVING THE BODY! These functions are useful for position a body in a direction reletive to an other body. For example position a ball in front of the character. If you use a 'non FRI' functino for doing that, the ball is farther from the character or nearest from the character depending on the frame rate
irr::core::vector3df irr::newton::CharacterController::getPositionDifference | ( | ) | [inline] |
Get the difference of the body of that body since the last update (simply do last_update_position-current_position)
bool irr::newton::CharacterController::getRotationUpdate | ( | ) | [inline] |
Return yes if the scene node has the same rotation of the physics rigid body false if IrrNewt mantein their rotation separately
bool irr::newton::CharacterController::isPositionChanged | ( | ) | [inline] |
Is the position changed from the last update? (has the body moved since the last update?)
void irr::newton::CharacterController::newRotationX | ( | float | value | ) | [inline] |
copy a value to body current x rotation
value | new rotation on the axis |
virtual void irr::newton::CharacterController::reserved_destroy | ( | ) | [inline, protected, virtual] |
Reimplemented from irr::newton::Body.
void irr::newton::CharacterController::rotateFromMouse | ( | irr::SEvent & | event, | |
float | mouse_sensitive | |||
) |
This function rotate a body based on mouse movements call this function inside a IEventReceiver::OnEvent function
event | the SEvent passed to the OnEvent function | |
mouse_sensitive | the sensitive of the mouse |
void irr::newton::CharacterController::rotateX | ( | irr::f32 | value | ) | [inline] |
add a value at body current x rotation
value | value to add at the rotation |
void irr::newton::CharacterController::rotateY | ( | irr::f32 | value | ) | [inline] |
add a value at body current y rotation
value | value to add at the rotation |
void irr::newton::CharacterController::rotateZ | ( | irr::f32 | value | ) | [inline] |
add a value at body current z rotation
value | value to add at the rotation |
void irr::newton::CharacterController::setRotationUpdate | ( | bool | value | ) | [inline] |
Pass yes if you want that the scene node has the same rotation of the physics rigid body false to leave their rotation separately
value | true or false |
virtual void irr::newton::CharacterController::setVelocity | ( | irr::core::vector3df | velocity | ) | [virtual] |
set body linear velocity
velocity | new body linear velocity |
Reimplemented from irr::newton::Body.
void __cdecl CharacterControllerSetForceAndTorqueEvent | ( | const NewtonBody * | body | ) | [friend] |
void __cdecl CharacterControllerSetTransformEvent | ( | const NewtonBody * | body, | |
const float * | matrix | |||
) | [friend] |
bool irr::newton::CharacterController::apply_force_if_not_air_borne [protected] |
irr::u32 irr::newton::CharacterController::can_set_velocity [protected] |
bool irr::newton::CharacterController::center_mouse [protected] |
irr::core::vector3df irr::newton::CharacterController::position_difference [protected] |
bool irr::newton::CharacterController::update_rotation [protected] |