当前位置: 首页>>代码示例>>C++>>正文


C++ TransformPtr::editMatrix方法代码示例

本文整理汇总了C++中TransformPtr::editMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformPtr::editMatrix方法的具体用法?C++ TransformPtr::editMatrix怎么用?C++ TransformPtr::editMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TransformPtr的用法示例。


在下文中一共展示了TransformPtr::editMatrix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doMovement

void  MoveManipulator::doMovement(TransformPtr t,
								  Int32 coord,
								  Real32 value,
								  const Vec3f		&translation,
								  const Quaternion	&rotation,
								  const Vec3f		&scaleFactor,
								  const Quaternion	&scaleOrientation )
{
	Vec3f trans(0.0f, 0.0f, 0.0f);
	trans[coord] = value;

	Matrix ma, mb, mc, md, me;
	
	ma.setTranslate( -translation        );
	mb.setRotate   (  rotation.inverse() );
	mc.setTransform(  trans              );
	md.setRotate   (  rotation           );
	me.setTranslate(  translation        );
	beginEditCP(t, Transform::MatrixFieldMask);
	{
		t->editMatrix().multLeft(ma);
		t->editMatrix().multLeft(mb);
		t->editMatrix().multLeft(mc);
		t->editMatrix().multLeft(md);
		t->editMatrix().multLeft(me);
	}	
	endEditCP(t, Transform::MatrixFieldMask);
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:OSGMoveManipulator.cpp

示例2: Animate

//do Animation-Calculations here
void Animate()
{
    static Real64 t0 = OSG::getSystemTime();

    Real64 t = OSG::getSystemTime() - t0;

    Real32 rotb = t * 10.0;
    if(rotb > 360.0)
        rotb -= 360.0;

    Real32 rotc1 = t * 20.0;
    if(rotc1 > 360.0)
        rotc1 -= 360.0;

    Real32 rotc2 = t * 40.0;
    if(rotc2 > 360.0)
        rotc2 -= 360.0;

    Quaternion q;
    beginEditCP(_box_trans);
        q.setValueAsAxisDeg(0.2,0,1, rotb);
        _box_trans->editMatrix().setRotate(q);
    endEditCP(_box_trans);

    beginEditCP(_cylinder1_trans);
        q.setValueAsAxisDeg(0,0,1, rotc1);
        _cylinder1_trans->editMatrix().setRotate(q);
    endEditCP(_cylinder1_trans);

    beginEditCP(_cylinder2_trans);
        q.setValueAsAxisDeg(0,0,1, rotc2);
        _cylinder2_trans->editMatrix().setRotate(q);
    endEditCP(_cylinder2_trans);

    beginEditCP(box_trans_node);
    endEditCP(box_trans_node);
    beginEditCP(cam);
    endEditCP(cam);

    mgr->redraw();
    glutPostRedisplay();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:43,代码来源:testFboVP.cpp

示例3: beginEditCP

NodePtr
buildGraphRecurse(UInt32 depth, UInt32 maxDepth, GeometryPtr pGeo)
{
    if(depth == maxDepth)
    {
        NodePtr pNodeGeo = Node::create();

        beginEditCP(pNodeGeo, Node::CoreFieldId);
        pNodeGeo->setCore(pGeo);
        endEditCP  (pNodeGeo, Node::CoreFieldId);

        return pNodeGeo;
    }
    else
    {
        NodePtr   pNodeGroup  = Node  ::create();
        GroupPtr  pGroup      = Group ::create();

        NodePtr   pNodeSwitch = Node  ::create();
        SwitchPtr pSwitch     = Switch::create();

        beginEditCP(pNodeGroup, Node::CoreFieldId | Node::ChildrenFieldId);
        pNodeGroup->setCore (pGroup     );
        pNodeGroup->addChild(pNodeSwitch);
        endEditCP  (pNodeGroup, Node::CoreFieldId | Node::ChildrenFieldId);

        beginEditCP(pSwitch, Switch::ChoiceFieldId);
        pSwitch->editChoice() = Switch::ALL;
        endEditCP  (pSwitch, Switch::ChoiceFieldId);

        beginEditCP(pNodeSwitch, Node::CoreFieldId | Node::ChildrenFieldId);
        pNodeSwitch->setCore(pSwitch);

        for(UInt32 i = 0; i < 8; ++i)
        {
            NodePtr      pNodeTrans  = Node     ::create();
            TransformPtr pTrans      = Transform::create();

            Vec3f       vecTrans;

            if(i & 0x01)
            {
                vecTrans[0] =  0.25 * X_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }
            else
            {
                vecTrans[0] = -0.25 * X_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }

            if(i & 0x02)
            {
                vecTrans[1] =  0.25 * Y_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }
            else
            {
                vecTrans[1] = -0.25 * Y_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }

            if(i & 0x04)
            {
                vecTrans[2] =  0.25 * Z_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }
            else
            {
                vecTrans[2] = -0.25 * Z_SIZE * (1.0 / (depth + 1.0)) + 0.2 * (osgrand() - 0.5);
            }

            beginEditCP(pTrans, Transform::MatrixFieldId);
            pTrans->editMatrix().setTranslate(vecTrans);
            endEditCP  (pTrans, Transform::MatrixFieldId);

            beginEditCP(pNodeTrans, Node::CoreFieldId | Node::ChildrenFieldId);
            pNodeTrans->setCore (pTrans                                      );
            pNodeTrans->addChild(buildGraphRecurse(depth + 1, maxDepth, pGeo));
            endEditCP  (pNodeTrans, Node::CoreFieldId | Node::ChildrenFieldId);

            pNodeSwitch->addChild(pNodeTrans);
        }

        endEditCP  (pNodeSwitch, Node::CoreFieldId | Node::ChildrenFieldId);

        return pNodeGroup;
    }
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:84,代码来源:testIntersectActor.cpp

示例4: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);
    gwin = GLUTWindow::create();

    // create root
    rootNode = makeCoredNode<Group>();
    NodePtr scene = makeCoredNode<Group>();

    // create lights
    TransformPtr point1_trans;
    NodePtr point1 = makeCoredNode<PointLight>(&_point1_core);
    NodePtr point1_beacon = makeCoredNode<Transform>(&point1_trans);
    beginEditCP(point1_trans);
        point1_trans->editMatrix().setTranslate(0.0, 0.0, 25.0);
    endEditCP(point1_trans);

    beginEditCP(_point1_core);
        _point1_core->setAmbient(0.15,0.15,0.15,1);
        _point1_core->setDiffuse(0.4,0.4,0.4,1);
        _point1_core->setSpecular(0.0,0.0,0.0,1);
        _point1_core->setBeacon(point1_beacon);
        _point1_core->setOn(true);
    endEditCP(_point1_core);

    TransformPtr point2_trans;
    NodePtr point2 = makeCoredNode<PointLight>(&_point2_core);
    NodePtr point2_beacon = makeCoredNode<Transform>(&point2_trans);
    beginEditCP(point2_trans);
        point2_trans->editMatrix().setTranslate(5.0, 5.0, 20.0);
    endEditCP(point2_trans);

    beginEditCP(_point2_core);
        _point2_core->setAmbient(0.15,0.15,0.15,1);
        _point2_core->setDiffuse(0.4,0.4,0.4,1);
        _point2_core->setSpecular(0.0,0.0,0.0,1);
        _point2_core->setBeacon(point2_beacon);
        _point2_core->setOn(true);
    endEditCP(_point2_core);

    beginEditCP(point1);
        point1->addChild(point2);
    endEditCP(point1);

    beginEditCP(point2);
        point2->addChild(scene);
    endEditCP(point2);

    // create scene
    
    // bottom
    NodePtr plane = makePlane(25.0, 25.0, 128, 128);
    
    int size = imageWinWidth*imageWinHeight*256;

    ImagePtr plane_img = Image::create();

    beginEditCP(plane_img);
    plane_img->set(Image::OSG_RGBA_PF, imageWinWidth, imageWinHeight, 1, 1, 1, 0, NULL);
    endEditCP(plane_img);

    TextureChunkPtr plane_tex = TextureChunk::create();
    beginEditCP(plane_tex);
        plane_tex->setImage(plane_img);
        plane_tex->setMinFilter(GL_LINEAR);
        plane_tex->setMagFilter(GL_LINEAR);
        plane_tex->setTarget(GL_TEXTURE_2D);
        plane_tex->setInternalFormat(GL_RGBA16F_ARB);
    endEditCP(plane_tex);

    SHLChunkPtr shl = SHLChunk::create();
    beginEditCP(shl);
        shl->setVertexProgram(_vp_program);
        shl->setFragmentProgram(_fp_program);
        shl->setUniformParameter("tex0", 0);
    endEditCP(shl);

    SimpleMaterialPtr plane_mat = SimpleMaterial::create();
    beginEditCP(plane_mat);
        plane_mat->setAmbient(Color3f(0.3,0.3,0.3));
        plane_mat->setDiffuse(Color3f(1.0,1.0,1.0));
        plane_mat->addChunk(plane_tex);
        plane_mat->addChunk(shl);
    endEditCP(plane_mat);

    GeometryPtr plane_geo = GeometryPtr::dcast(plane->getCore());
    beginEditCP(plane_geo);
        plane_geo->setMaterial(plane_mat);
    beginEditCP(plane_geo);
    
    // box
    box_trans_node = makeCoredNode<Transform>(&_box_trans);
    beginEditCP(_box_trans);
        _box_trans->editMatrix().setTranslate(0.0, 0.0, 12.0);
    endEditCP(_box_trans);
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testFboVP.cpp


注:本文中的TransformPtr::editMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。