The AbstractGem class is the base class of all gems. As base class all required information of a gem are stored. Also, useful algorithms for collision detection are provided. Furthermore, this class is supposed to be used within QML.
More...
#include <abstractgem.h>
|
void | setRotationFromEuler (const QVector3D &eulerRotation) |
| Sets rotation of gem using euler angles. This method is mainly used to set initial rotation. More...
|
|
|
| AbstractGem (QObject *parent=0) |
|
virtual | ~AbstractGem () |
|
const QVector3D & | color () const |
|
void | setColor (const QVector3D &color) |
|
const GemData & | data () const |
| Returns the GemData object describing the gem. This method was not intended to be public, but public access is needed it for rendering. More...
|
|
const QMatrix4x4 & | model () const |
| Constructs normal matrix for gem in order to transform it from objectspace into worldsapce. More...
|
|
const QVector3D & | position () const |
|
virtual void | setPosition (const QVector3D &position) |
|
qreal | radius () const |
| Radius of boundingsphere. This value is influenced by scale and the geometry of gem. More...
|
|
const QQuaternion & | rotation () const |
| Rotation around own center. More...
|
|
virtual void | setRotation (const QQuaternion &rotation) |
| Sets the rotation of gem around own center. More...
|
|
void | rotate (const QQuaternion &quaternion) |
| Rotates the gem around the center of the gem. More...
|
|
qreal | scale () const |
|
void | setScale (qreal scaleFactor) |
|
GemType | type () const |
| Returns the type of gem, in order to differentiate between types even if you have only AbstractGems. More...
|
|
float | boundingSphereIntersectedBy (const LightRay &ray, QVector3D *collisionPoint=nullptr) |
| Calculates distance to collision with gem's boundingsphere. The boundingsphere is specified by gems themself and cannot be influenced from outside. Because the collision point is only calculated with the bondingsphere computation is pretty fast. More...
|
|
virtual float | intersectedBy (const LightRay &ray, QVector3D *collisionPoint=nullptr) |
| Calcualtes the distance to collision of ray with gem. This method calculates the real collision point. Therefore, many computations are done especially for complex gems. More...
|
|
virtual QList< LightRay * > | processRayIntersection (const LightRay &ray, Scene *scene) |
| Calculates all new rays, that will be created by a collision with that gem. Also affect gem attributes. More...
|
|
The AbstractGem class is the base class of all gems. As base class all required information of a gem are stored. Also, useful algorithms for collision detection are provided. Furthermore, this class is supposed to be used within QML.
AbstractGem::AbstractGem |
( |
QObject * |
parent = 0 | ) |
|
|
explicit |
AbstractGem::~AbstractGem |
( |
| ) |
|
|
virtual |
float AbstractGem::boundingSphereIntersectedBy |
( |
const LightRay & |
ray, |
|
|
QVector3D * |
collisionPoint = nullptr |
|
) |
| |
Calculates distance to collision with gem's boundingsphere. The boundingsphere is specified by gems themself and cannot be influenced from outside. Because the collision point is only calculated with the bondingsphere computation is pretty fast.
- Parameters
-
ray | The ray which might collide with gem's boundingsphere |
collisionPoint | Optional parameter. If provided the collision point of ray with boundingsphere is written into. If no collision occurs the maximum float value is written into all components. |
- Returns
- The factor you need to apply ray.direction() to ray.startPosition(). If no collision occurs maximum float value is returned. Do not compare this value with return values of intersectedBy() intersectedBy()
const QVector3D& AbstractGem::color |
( |
| ) |
const |
void AbstractGem::colorChanged |
( |
| ) |
|
|
signal |
const GemData & AbstractGem::data |
( |
| ) |
const |
Returns the GemData object describing the gem. This method was not intended to be public, but public access is needed it for rendering.
- Returns
float AbstractGem::faceIntersectedBy |
( |
const LightRay & |
ray, |
|
|
Triangle *& |
intersectedFace, |
|
|
QVector3D * |
collisionPoint = nullptr |
|
) |
| |
|
protected |
Finds face of gem intersected by given ray. Ownership of returned face is transferred to caller.
- Parameters
-
ray | Ray that might intersect gem |
intersectedFace | A pointer to intersected face is written into. Because this triangle is in worldspace and for performance reasons the ownership of face is transferred to caller. If ray does not intersect nullptr is written. |
collisionPoint | Optional parameter. If the given pointer is not nullptr the collisionpoint is written into. |
- Returns
- Returns distance to collisionpoint. If no collission occured the value is maximum of float.
float AbstractGem::intersectedBy |
( |
const LightRay & |
ray, |
|
|
QVector3D * |
collisionPoint = nullptr |
|
) |
| |
|
virtual |
Calcualtes the distance to collision of ray with gem. This method calculates the real collision point. Therefore, many computations are done especially for complex gems.
- Parameters
-
ray | The ray that might collide with gem. |
collisionPoint | Optional parameter. If a collision occurs the collision point will be written into this else all components contain maximum float values. |
- Returns
- The factor you need to apply ray.normalizedDirection() to ray.startDirection(). If no collision occurs this value will be highest possible float. Do not compare this value with return value of boundingsphereIntersectedBy() boundingSphereIntersectedBy()
Calculates triangle in world coordinates for given triangle. Therefore, position, rotatition and scale of gem are used.
- Parameters
-
triangle | Objectspace triangle whose corresponding worldspace triangle should be calculated. |
- Returns
- Returns the Triangle in world coordinates.
const QMatrix4x4 & AbstractGem::model |
( |
| ) |
const |
Constructs normal matrix for gem in order to transform it from objectspace into worldsapce.
- Returns
const QVector3D& AbstractGem::position |
( |
| ) |
const |
void AbstractGem::positionChanged |
( |
| ) |
|
|
signal |
Calculates all new rays, that will be created by a collision with that gem. Also affect gem attributes.
- Parameters
-
ray | Ray that might collide. |
scene | The scene the ray and gem are in. This is needed in order to calculate new rays appropriately. |
- Returns
- A List of light rays that should be added to scene. If no collision occurs, the list is empty. Ownership of rays contained in list is transferred to caller.
Reimplemented in SceneBounds.
qreal AbstractGem::radius |
( |
| ) |
const |
Radius of boundingsphere. This value is influenced by scale and the geometry of gem.
- Returns
void AbstractGem::rotate |
( |
const QQuaternion & |
quaternion | ) |
|
Rotates the gem around the center of the gem.
- Parameters
-
quaternion | Specifies how the gem should be rotated. |
const QQuaternion& AbstractGem::rotation |
( |
| ) |
const |
Rotation around own center.
- Returns
void AbstractGem::rotationChanged |
( |
| ) |
|
|
signal |
qreal AbstractGem::scale |
( |
| ) |
const |
void AbstractGem::scaleChanged |
( |
| ) |
|
|
signal |
void AbstractGem::setColor |
( |
const QVector3D & |
color | ) |
|
void AbstractGem::setPosition |
( |
const QVector3D & |
position | ) |
|
|
virtual |
void AbstractGem::setRotation |
( |
const QQuaternion & |
rotation | ) |
|
|
virtual |
Sets the rotation of gem around own center.
- Parameters
-
Reimplemented in SceneBounds.
void AbstractGem::setRotationFromEuler |
( |
const QVector3D & |
eulerRotation | ) |
|
|
slot |
Sets rotation of gem using euler angles. This method is mainly used to set initial rotation.
- Parameters
-
eulerRotation | QVector3D containing the euler angles. The member of eulerVector contains corresponding rotation along axis (x component = rotation around x axis). The angle around axis is specified in degrees. |
void AbstractGem::setScale |
( |
qreal |
scaleFactor | ) |
|
int AbstractGem::solveQuadricFormula |
( |
float |
a, |
|
|
float |
b, |
|
|
float |
c, |
|
|
float & |
x1, |
|
|
float & |
x2 |
|
) |
| |
|
protected |
GemType AbstractGem::type |
( |
| ) |
const |
Returns the type of gem, in order to differentiate between types even if you have only AbstractGems.
- Returns
qreal AbstractGem::m_radius |
|
protected |
The documentation for this class was generated from the following files: