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


C++ MatrixF::getScale方法代码示例

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


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

示例1: zapScale

void TSShapeLoader::zapScale(MatrixF& mat)
{
   Point3F invScale = mat.getScale();
   invScale.x = invScale.x ? (1.0f / invScale.x) : 0;
   invScale.y = invScale.y ? (1.0f / invScale.y) : 0;
   invScale.z = invScale.z ? (1.0f / invScale.z) : 0;
   mat.scale(invScale);
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:8,代码来源:tsShapeLoader.cpp

示例2: lookupSkinData


//.........这里部分代码省略.........
            S32 minIndex = weight.size() - TSSkinMesh::BatchData::maxBonePerVert;
            F32 minWeight = weight[minIndex];
            for (S32 i = minIndex + 1; i < weight.size(); i++)
            {
               if (weight[i] < minWeight)
               {
                  minWeight = weight[i];
                  minIndex = i;
               }
            }

            boneIndex[minIndex] = bIndex;
            weight[minIndex] = bWeight;
         }
         else
         {
            vertexIndex.push_back( iVert );
            boneIndex.push_back( bIndex );
            weight.push_back( bWeight );
            nonZeroWeightCount++;
         }
      }
   }

   // Normalize vertex weights (force weights for each vert to sum to 1)
   int iWeight = 0;
   while (iWeight < weight.size()) {
      // Find the last weight with the same vertex number, and sum all weights for
      // that vertex
      F32 invTotalWeight = 0;
      int iLast;
      for (iLast = iWeight; iLast < weight.size(); iLast++) {
         if (vertexIndex[iLast] != vertexIndex[iWeight])
            break;
         invTotalWeight += weight[iLast];
      }

      // Then normalize the vertex weights
      invTotalWeight = 1.0f / invTotalWeight;
      for (; iWeight < iLast; iWeight++)
         weight[iWeight] *= invTotalWeight;
   }

   // Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
   bones.setSize(streams.joints.size());
   initialTransforms.setSize(streams.joints.size());
   for (int iJoint = 0; iJoint < streams.joints.size(); iJoint++)
   {
      const char* jointName = streams.joints.getStringValue(iJoint);

      // Lookup the joint element
      const domNode* joint = 0;
      if (instanceCtrl->getSkeleton_array().getCount()) {
         // Search for the node using the <skeleton> as the base element
         for (int iSkel = 0; iSkel < instanceCtrl->getSkeleton_array().getCount(); iSkel++) {
            xsAnyURI skeleton = instanceCtrl->getSkeleton_array()[iSkel]->getValue();
            daeSIDResolver resolver(skeleton.getElement(), jointName);
            joint = daeSafeCast<domNode>(resolver.getElement());
            if (joint)
               break;
         }
      }
      else {
         // Search for the node from the root level
         daeSIDResolver resolver(skin->getDocument()->getDomRoot(), jointName);
         joint = daeSafeCast<domNode>(resolver.getElement());
      }

      if (!joint) {
         daeErrorHandler::get()->handleWarning(avar("Failed to find bone '%s', "
            "defaulting to instance_controller parent node '%s'", jointName, appNode->getName()));
         joint = appNode->getDomNode();
      }
      bones[iJoint] = new ColladaAppNode(joint);

      initialTransforms[iJoint] = objectOffset;

      // Bone scaling is generally ignored during import, since 3space only
      // stores default node transform and rotation. Compensate for this by
      // removing the scaling from the inverse bind transform as well
      MatrixF invBind = streams.invBindMatrices.getMatrixFValue(iJoint);
      if (!ColladaUtils::getOptions().ignoreNodeScale)
      {
         Point3F invScale = invBind.getScale();
         invScale.x = invScale.x ? (1.0f / invScale.x) : 0;
         invScale.y = invScale.y ? (1.0f / invScale.y) : 0;
         invScale.z = invScale.z ? (1.0f / invScale.z) : 0;
         initialTransforms[iJoint].scale(invScale);
      }

      // Inverted node coordinate spaces (negative scale factor) are corrected
      // in ColladaAppNode::getNodeTransform, so need to apply the same operation
      // here to match
      if (m_matF_determinant(invBind) < 0.0f)
         initialTransforms[iJoint].scale(Point3F(1, 1, -1));

      initialTransforms[iJoint].mul(invBind);
      initialTransforms[iJoint].mul(bindShapeMatrix);
   }
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:101,代码来源:colladaAppMesh.cpp


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