![]() |
http://www.sim.no http://www.coin3d.org |
The following stand-alone example shows how screen space coordinates projects into 3D when mapped with an SbSphereSheetProjector. It outputs the resulting projections as an SoPointSet in a Inventor-file on stdout:. More...
#include <Inventor/projectors/SbSphereSheetProjector.h>
Public Member Functions | |
SbSphereSheetProjector (const SbBool orienttoeye=1) | |
SbSphereSheetProjector (const SbSphere &sph, const SbBool orienttoeye=1) | |
virtual SbProjector * | copy (void) const |
virtual SbVec3f | project (const SbVec2f &point) |
virtual SbRotation | getRotation (const SbVec3f &point1, const SbVec3f &point2) |
Protected Member Functions | |
void | setupPlane (void) |
Protected Attributes | |
SbVec3f | workingProjPoint |
SbVec3f | planePoint |
SbVec3f | planeDir |
float | planeDist |
SbPlane | tolPlane |
The following stand-alone example shows how screen space coordinates projects into 3D when mapped with an SbSphereSheetProjector. It outputs the resulting projections as an SoPointSet in a Inventor-file on stdout:.
#include <stdio.h> #include <Inventor/SbLinear.h> #include <Inventor/projectors/SbSphereSheetProjector.h> #include <Inventor/SoDB.h> int main(void) { SoDB::init(); const float START = 0.0f; const float END = 1.0f; const float STEPS = 50.0f; const float STEPSIZE = ((END - START) / STEPS); SbSphere s(SbVec3f(0, 0, 0), 0.8); SbSphereSheetProjector ssp(s, TRUE); // last argument is orientToEye SbViewVolume volume; volume.ortho(-1, 1, -1, 1, -1, 1); ssp.setViewVolume(volume); (void)fprintf(stdout, "#Inventor V2.1 ascii\n\n" "Separator {\n" " Coordinate3 {\n" " point [\n"); for (float i=START; i <= END; i += STEPSIZE) { for (float j=START; j <= END; j += STEPSIZE) { SbVec3f v = ssp.project(SbVec2f(j, i)); (void)fprintf(stdout, "\t%f %f %f,\n", v[0], v[1], v[2]); } } (void)fprintf(stdout, " ]\n" " }\n" " DrawStyle { pointSize 2 }\n" " PointSet { }\n" "}\n"); return 0; }
The projections to 3D points in the resulting Inventor-file looks like this:
SbSphereSheetProjector::SbSphereSheetProjector | ( | const SbBool | orienttoeye = 1 |
) |
Constructor. Uses default sphere defintion, see SbSphereProjector::SbSphereProjector().
orienttoeye decides whether or not the sheet should always be oriented towards the viewer.
Referenced by copy().
SbSphereSheetProjector::SbSphereSheetProjector | ( | const SbSphere & | sph, | |
const SbBool | orienttoeye = 1 | |||
) |
Constructor with explicit definition of projection sphere.
SbProjector * SbSphereSheetProjector::copy | ( | void | ) | const [virtual] |
Construct and return a copy of this projector. The caller is responsible for destructing the new instance.
Note that if the Coin library has been built as a DLL under Microsoft Windows and you use this method from application code, you must make sure that both the Coin DLL and the application executable is using the same instance of a C Run-Time (CRT) library. Otherwise, you will get memory heap corruption upon deallocating the returned instances, eventually leading to mysterious crashes.
Implements SbProjector.
References SbSphereSheetProjector().
Project the 2D point from normalized viewport coordinates to a 3D point. The mapping will be done in accordance with the type of the projector.
Implements SbProjector.
References SbLine::getDirection(), SbSphere::getRadius(), SbProjector::getWorkingLine(), SbPlane::intersect(), SbSphereProjector::intersectFront, SbSphereProjector::intersectSphereFront(), SbSphereProjector::isOrientToEye(), SbSphereProjector::lastPoint, SbSphereProjector::needSetup, SbVec3f::negate(), planeDir, planePoint, SoDebugError::postWarning(), setupPlane(), SbLine::setValue(), SbSphereProjector::sphere, tolPlane, and workingProjPoint.
SbRotation SbSphereSheetProjector::getRotation | ( | const SbVec3f & | point1, | |
const SbVec3f & | point2 | |||
) | [virtual] |
Returns rotation on the projection surface which re-orients point1 to point2.
Implements SbSphereProjector.
References SbSphereProjector::needSetup, planePoint, and setupPlane().
void SbSphereSheetProjector::setupPlane | ( | void | ) | [protected] |
Recalculates projection surface settings after changes to the parameters.
References SbSphere::getCenter(), SbViewVolume::getProjectionDirection(), SbSphereProjector::intersectFront, SbMatrix::multDirMatrix(), SbSphereProjector::needSetup, SbVec3f::normalize(), SbSphereProjector::orientToEye, planeDir, planeDist, planePoint, SoDebugError::postWarning(), SbVec3f::setValue(), SbSphereProjector::sphere, tolPlane, SbProjector::viewVol, and SbProjector::worldToWorking.
Referenced by getRotation(), and project().
SbSphereSheetProjector::workingProjPoint [protected] |
Last projected point, in the working space coordinate system.
Referenced by project().
SbSphereSheetProjector::planePoint [protected] |
Position of the center of the sphere in the plane of the hyberbolic sheet.
Referenced by getRotation(), project(), and setupPlane().
SbSphereSheetProjector::planeDir [protected] |
Normal vector of the plane defining the orientation of the sheet.
Referenced by project(), and setupPlane().
SbSphereSheetProjector::planeDist [protected] |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Referenced by setupPlane().
SbSphereSheetProjector::tolPlane [protected] |
The tolerance value specifying how much of the sphere is "above" the sheet.
Referenced by project(), and setupPlane().
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 23 16:33:41 2009 for Coin by Doxygen. 1.5.8