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


C++ TransformNode::addNode方法代码示例

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


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

示例1: render

void Picture::render(Pixel* pix)
{
    Matrix* T;
    Matrix* R;
    Matrix* S;
    Matrix* T2;
    Matrix* T3;

    // Get BasicObjects
    BasicObject* cube = readObject( "cube.txt" );
    BasicObject* cyli = readObject( "cylinder.txt" );
//    BasicObject* sphere = readObject( "sphere.txt" );

    //WA
    Matrix* wnd_trns = AffineTransforms::windowingTransform(pix->getWidth(),
        pix->getHeight());
    Matrix* aspct_ratio = AffineTransforms::aspectRatio(pix->getWidth(),
        pix->getHeight());    // Matrix for aspect ratio.

    // Concatenate wnd_trns and aspct_ratio.
    Matrix* wa = wnd_trns->multiply( aspct_ratio );

    delete wnd_trns;
    delete aspct_ratio;

    Scene* scene = new Scene(wa);

    // Robot 1 Arm
    Matrix* robot1;
    S = AffineTransforms::scale( 0.2, 0.2, 0.2 );
    T = AffineTransforms::translate(0.0, 0.0, -3.0);
    robot1 = T->multiply(S);

    delete S;
    delete T;

    // Robot 2 Arm
    Matrix* robot2;
    T = AffineTransforms::translate(-3.0,0.5,0.0);
    S = AffineTransforms::scale( 0.2, 0.2, 0.2 );
    R = AffineTransforms::rotateX(45.0);
    robot2 = S->multiply(T->multiply(R->multiply(S)));

    delete T;
    delete S;
    delete R;

    // Create Base
    InstanceObject* base = buildInstanceObject( "base.txt", cyli );
    T = AffineTransforms::translate( 0.0, -2.0, 0.0 );
    R = AffineTransforms::rotateY( 30.0 );
    TransformNode* baseT = new TransformNode(T->multiply( R ));

    delete T;
    delete R;

    // Create Lower Arm
    InstanceObject* lower_arm = buildInstanceObject( "lower_arm.txt", cube );
    T = AffineTransforms::translate( 0.0, 3.0, 0.0 );
    T2 = AffineTransforms::translate( 0.0, -2.0, 0.0 );
    R = AffineTransforms::rotateZ( -20.0 );
    T3 = AffineTransforms::translate( 0.0, 2.0, 0.0 );
    TransformNode* lowerT = new TransformNode(T->multiply(T2->multiply(
        R->multiply(T3))));

    delete T;
    delete T2;
    delete T3;
    delete R;

    // Create Upper Arm
    InstanceObject* upper_arm = buildInstanceObject( "upper_arm.txt", cube );
    T = AffineTransforms::translate( 0.0,3.0, 0.0 );
    T2 = AffineTransforms::translate( 0, -1.0, 0 );
    R = AffineTransforms::rotateZ( 90 );
    T3 = AffineTransforms::translate( 0.0, 1.0, 0.0 );
    TransformNode* upperT = new TransformNode(T->multiply(T2->multiply(
        R->multiply(T3))));

    delete T;
    delete T2;
    delete T3;
    delete R;

    // Create sphere
    /*InstanceObject* ball = buildInstanceObject( "sphere_trs.txt", sphere );

    InstanceObject* clamp = buildInstanceObject( "clamp1.txt", cube );
    InstanceObject* clamp2 = buildInstanceObject( "clamp2.txt", cube );*/

    // Connect the pieces.
    baseT->addNode( base );
    lowerT->addNode( lower_arm );
    lowerT->addNode( upperT );
    upperT->addNode( upper_arm );
/*    upperT->addNode( clamp );
    upperT->addNode( clamp2 );
    upperT->addNode( ball );*/
    baseT->addNode( lowerT );

//.........这里部分代码省略.........
开发者ID:tjshaffer21,项目名称:School,代码行数:101,代码来源:Picture.cpp


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