本文整理汇总了C++中osg::Matrix::setTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::setTransform方法的具体用法?C++ Matrix::setTransform怎么用?C++ Matrix::setTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Matrix
的用法示例。
在下文中一共展示了Matrix::setTransform方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
// redraw the window
void display( void )
{
// create the matrix
OSG::Matrix m;
OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME);
// set the transforms' matrices
m.setTransform(OSG::Vec3f(0,
0,
OSG::osgSin(t / 1000.f) * 1.5),
OSG::Quaternion(OSG::Vec3f (1, 0, 0),
t / 500.f));
cyltrans->setMatrix(m);
m.setTransform(OSG::Vec3f(OSG::osgSin(t / 2000.f),
0,
0),
OSG::Quaternion(OSG::Vec3f (0, 0, 1),
t / 2000.f));
tortrans->setMatrix(m);
mgr->redraw();
}
示例2: makeMatrix
// create the motion matrix for a light source at time t
void makeMatrix(OSG::Real32 t, OSG::Matrix &result)
{
OSG::Matrix m;
result.setTransform(OSG::Quaternion(OSG::Vec3f(0,0,1), -OSG::Pi / 2));
m.setTransform(OSG::Vec3f(1, 0, 0));
result.multLeft(m);
m.setTransform(OSG::Quaternion(OSG::Vec3f(0,1,0), t / 1000.f));
result.multLeft(m);
m.setTransform(OSG::Vec3f(2, 0, 0));
result.multLeft(m);
m.setTransform(OSG::Quaternion(OSG::Vec3f(0,0,1), t / 3000.f));
result.multLeft(m);
}
示例3: setTranslation
void Transform::setTranslation(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z)
{
OSG::Matrix m;
m.setTransform(OSG::Vec3f(x,y,z));
// OSG::beginEditCP(_transform);
_transform->setMatrix(m);
// OSG::endEditCP(_transform);
}
示例4: display
// redraw the window
void display( void )
{
// create the matrix
OSG::Matrix m;
OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
m.setTransform(OSG::Quaternion(OSG::Vec3f(0,1,0), t / 1000.f));
// set the transform's matrix
trans->setMatrix(m);
OSG::commitChanges();
mgr->redraw();
}
示例5: display
//
// redraw the window
//
void display(void)
{
// light spot direction and light position must be provided in eye space
update_light_state(ubo_light_state, lights);
// create the matrix
OSG::Matrix m;
OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
// set the transforms' matrices
m.setTransform(OSG::Vec3f(0, 0, OSG::osgSin(t / 1000.f) * 1.5),
OSG::Quaternion( OSG::Vec3f (1, 0, 0), t / 500.f));
cyltrans->setMatrix(m);
m.setTransform(OSG::Vec3f(OSG::osgSin(t / 1000.f), 0, 0),
OSG::Quaternion( OSG::Vec3f (0, 0, 1), t / 1000.f));
tortrans->setMatrix(m);
OSG::commitChanges();
mgr->redraw();
}
示例6: updateClipPlanes
//
// In case the clip plane data change this function is called
//
void updateClipPlanes(const VecClipPlaneData& vec)
{
int sz = vec.size();
for(int i = 0; i < iNumClipPlanes; ++i)
{
OSG::ClipPlaneChunk *clipPlaneChunk =
vecClipPlaneDetails[i]._clipPlaneChunk;
clipPlaneChunk->setEnable(false);
if(i < sz)
{
const ClipPlaneData& data = vec[i];
//
// Update the clip plane chunk
//
clipPlaneChunk->setEquation(data._equation);
clipPlaneChunk->setEnable (data._enabled );
//
// and the plane transform core
//
OSG::Matrix rotMat;
OSG::Vec4f v1(0.f, 0.f, -1.f, 0.f);
OSG::Quaternion q(OSG::Vec3f(v1), OSG::Vec3f(data._equation));
rotMat.setTransform(q);
OSG::Matrix mat;
OSG::Vec3f v2(0.0f, 0.0f, data._equation[3]);
mat.setTranslate(v2);
mat.multLeft(rotMat);
vecClipPlaneDetails[i]._planeTrafoCore->setMatrix(mat);
}
}
}
示例7: display
// redraw the window
void display( void )
{
// create the matrix
OSG::Matrix m;
OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
// set the transforms' matrices
for(OSG::UInt16 i=0; i < ncopies; ++i)
{
m.setTransform(OSG::Vec3f(
OSG::osgSin(t / 1000.f + i * 4 * ncopies / OSG::Pi),
OSG::osgCos(t / 1000.f + i * 6 * ncopies / OSG::Pi),
OSG::osgSin(t / 1000.f + i * 7 * ncopies / OSG::Pi)),
OSG::Quaternion(OSG::Vec3f (1,1,0),
t / 1000.f + i * 4 * ncopies / OSG::Pi));
trans[i]->setMatrix(m);
}
OSG::commitChanges();
mgr->redraw();
}
示例8: display
// redraw the window
void display( void )
{
// update the geometry
OSG::Matrix m;
OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
m.setTransform(OSG::Vec3f(OSG::osgSin(t / 1000.f),
OSG::osgCos(t / 1000.f),
OSG::osgSin(t / 1000.f)),
OSG::Quaternion( OSG::Vec3f(0,1,0), t / 1000.f));
trans->setMatrix(m);
// update the image
grabImage(image);
// redraw the screen
mgr->redraw();
}
示例9: Animate
void Animate()
{
//Show FPS
//showFpsCounter();
if(bAnim == true)
{
static OSG::Real64 t0 = OSG::getSystemTime();
OSG::Real64 t = OSG::getSystemTime() - t0;
OSG::Real32 rot0 = t * 0.25;
if(rot0 > 360.0)
rot0 -= 360.0;
OSG::Real32 rota = t * 0.5;
if(rota > 360.0)
rota -= 360.0;
OSG::Real32 rotb = t * 1.0;
if(rotb > 360.0)
rotb -= 360.0;
OSG::Real32 rotc = t * 1.5;
if(rotc > 360.0)
rotc -= 360.0;
OSG::Real32 rotd = t * 2.0;
if(rotd > 360.0)
rotd -= 360.0;
// _light2_trans->editMatrix().setTranslate(-100.0*sin(rota),-100.0*cos(rota), 250.0);
//animate Trees
OSG::Quaternion q;
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rota));
_tree1_trans->editMatrix().setRotate(q);
_tree1_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotc));
_tree2_trans->editMatrix().setRotate(q);
_tree2_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotb));
_tree3_trans->editMatrix().setRotate(q);
_tree3_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotb));
_tree4_trans->editMatrix().setRotate(q);
_tree4_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotc));
_tree5_trans->editMatrix().setRotate(q);
_tree5_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotb));
_tree6_trans->editMatrix().setRotate(q);
_tree6_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotd));
_tree7_trans->editMatrix().setRotate(q);
_tree7_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotb));
_tree8_trans->editMatrix().setRotate(q);
_tree8_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
q.setValueAsAxisRad(1, 1, 1, 0.5 * sin(rotc));
_tree9_trans->editMatrix().setRotate(q);
_tree9_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
q.setIdentity();
{
OSG::Matrix m;
m.setIdentity();
OSG::Vec3f scale(0.15f,0.15f,0.15f);
OSG::Vec3f trans(-40.0 * sin(rotb),-40.0 * cos(rotb),
50.0 + 25.0 * sin(rotd));
q.setValueAsAxisRad(0, 0, 1, -rotb);
m.setTransform(trans, q, scale);
_obj1_trans->setMatrix(m);
}
//.........这里部分代码省略.........
示例10: initGeometry
void Grid::initGeometry(const OSG::Real32 width, const OSG::Real32 height,
const OSG::Real32 granularity,
const Grid::Corner corner,
const OSG::Vec3f& cornerPos,
const OSG::Quaternion& rot,
const OSG::Color3f& color)
{
OSG::SimpleMaterialPtr plane_mat = OSG::SimpleMaterial::create();
#if OSG_MAJOR_VERSION < 2
OSG::CPEditor pme(plane_mat,
OSG::SimpleMaterial::AmbientFieldMask |
OSG::SimpleMaterial::DiffuseFieldMask |
OSG::SimpleMaterial::LitFieldMask |
OSG::SimpleMaterial::TransparencyFieldMask);
#endif
plane_mat->setLit(false);
plane_mat->setAmbient(color);
plane_mat->setDiffuse(color);
plane_mat->setTransparency(0.90f);
OSG::SimpleMaterialPtr line_mat =
#if OSG_MAJOR_VERSION < 2
OSG::SimpleMaterialPtr::dcast(OSG::deepClone(plane_mat));
#else
OSG::cast_dynamic<OSG::SimpleMaterialPtr>(OSG::deepClone(plane_mat));
#endif
#if OSG_MAJOR_VERSION < 2
OSG::CPEditor lme(line_mat, OSG::SimpleMaterial::TransparencyFieldMask);
#endif
line_mat->setTransparency(0.0f);
mPlaneNode = OSG::makePlaneGeo(width, height, 1, 1);
#if OSG_MAJOR_VERSION < 2
OSG::CPEditor pne(mPlaneNode.core(), OSG::Geometry::MaterialFieldMask);
#endif
mPlaneNode->setMaterial(plane_mat);
const float half_width(width / 2.0f);
const float half_height(height / 2.0f);
std::cout << "Corner = " << cornerPos << std::endl;
OSG::Vec3f center_pt;
switch ( corner )
{
case LOWER_LEFT:
center_pt[0] = cornerPos[0] + half_width;
center_pt[1] = cornerPos[1] + half_height;
center_pt[2] = cornerPos[2];
break;
case LOWER_RIGHT:
center_pt[0] = cornerPos[0] - half_width;
center_pt[1] = cornerPos[1] + half_height;
center_pt[2] = cornerPos[2];
break;
case UPPER_RIGHT:
center_pt[0] = cornerPos[0] - half_width;
center_pt[1] = cornerPos[1] - half_height;
center_pt[2] = cornerPos[2];
break;
case UPPER_LEFT:
center_pt[0] = cornerPos[0] + half_width;
center_pt[1] = cornerPos[1] - half_height;
center_pt[2] = cornerPos[2];
break;
}
std::cout << "Center = " << center_pt << std::endl;
mRoot = OSG::Transform::create();
OSG::Matrix xform;
xform.setTransform(center_pt, rot, OSG::Vec3f(1.0f, 1.0f, 1.0f),
OSG::Quaternion(), cornerPos - center_pt);
move(xform);
OSG::GeoPTypesPtr type = OSG::GeoPTypesUI8::create();
#if OSG_MAJOR_VERSION < 2
OSG::CPEditor te(type, OSG::GeoPTypesUI8::GeoPropDataFieldMask);
#endif
type->addValue(GL_LINES);
unsigned int vertex_count(0);
OSG::GeoPositions3fPtr pos = OSG::GeoPositions3f::create();
#if OSG_MAJOR_VERSION < 2
OSG::CPEditor pe(pos, OSG::GeoPositions3f::GeoPropDataFieldMask);
#endif
for ( float i = -half_width; i <= half_width; i += granularity )
{
pos->addValue(OSG::Pnt3f(i, -half_height, 0.0f));
pos->addValue(OSG::Pnt3f(i, half_height, 0.0f));
vertex_count += 2;
}
for ( float i = -half_height; i <= half_height; i += granularity )
{
pos->addValue(OSG::Pnt3f(-half_width, i, 0.0f));
//.........这里部分代码省略.........