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


C++ STVector3::Transform方法代码示例

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


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

示例1: DrawManipulator

void DrawManipulator(void)
{

    // color
    RGBR_f colorRed(1, 0, 0, 1);
    RGBR_f colorGreen(0, 1, 0, 1);
    RGBR_f colorBlue(0, 0, 1, 1);
    RGBR_f colorWhite(1,1,1,1);
    RGBR_f colorMagenta(1.0f,0.3f,1.0f, 1.0f);
    RGBR_f colorGrey(0.2f,0.2f,0.2f, 1.0f);

    // a, y and z axis
    STVector3 xaxis = STVector3::eX;
    STVector3 yaxis = STVector3::eY;
    STVector3 zaxis = STVector3::eZ;

    // camera basis
    STVector3 up = pScene->GetCamera()->Up();
    STVector3 right = pScene->GetCamera()->Right();
    STVector3 dir = pScene->GetCamera()->LookAt();
    STVector3 front;
    front = front.Cross(right, xaxis);
    front.Normalize();

    // camera plane
    float colx[4] = {1, 0, 0, 1};
    float coly[4] = {0, 1, 0, 1};
    float colz[4] = {0, 0, 1, 1};
    float colall[4] = {1, 1, 1, 1};

    float fct = 0.05f;
    float fct2 = 0.83f;

    STMatrix4 curModelMatrix;
    curModelMatrix.EncodeI();

    //------------------------------------------------------------------------------
    // TO DO: Proj3_4 OpenGL
    // Update the matrix transformation for the manipulator geometry
    // Update curModelMatrix
    //------------------------------------------------------------------------------
    curModelMatrix.EncodeS(0.1, 0.1, 0.1);
    //-------------------------------------------------------------------------------

    // screen projection
    ViewProjectionScreenSpace(curModelMatrix);

    STVector3 origin(0,0,0);
    curModelMatrix.GetT(&origin.x, &origin.y, &origin.z);

    if(pScene->CurrentManipMode() == LOCAL) {
        xaxis.Transform(curModelMatrix);
        yaxis.Transform(curModelMatrix);
        zaxis.Transform(curModelMatrix);
        xaxis.Normalize();
        yaxis.Normalize();
        zaxis.Normalize();
    }


    // Rotations
    if((pScene->CurrentManipGeometryState() == AXIS_ALL) || 
        (pScene->CurrentManipGeometryState() == AXIS_ROTATIONALL)) {


        STVector3 X_UP;
        STVector3 X_RIGHT;
        STVector3 X_FRONT;
        STVector3 X_UP_sc;
        STVector3 X_RIGHT_sc;
        STVector3 X_FRONT_sc;


        STVector3 planenorm(pScene->GetCamera()->Position() - origin);
        planenorm.Normalize();
        STVector4 camplane = vector4(planenorm,0);
        
        // duplicate
        X_RIGHT   =   right    * ScreenFactor();
        X_UP      =   up       * ScreenFactor();
        if(pScene->CurrentManipMotion() == ROTATE_DUPLICATE)
            DrawCircle(origin, colorWhite, X_RIGHT, X_UP);
        else
            DrawCircle(origin, colorGrey, X_RIGHT, X_UP);


        // screen rot
        X_UP_sc    =  up * 1.2f       * ScreenFactor();
        X_RIGHT_sc =  right * 1.2f    * ScreenFactor();
        if(pScene->CurrentManipMotion() == ROTATE_SCREEN) 
            DrawCircle(origin, colorWhite, X_UP_sc, X_RIGHT_sc);
        else 
            DrawCircle(origin, colorMagenta, X_UP_sc, X_RIGHT_sc);


        // x rot
        right.Cross(dir, xaxis);
        right.Normalize();
        front.Cross(right, xaxis);
        front.Normalize();
//.........这里部分代码省略.........
开发者ID:valdersoul,项目名称:CGProject3-4,代码行数:101,代码来源:mainsrc_proj3_4.cpp


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