本文整理汇总了C++中osg::Matrix::preMult方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::preMult方法的具体用法?C++ Matrix::preMult怎么用?C++ Matrix::preMult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Matrix
的用法示例。
在下文中一共展示了Matrix::preMult方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
void coTouchIntersection::intersect(const osg::Matrix &handMat, bool mouseHit)
{
cerr << "coTouchIntersection::intersect info: called" << endl;
Vec3 q0, q1, q2, q3, q4, q5;
// 3 line segments for interscetion test hand-object
// of course this test can fail
q0.set(0.0f, -0.5f * handSize, 0.0f);
q1.set(0.0f, 0.5f * handSize, 0.0f);
q2.set(-0.5f * handSize, 0.0f, 0.0f);
q3.set(0.5f * handSize, 0.0f, 0.0f);
q4.set(0.0f, 0.0f, -0.5f * handSize);
q5.set(0.0f, 0.0f, 0.5f * handSize);
// xform the intersection line segment
q0 = handMat.preMult(q0);
q1 = handMat.preMult(q1);
q2 = handMat.preMult(q2);
q3 = handMat.preMult(q3);
q4 = handMat.preMult(q4);
q5 = handMat.preMult(q5);
ref_ptr<LineSegment> ray1 = new LineSegment();
ref_ptr<LineSegment> ray2 = new LineSegment();
ref_ptr<LineSegment> ray3 = new LineSegment();
ray1->set(q0, q1);
ray2->set(q2, q3);
ray3->set(q4, q5);
IntersectVisitor visitor;
visitor.addLineSegment(ray1.get());
visitor.addLineSegment(ray2.get());
visitor.addLineSegment(ray3.get());
cover->getScene()->traverse(visitor);
ref_ptr<LineSegment> hitRay = 0;
if (visitor.getNumHits(ray1.get()))
hitRay = ray1;
else if (visitor.getNumHits(ray2.get()))
hitRay = ray2;
else if (visitor.getNumHits(ray3.get()))
hitRay = ray3;
if (visitor.getNumHits(hitRay.get()))
{
Hit hitInformation = visitor.getHitList(hitRay.get()).front();
cover->intersectionHitPointWorld = hitInformation.getWorldIntersectPoint();
cover->intersectionHitPointLocal = hitInformation.getLocalIntersectPoint();
cover->intersectionMatrix = hitInformation._matrix;
cover->intersectedNode = hitInformation._geode;
// walk up to the root and call all coActions
OSGVruiHit hit(hitInformation, mouseHit);
OSGVruiNode node(cover->intersectedNode.get());
callActions(&node, &hit);
}
}
示例2:
bool
GeoTransform::ComputeMatrixCallback::computeLocalToWorldMatrix(const GeoTransform* xform, osg::Matrix& m, osg::NodeVisitor* nv) const
{
if (xform->getReferenceFrame() == xform->RELATIVE_RF)
m.preMult(xform->getMatrix());
else
m = xform->getMatrix();
return true;
}
示例3: computeLocalToWorldMatrix
//src/Viewer/SkyBox.cpp:111: Is this a non-const reference? If so, make const or use a pointer: osg::Matrix& matrix [runtime/references] [2]
virtual bool computeLocalToWorldMatrix( osg::Matrix& matrix,osg::NodeVisitor* nv ) const
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( nv );
if ( cv ) {
osg::Vec3 eyePointLocal = cv->getEyeLocal();
matrix.preMult( osg::Matrix::translate( eyePointLocal ) );
}
return true;
}
示例4: computeLocalToWorldMatrix
bool SkyBox::computeLocalToWorldMatrix( osg::Matrix& matrix, osg::NodeVisitor* nv ) const
{
if ( nv && nv->getVisitorType()==osg::NodeVisitor::CULL_VISITOR )
{
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>( nv );
matrix.preMult( osg::Matrix::translate(cv->getEyeLocal()) );
return true;
}
else
return osg::Transform::computeLocalToWorldMatrix( matrix, nv );
}
示例5: computeLocalToWorldMatrix
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const
{
if (_referenceFrame==RELATIVE_RF)
{
matrix.preMult(getMatrix());
}
else // absolute
{
matrix = getMatrix();
}
return true;
}
示例6: computeLocalToWorldMatrix
bool AntiSquish::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
osg::Matrix unsquishedMatrix;
if ( !computeUnSquishedMatrix( nv, unsquishedMatrix ) )
return Transform::computeLocalToWorldMatrix( matrix, nv );
if (_referenceFrame==RELATIVE_RF)
{
matrix.preMult(unsquishedMatrix);
}
else // absolute
{
matrix = unsquishedMatrix;
}
return true;
}
示例7: computeLocalToWorldMatrix
bool AntiSquish::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* /*nv*/) const
{
osg::Matrix unsquishedMatrix;
if ( !computeUnSquishedMatrix( unsquishedMatrix ) )
{
return false;
}
if (_referenceFrame==RELATIVE_RF)
{
matrix.preMult(unsquishedMatrix);
}
else // absolute
{
matrix = unsquishedMatrix;
}
return true;
}
示例8: if
bool
AbsoluteModelTransform::computeLocalToWorldMatrix( osg::Matrix& matrix, osg::NodeVisitor* nv ) const
{
if( getReferenceFrame() == osg::Transform::ABSOLUTE_RF )
{
osg::Matrix view;
if( !nv )
osg::notify( osg::INFO ) << "AbsoluteModelTransform: NULL NodeVisitor; can't get view." << std::endl;
else if( nv->getVisitorType() != osg::NodeVisitor::CULL_VISITOR )
osg::notify( osg::INFO ) << "AbsoluteModelTransform: NodeVisitor is not CullVisitor; can't get view." << std::endl;
else
{
osgUtil::CullVisitor* cv = dynamic_cast< osgUtil::CullVisitor* >( nv );
#ifdef SCENEVIEW_ANAGLYPHIC_STEREO_SUPPORT
// If OSG_STEREO=ON is in the environment, SceneView hides the view matrix
// in a stack rather than placing it in a Camera node. Enable this code
// (using CMake) to use a less-efficient way to compute the view matrix that
// is compatible with SceneView's usage.
osg::NodePath np = nv->getNodePath();
np.pop_back();
osg::Matrix l2w = osg::computeLocalToWorld( np );
osg::Matrix invL2w = osg::Matrix::inverse( l2w );
view = invL2w * *( cv->getModelViewMatrix() );
#else
// Faster way to determine the view matrix, but not compatible with
// SceneView anaglyphic stereo.
osg::Camera* cam = cv->getCurrentCamera();
cam->computeLocalToWorldMatrix( view, cv );
#endif
}
matrix = ( _matrix * view );
}
else
// RELATIVE_RF
matrix.preMult(_matrix);
return( true );
}
示例9: convertRotMtxToEuler
// ================================================
// convertRotMtxToEuler
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
void convertRotMtxToEuler( const osg::Matrix &m, osg::Vec3 &euler )
{
osg::Vec3 yaxis( 0., 1., 0. ), zaxis( 0., 0., 1. );
float heading, pitch, roll;
osg::Vec3 headingv, pitchv, hpnormalv, v;
pitchv = m.preMult( yaxis );
headingv = pitchv;
// zero-out the z component
headingv[2] = 0.;
// normalize
headingv.normalize();
/////////////////////////////////////////////////////////////////
// HEADING
/////////////////////////////////////////////////////////////////
// the dot product of the two vectors will get us the cosine of the
// angle between them
float cosH = headingv * yaxis; // dot product
ARCCOS_SANITY( cosH )
heading = acos(cosH);
// the cross product of the two vectors will get us the vector normal
// to them
v = headingv ^ yaxis; // cross product
if( v[2] > 0. )
{
heading *= -1.;
}
/////////////////////////////////////////////////////////////////
// PITCH
/////////////////////////////////////////////////////////////////
float cosP = pitchv * headingv; // dot product
ARCCOS_SANITY( cosP )
pitch = acos(cosP);
if( pitchv[2] < 0. )
{
pitch *= -1.;
}
/////////////////////////////////////////////////////////////////
// ROLL
/////////////////////////////////////////////////////////////////
hpnormalv = pitchv ^ headingv;
hpnormalv.normalize();
// If pitch is negative, hpnormalv will point in the "wrong" direction.
// In this situation, we'll negate hpnormalv. If we didn't do this,
// we'd get roll values that change sign as pitch changes from positive to
// negative or vice versa (yuck).
if( pitch < 0. )
hpnormalv *= -1.;
osg::Vec3 zm;
zm = m.preMult( zaxis );
/*
cout << "vv color " << "zm" << " 0.5 0.5 1.0\n";
cout << "vv set zm " << zm << endl;
cout << "vv color pitchv 1 0 1\n";
cout << "vv set pitchv " << pitchv << endl;
cout << "vv color headingv 1 .5 1\n";
cout << "vv set headingv " << headingv << endl;
cout << "vv color " << "hpnormalv" << " 1. 1. 1.\n";
cout << "vv set hpnormalv " << hpnormalv << endl;
*/
float cosR = zm * hpnormalv;
ARCCOS_SANITY( cosR )
roll = acos(cosR);
// if the normal is roughly coincident with pitchv, then we need
// to negate the sign of the roll angle
osg::Vec3 rollplanenormalv = zm ^ hpnormalv;
rollplanenormalv.normalize();
//cout << "vv color " << "rollplanenormalv" << " .3 .3 .3\n";
//cout << "vv set rollplanenormalv " << rollplanenormalv << endl;
if( pitchv * rollplanenormalv > 0. )
{
roll *= -1.;
}
euler.set( roll, pitch, heading );
//cout << "r p h " << euler << endl;
}
示例10: if
//.........这里部分代码省略.........
pfFullXformPt3(v, v, matrix);
coord.xyz[0] = coord0.xyz[0] + v[0];
coord.xyz[1] = coord0.xyz[1] + v[1];
coord.xyz[2] = coord0.xyz[2] + v[2];
pfMakeCoordMat(matrix, &coord);
pfCopyMat(mat, matrix);
#endif
}
else if (coVRTrackingUtil::instance()->getTrackingSystem() == coVRTrackingUtil::T_PHANTOM)
{
#ifdef PHANTOM_TRACKER
static int oldTime;
int currTime;
update_phantom(phid);
currTime = time(NULL);
if (get_stylus_switch(phid))
*button = 1;
else
{
*button = 0;
oldTime = currTime;
}
if (currTime - oldTime > 3)
{
oldTime = currTime;
phantom_reset(gPhantomID);
}
get_stylus_matrix(phid, mat.mat);
mat[3][0] *= 0.2;
mat[3][1] *= 0.2;
mat[3][2] *= 0.2;
osg::Matrix rmat;
rmat.makeEuler(0.0, -90.0, 0.0);
mat.preMult(rmat);
#endif
}
else if (coVRTrackingUtil::instance()->getTrackingSystem() == coVRTrackingUtil::T_SPACEBALL)
{
/* mat.copy(sh->spaceball_mat);
//fprintf(stderr,"spaceball pos: %f %f %f", mat[3][0], mat[3][1], mat[3][2]);
*button=0;
if(sh->button&SPACEBALL_B1)
*button=1;
if(sh->button&SPACEBALL_B2)
*button=DRIVE_BUTTON;
if(sh->button&SPACEBALL_B3)
*button=XFORM_BUTTON;
if(sh->button&SPACEBALL_B5)
*button=1;
if(sh->button&SPACEBALL_B6)
*button=DRIVE_BUTTON;
if(sh->button&SPACEBALL_B7)
*button=XFORM_BUTTON;
if(sh->button&SPACEBALL_BPICK)
{
buttonSpecCell spec;
strcpy(spec.name,"view all");
sh->button &= ~SPACEBALL_BPICK;
VRSceneGraph::sg->manipulate(&spec);
}*/
}
else
{
//oldflags= mouse.flags; // bugfix dr: coGetMouse wurde in VRRenderer schon aufgerufen
//coGetMouse(&mouse);