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


C++ Matrix3::getCol0方法代码示例

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


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

示例1: length

void Magic3D::Object::applyMatrix(Matrix4 matrix)
{
    Vector3 tmpPos = matrix.getTranslation();
    Matrix3 mRot = matrix.getUpper3x3();
    Vector3 tmpScale  = Vector3(length(mRot.getCol0()), length(mRot.getCol1()), length(mRot.getCol2()));

    mRot.setCol0(normalize(mRot.getCol0()));
    mRot.setCol1(normalize(mRot.getCol1()));
    mRot.setCol2(normalize(mRot.getCol2()));

    setPosition(tmpPos);
    setRotation(Quaternion(mRot));
    setScale(tmpScale);
}
开发者ID:whztt07,项目名称:Magic3D-2,代码行数:14,代码来源:object.cpp

示例2: getMatrix

Magic3D::Matrix4 Magic3D::Object::getMatrixFromParent()
{
    Matrix4 m = getMatrix();

    if (getParent())
    {
        m = getParent()->getMatrixFromParent();

        if (getParentBone())
        {
            m = m * getParentBone()->getMatrixFromParent();
        }

        if (isParentPosition() && isParentRotation() && isParentScale())
        {
            m = m * getMatrix();
        }
        else
        {
            Vector3 tmpPos = m.getTranslation();
            Matrix3 mRot = m.getUpper3x3();
            Vector3 tmpScale  = Vector3(length(mRot.getCol0()), length(mRot.getCol1()), length(mRot.getCol2()));

            mRot.setCol0(normalize(mRot.getCol0()));
            mRot.setCol1(normalize(mRot.getCol1()));
            mRot.setCol2(normalize(mRot.getCol2()));

            m = Matrix4::identity();

            if (isParentRotation())
            {
                m = m * Matrix4(mRot, Vector3(0.0f, 0.0f, 0.0f));
            }

            if (isParentPosition())
            {
                m.setTranslation(tmpPos);
            }

            if (isParentScale())
            {
                m = appendScale(m, tmpScale); // Faster than creating and multiplying a scale transformation matrix.
            }

            m = m * getMatrix();
        }
    }

    if (billboard != eBILLBOARD_NONE)
    {
        Camera* camera = Renderer::getInstance()->getCurrentViewPort()->getPerspective();
        Matrix3 view = camera->getView().getUpper3x3();
        Matrix3 bb = Matrix3::identity();

        switch (billboard)
        {
            case eBILLBOARD_HORIZONTAL:
            {
                Vector3 v1 = Vector3(1.0f, 0.0f, 0.0f);
                Vector3 v2 = view.getCol0();

                float angle = Math::angle(v1, v2, Vector3(0.0f, 1.0f, 0.0f));

                bb = Matrix3::rotationY(angle);
                break;
            }
            case eBILLBOARD_VERTICAL:
            {
                Vector3 v1 = Vector3(0.0f, 1.0f, 0.0f);
                Vector3 v2 = view.getCol1();

                float angle = Math::angle(v1, v2, Vector3(1.0f, 0.0f, 0.0f));

                bb = Matrix3::rotationX(angle);
                break;
            }
            default:
            {
                bb = view;
                break;
            }            
        }

        bb = inverse(m.getUpper3x3()) * inverse(bb);

        m = m * Matrix4(bb, Vector3(0.0f, 0.0f, 0.0f));
    }

    return m;
}
开发者ID:whztt07,项目名称:Magic3D-2,代码行数:90,代码来源:object.cpp


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