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


C++ Mat4f::transformVector方法代码示例

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


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

示例1: setupQuad

    void binPlane1D(Vec3f center, Vec3f a, Vec3f b, Vec3f c, Intersector intersector) const
    {
        center = _invT*center;
        a = _invT.transformVector(a);
        b = _invT.transformVector(b);
        c = _invT.transformVector(c);

        std::array<QuadSetup, 6> quads{{
            setupQuad(center + c - a - b, center + c - a + b, center + c + a + b, center + c + a - b),
            setupQuad(center - c - a - b, center - c - a + b, center - c + a + b, center - c + a - b),
            setupQuad(center + b - a - c, center + b - a + c, center + b + a + c, center + b + a - c),
            setupQuad(center - b - a - c, center - b - a + c, center - b + a + c, center - b + a - c),
            setupQuad(center + a - b - c, center + a - b + c, center + a + b + c, center + a + b - c),
            setupQuad(center - a - b - c, center - a - b + c, center - a + b + c, center - a + b - c)
        }};

        iterateTiles(quads, intersector);
    }
开发者ID:tunabrain,项目名称:tungsten,代码行数:18,代码来源:FrustumBinner.hpp

示例2: updateAttributes

void Rectangle::updateAttributes(Config cfg)
{
  std::vector<TriangleFace> *faces; {
    TriangleVertex level0[4];
    level0[0] = TriangleVertex(Vec3f(0.0,0.0,0.0),0);
    level0[1] = TriangleVertex(Vec3f(1.0,0.0,0.0),1);
    level0[2] = TriangleVertex(Vec3f(1.0,0.0,1.0),2);
    level0[3] = TriangleVertex(Vec3f(0.0,0.0,1.0),3);

    std::vector<TriangleFace> facesLevel0(2);
    facesLevel0[0] = TriangleFace( level0[0], level0[1], level0[3] );
    facesLevel0[1] = TriangleFace( level0[1], level0[2], level0[3] );
    faces = tessellate(cfg.levelOfDetail, facesLevel0);
  }
  Mat4f rotMat = Mat4f::rotationMatrix(cfg.rotation.x, cfg.rotation.y, cfg.rotation.z);
  GLboolean useIndexBuffer = (cfg.levelOfDetail>1);

  GLuint numVertices;
  std::map<GLuint,GLuint> indexMap;
  std::set<GLuint> processedIndices;

  ref_ptr<ShaderInput1ui> indices;
  if(useIndexBuffer) {
    // Allocate RAM for indices
    GLuint numIndices = faces->size()*3;
    indices = ref_ptr<ShaderInput1ui>::alloc("i");
    indices->setVertexData(numIndices);
    GLuint *indicesPtr = (GLuint*)indices->clientDataPtr();

    // Set index data and compute vertex count
    GLuint currIndex = 0;
    for(GLuint faceIndex=0; faceIndex<faces->size(); ++faceIndex) {
      TriangleFace &face = (*faces)[faceIndex];
      TriangleVertex *vertices = (TriangleVertex*)&face;

      for(GLuint i=0; i<3; ++i) {
        TriangleVertex &vertex = vertices[i];
        // Find vertex index
        if(indexMap.count(vertex.i)==0) {
          indexMap[vertex.i] = currIndex;
          currIndex += 1;
        }
        // Add to indices attribute
        *indicesPtr = indexMap[vertex.i];
        indicesPtr += 1;
      }
    }
    numVertices = indexMap.size();
  }
  else {
    numVertices = faces->size()*3;
  }

  if(cfg.isTangentRequired) {
    cfg.isNormalRequired = GL_TRUE;
    cfg.isTexcoRequired = GL_TRUE;
  }
  Vec3f startPos;
  if(cfg.centerAtOrigin) {
    startPos = Vec3f(-cfg.posScale.x*0.5f, 0.0f, -cfg.posScale.z*0.5f);
  } else {
    startPos = Vec3f(0.0f, 0.0f, 0.0f);
  }

  // allocate attributes
  pos_->setVertexData(numVertices);
  if(cfg.isNormalRequired) {
    nor_->setVertexData(numVertices);
  }
  if(cfg.isTexcoRequired) {
    texco_->setVertexData(numVertices);
  }
  if(cfg.isTangentRequired) {
    tan_->setVertexData(numVertices);
  }

  GLuint triIndices[3];
  Vec3f triVertices[3];
  Vec2f triTexco[3];
  Vec3f normal = rotMat.transformVector(Vec3f(0.0,-1.0,0.0));

  for(GLuint faceIndex=0; faceIndex<faces->size(); ++faceIndex) {
    TriangleFace &face = (*faces)[faceIndex];
    TriangleVertex *vertices = (TriangleVertex*)&face;

    for(GLuint i=0; i<3; ++i) {
      GLuint vertexIndex;
      if(useIndexBuffer) {
        vertexIndex = indexMap[vertices[i].i];
      }
      else {
        vertexIndex = faceIndex*3+i;
      }
      triIndices[i] = vertexIndex;

      if(processedIndices.count(vertexIndex)>0) {
        if(cfg.isTangentRequired) {
          triVertices[i] = pos_->getVertex(vertexIndex);
          triTexco[i]    = texco_->getVertex(vertexIndex);
        }
//.........这里部分代码省略.........
开发者ID:daniel86,项目名称:regen,代码行数:101,代码来源:rectangle.cpp


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