#include <qsprojection.h>
Inheritance diagram for QSProjection:
Public Types | |
enum | ClipResult { Rejected = 0, Clipped, Accepted } |
Public Methods | |
QSProjection () | |
virtual | ~QSProjection () |
virtual void | setLight (bool enabled) |
virtual void | setLightParameters (const QSPt3f &lightVector, int ambientLight, int directedLight) |
bool | light () const |
QSPt3f | lightVector () const |
int | ambientLight () const |
int | directedLight () const |
virtual QSPt3f | world2DToCanvas3 (const QSPt2f &p) const=0 |
virtual QSPt2f | world2DToCanvas (const QSPt2f &p) const=0 |
virtual QSPt3f | world3DToCanvas3 (const QSPt3f &p) const=0 |
virtual QSPt2f | world3DToCanvas (const QSPt3f &p) const=0 |
virtual QSPt3f | canvas3ToWorld3D (const QSPt3f &p) const=0 |
QSPt2f | map (const QSPt3f &pos) const |
QSPt3f | map (const QSPt2f &pos) const |
virtual QSPt3f | furthest () const |
virtual QSPt2f | middle () const |
virtual ClipResult | clipPoint2 (const QSPt2f &p1) const |
virtual ClipResult | clipLine2 (QSPt2f *p1, QSPt2f *p2) const |
virtual ClipResult | clipPoly2 (const QSPt2f in[], int inpoints, QSPt2f out[], int *outpoints, int maxout, bool outedges[]=NULL, const bool inedges[]=NULL) const |
virtual ClipResult | clipPoint3 (const QSPt3f &pos) const |
virtual ClipResult | clipLine3 (QSPt3f *p1, QSPt3f *p2) const |
virtual ClipResult | clipPoly3 (const QSPt3f in[], int inpoints, QSPt3f out[], int *outpoints, int maxpoints, const QSPt3f cube[2], bool outedges[]=NULL, const bool inedges[]=NULL) const |
virtual void | shade (QSGFill &fill, const QSPt3f &normal, const QSPt2f *canvas_pts, int npoints, QSGFill *bottomFill) const |
Static Public Methods | |
double | degToRad (double deg) |
double | radToDeg (double rad) |
bool | pointInPoly (const QSPt2f &pos, const QSPt2f *pts, int npts) |
double | dotProduct (const QSPt3f &p1, const QSPt3f &p2) |
QSPt3f | vectorProduct (const QSPt3f &p1, const QSPt3f &p2) |
QSPt3f | normal (const QSPt3f vertices[4], bool normalize=true) |
QSPt3f | normal (const QSPt3f *v, int npoints, bool normalize=true) |
QSPt3f | normalize (QSPt3f vector) |
void | getPoly3Cube (const QSPt3f in[], int inpoints, QSPt3f cube[2]) |
ClipResult | clipLine (QSPt2f *p0, QSPt2f *p1, const QSPt2f &clip_pos, const QSPt2f &clip_area) |
void | clipVertexNormals (const QSPt3f in[], int inpoints, const QSPt3f clip[], int clipoints, const QSPt3f innors[], QSPt3f outnor[]) |
void | clipVertexColors (const QSPt3f in[], int inpoints, const QSPt3f clip[], int clipoints, const QSGFill incol[], QSGFill outcol[]) |
bool | isBottom (const QSPt2f pts[], int npoints) |
bool | isBottom (const QSPt3f pts[], int npoints) |
bool | isBottom (const QSPt3f &p0, const QSPt3f &p1, const QSPt3f &p2) |
bool | isFlat (const QSPt3f pts[], int npoints) |
bool | isCorrect (const QSPt3f pts[4]) |
bool | isCorrect (const double values[4]) |
void | triangulate1 (int triangleNumber, const QSPt3f pts[], int npoints, QSPt3f triangle[3], bool edges[3]) |
Static Public Attributes | |
const double | pi |
Protected Attributes | |
bool | m_light |
QSPt3f | m_light_vector |
int | m_ambient_light |
int | m_directed_light |
Transformations maps points from world coordinates ( 2d,3d space ) to screen(canvas) coordinates and also clips polygon and lines to the viewport. Each axes object such as QSAxes2D, QSAxes3D provides its own implementation of transformation object which can be acessed through this interface, see QSAxes::proj() There are two sets of functions: first which maps coordinates from 2D world to screen and the second, which maps coordinates from 3D world to screen. The first set should be used by 2d plots and the second should be used by 3d plots. Projection can treat mappings from world2D in a special way allowing plotting 2d datasets on a different planes etc. This will be detailed in the next version. Notice that QSAxes2D also provides world3DToCanvas() methods allowing drawing 3D datasets on 2D axes. Projection expect all world coordinates to be in range 0.0-1.0. see world2DToCanvas() and world2DToCanvas3() world3DToCanvas() world3DToCanvas3() furthest() middle() canvas3ToWorld3D()
|
Clipping result.
|
|
Constructor |
|
Destructor |
|
ambient light intensity ( -50,50 ) |
|
Maps 'p' from canvas coordinates to world coordinates. Implemented in QSProjection2D. |
|
Clips a line defined by 'p1' and 'p2' to the clipping rectangle. Returns a state of the operation: 'Clipped' - the line was clipped and coordinates of points were written to 'out', 'Rejected' - the line was thrown away ( coordinates not modified ), 'Accepted' - the line is inside the clipping rectangle ( coordinates were not modified ).
|
|
Clips line. |
|
Tests if point is inside the clipping area. Returns 'Rejected' or 'Accepted'. |
|
Tests if point is inside the clipping space. Returns 'Rejected' or 'Accepted'. |
|
This method clips a polygon defined by 'npoints' points in 'in' to the clip rectangle and returns a new polygon in 'out'. Table 'out' must be large enough to contain all vertices after clipping. The maximum size of this table must be given as 'maxpoints'. If 'outedges' array is passed returns edges to be drawn ( those will be all unclipped edges ), you can pass a table with an initial edge state in 'inedges'. Returns a state of the operation: 'Clipped' - the polygon was clipped and coordinates of points were written to 'out', 'Rejected' - the polygon was thrown away ( coordinates in 'out...' were not modified ), 'Accepted' - the polygon is inside the clipping rectangle ( coordinates in 'out...' were not modified ).
|
|
This method clips the polygon defined by 'npoints' points in 'in' to the axis box [(0,0,0),(1,1,1)] and returns a new mesh in 'out'. Table 'out' must be large enough to contain all vertices after clipping. The size of this table must be given in 'maxpoints'. If 'outedges' array is passed returns edges to be drawn ( those will be all unclipped edges ), you can pass a table with an initial edge state in 'inedges'. Returns a state of the operation: 'Clipped' - the polygon was clipped and coordinates of points were written to 'out', 'Rejected' - the polygon was thrown away ( coordinates not modified ), 'Acccepted' - the polygon is inside the axis box ( coordinates were not modified ). |
|
Calculates interpolated colors. With the given polygon defined by 'inpoints' vertices 'in[]', and colors of those vertices in 'incols[]', calculates colors at 'clippoints' points 'clip[]' interpolating respective colors of the polygon and writes them to 'outcols[]', which must have size equal to 'clippoints'. All points in 'clip[]' must lie inside the given polygon. |
|
Calculates interpolated normals. With the given polygon defined by 'inpoint' vertices 'in[]', and normals to those vertices in 'innors[]', calculates normals at 'clippoints' points 'clip[]' interpolating respective normals of the polygon and writes them to 'outnors[]', which must have size equal to 'clippoints'. All points in 'clip[]' must lie inside the given polygon. |
|
Degrees to radians |
|
directed light intensity ( -50, 50 ) |
|
Returns 'p1 * p2' . |
|
Returns a point from [(0, 0, 0) ( 1, 1, 1 )] cube, which has the greatest z coordinate and all its three neighbourng walls are visible.
Reimplemented in QSProjection3D. |
|
Calculates a bounding box of the polygon defined by 'inpoints' vertices in in[] and writes it to the 'cube[]' table. |
|
The special version for triangles of the above function. All points are in canvas coordinates. |
|
Checks wheather a bottom side of the given polygon is visible. All points are in canvas coordinates. |
|
Checks wheather a bottom side of the given polygon is visible. All points are in canvas coordinates. |
|
Triangulates the given polygon and checks if all triangles have the same side visible ( all have top or all have the bottom side visible ). All points are in canvas coordinates. |
|
Is light turned on ? |
|
light direction - normalized vector |
|
Middle point Reimplemented in QSProjection3D. |
|
Returns the normal to the given polygon. |
|
Returns the normal to the given quad. |
|
Normalize vector. |
|
Tests if point 'pos' is inside polygon 'pts'. No need to reimplement. |
|
Radians to degrees |
|
Turns on lighting. |
|
Sets light parameters |
|
Shades 'fill' color. |
|
Returns 'p1 x p2' . |
|
Maps the point to the screen coordinates - the same as world2DToCanvas3() but the depth is not returned. Provided only for efficiency. Implemented in QSProjection2D. |
|
Maps the point to the screen coordinates+depth. Implemented in QSProjection2D. |
|
Maps 'p' to the screen coordinates. - the same as world3DToCanvas3() but the depth not returned. Provided only for efficiency. Implemented in QSProjection2D. |
|
Maps 'p' to the screen coordinates.+ depth Implemented in QSProjection2D. |
|
PI |