// Tranforms vertices from world to window coordinates, via world, eye, clip, and normalized device coordinates. vector<glm::vec4> pipeline(const vector<glm::vec4> & objectCoords) { vector<glm::vec4> worldCoords = transformVertices(modelingTransformation, objectCoords); vector<glm::vec4> eyeCoords = transformVertices(viewingTransformation, worldCoords); vector<glm::vec4> projCoords = transformVertices(projectionTransformation, eyeCoords); vector<glm::vec4> clipCoords; // Perspective division for (glm::vec4 v : projCoords) { v = v / v.w; clipCoords.push_back(v); } // Clipping vector<glm::vec4> ndcCoords = clipCoords; // clip(clipCoords); vector<glm::vec4> windowCoords = transformVertices(viewportTransformation, ndcCoords); return windowCoords; } // end pipeline
void rspfGeoPolyCutter::addPolygon(const rspfGeoPolygon& polygon) { rspfPolyCutter::addPolygon(rspfPolygon()); theGeoPolygonList.push_back(polygon); if(theViewProjection.valid()) { transformVertices(((int)theGeoPolygonList.size())-1); } }
void rspfGeoPolyCutter::setPolygon(const rspfGeoPolygon& polygon, rspf_uint32 i) { if(i < theGeoPolygonList.size()) { theGeoPolygonList[i] = polygon.getVertexList(); transformVertices(i); } }
void rspfGeoPolyCutter::setPolygon(const vector<rspfGpt>& polygon, rspf_uint32 i) { if(i < theGeoPolygonList.size()) { theGeoPolygonList[i] = polygon; transformVertices(i); } }
bool rspfGeoPolyCutter::loadState(const rspfKeywordlist& kwl, const char* prefix) { rspfString copyPrefix(prefix); rspfString polygons = rspfString("^(") + copyPrefix + "geo_polygon[0-9]+.)"; vector<rspfString> keys = kwl.getSubstringKeyList( polygons ); int offset = (int)(copyPrefix+"geo_polygon").size(); std::vector<int> numberList(keys.size()); for(int idx = 0; idx < (int)numberList.size();++idx) { rspfString numberStr(keys[idx].begin() + offset, keys[idx].end()); numberList[idx] = numberStr.toInt(); } std::sort(numberList.begin(), numberList.end()); rspfString newPrefix; thePolygonList.clear(); for(int i = 0; i < (int)numberList.size();++i) { theGeoPolygonList.push_back(rspfGeoPolygon()); newPrefix = copyPrefix+"geo_polygon"+rspfString::toString(numberList[i])+"."; theGeoPolygonList[i].loadState(kwl, newPrefix.c_str()); } const char* lookup = kwl.find(prefix, "cut_type"); if(lookup) { theCutType = RSPF_POLY_NULL_INSIDE; rspfString test = lookup; if(test == "null_outside") { theCutType = RSPF_POLY_NULL_OUTSIDE; } } else { theCutType = RSPF_POLY_NULL_OUTSIDE; } rspfString viewPrefix = prefix; viewPrefix += "view."; theViewProjection = new rspfImageGeometry(); if(theViewProjection->loadState(kwl, viewPrefix)) { transformVertices(); } return rspfImageSourceFilter::loadState(kwl, prefix); }
bool rspfGeoPolyCutter::setView(rspfObject* baseObject) { rspfProjection* proj = dynamic_cast<rspfProjection*>(baseObject); if(proj) { theViewProjection = new rspfImageGeometry(0, proj); transformVertices(); } else { theViewProjection = dynamic_cast<rspfImageGeometry*>(baseObject); } return theViewProjection.valid(); }
void LoaderFbxMesh::parseMesh(FbxMesh* mesh, FbxPose* fbxPose, LoaderFbxMeshDesc* meshDesc) { reset(); meshDesc->setFbxMesh(mesh); int polygonVertexCount = mesh->GetPolygonVertexCount(); int polygonCount = mesh->GetPolygonCount(); int numControlPonts = mesh->GetControlPointsCount(); FbxVector4* controlPoints = mesh->GetControlPoints(); int vertexId = 0; for(int polygonIndex=0; polygonIndex<polygonCount; polygonIndex++) { parsePolygonGroup(mesh, polygonIndex); int polygonSize = mesh->GetPolygonSize(polygonIndex); for(int insidePolygonIndex=0; insidePolygonIndex<polygonSize; insidePolygonIndex++) { int controlPointIndex = mesh->GetPolygonVertex(polygonIndex, insidePolygonIndex); parseVertexPositions(mesh, controlPoints, controlPointIndex); parseVertexColors(mesh, controlPointIndex, vertexId); parseVertexNormals(mesh, controlPointIndex, vertexId); parseVertexUVs(mesh, polygonIndex, insidePolygonIndex, controlPointIndex); parseVertexTangents(mesh, controlPointIndex, vertexId); parseVertexBinormals(mesh, controlPointIndex, vertexId); vertexId++; } } transformVertices(mesh); meshDesc->setPolygonGroupIds(polygonGroupIds_); meshDesc->setVertexPositions(vertexPositions_); meshDesc->setVertexNormals(vertexNormals_); meshDesc->setVertexUVs(vertexUVs_); meshDesc->setVertexTangents(vertexTangents_); meshDesc->setVertexBinormals(vertexBinormals_); parseVertexLinkData(mesh, fbxPose, meshDesc); meshDesc->fillBoneData(); }
Node PaintBrush::imageNode(int dimX, int dimY, bool transform) { Node result("extension"); Attribute cAttr("class", "eurecom.usergraph.UserGraph"); result.addAttribute(cAttr); Logger::entry("info") << "dimX = " << dimX; Logger::entry("info") << "dimY = " << dimY; if (!actions_.empty()) { if (transform) result.addChildren(vertexNodes(transformVertices(dimX, dimY))); else result.addChildren(vertexNodes(vertexList_)); result.addChildren(edgeNodes()); } return result; }
bool WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { unsigned int vsize = ifs.vsize(); unsigned int nsize = ifs.nsize(); //soc unused - unsigned tsize = ifs.tsize(); const real *vertices = ifs.vertices(); const real *normals = ifs.normals(); const real *texCoords = ifs.texCoords(); real *new_vertices; real *new_normals; new_vertices = new real[vsize]; new_normals = new real[nsize]; // transform coordinates from local to world system if (_current_matrix) { transformVertices(vertices, vsize, *_current_matrix, new_vertices); transformNormals(normals, nsize, *_current_matrix, new_normals); } else { memcpy(new_vertices, vertices, vsize * sizeof(*new_vertices)); memcpy(new_normals, normals, nsize * sizeof(*new_normals)); } const IndexedFaceSet::TRIANGLES_STYLE *faceStyle = ifs.trianglesStyle(); vector<FrsMaterial> frs_materials; if (ifs.msize()) { const FrsMaterial *const *mats = ifs.frs_materials(); for (unsigned i = 0; i < ifs.msize(); ++i) frs_materials.push_back(*(mats[i])); shape.setFrsMaterials(frs_materials); } #if 0 const FrsMaterial *mat = (ifs.frs_material()); if (mat) shape.setFrsMaterial(*mat); else if (_current_frs_material) shape.setFrsMaterial(*_current_frs_material); #endif const IndexedFaceSet::FaceEdgeMark *faceEdgeMarks = ifs.faceEdgeMarks(); // sets the current WShape to shape _current_wshape = &shape; // create a WVertex for each vertex buildWVertices(shape, new_vertices, vsize); const unsigned int *vindices = ifs.vindices(); const unsigned int *nindices = ifs.nindices(); const unsigned int *tindices = NULL; if (ifs.tsize()) { tindices = ifs.tindices(); } const unsigned int *mindices = NULL; if (ifs.msize()) mindices = ifs.mindices(); const unsigned int *numVertexPerFace = ifs.numVertexPerFaces(); const unsigned int numfaces = ifs.numFaces(); for (unsigned int index = 0; index < numfaces; index++) { switch (faceStyle[index]) { case IndexedFaceSet::TRIANGLE_STRIP: buildTriangleStrip(new_vertices, new_normals, frs_materials, texCoords, faceEdgeMarks, vindices, nindices, mindices, tindices, numVertexPerFace[index]); break; case IndexedFaceSet::TRIANGLE_FAN: buildTriangleFan(new_vertices, new_normals, frs_materials, texCoords, faceEdgeMarks, vindices, nindices, mindices, tindices, numVertexPerFace[index]); break; case IndexedFaceSet::TRIANGLES: buildTriangles(new_vertices, new_normals, frs_materials, texCoords, faceEdgeMarks, vindices, nindices, mindices, tindices, numVertexPerFace[index]); break; } vindices += numVertexPerFace[index]; nindices += numVertexPerFace[index]; if (mindices) mindices += numVertexPerFace[index]; if (tindices) tindices += numVertexPerFace[index]; faceEdgeMarks++; } delete[] new_vertices; delete[] new_normals; if (shape.GetFaceList().size() == 0) // this may happen due to degenerate triangles return false; // compute bbox shape.ComputeBBox(); // compute mean edge size: shape.ComputeMeanEdgeSize(); // Parse the built winged-edge shape to update post-flags set<Vec3r> normalsSet; vector<WVertex *>& wvertices = shape.getVertexList(); for (vector<WVertex *>::iterator wv = wvertices.begin(), wvend = wvertices.end(); wv != wvend; ++wv) { if ((*wv)->isBoundary()) continue; if ((*wv)->GetEdges().size() == 0) // This means that the WVertex has no incoming edges... (12-Sep-2011 T.K.) continue; normalsSet.clear(); WVertex::face_iterator fit = (*wv)->faces_begin(); WVertex::face_iterator fitend = (*wv)->faces_end(); for (; fit != fitend; ++fit) { WFace *face = *fit; normalsSet.insert(face->GetVertexNormal(*wv)); if (normalsSet.size() != 1) { break; } } if (normalsSet.size() != 1) { (*wv)->setSmooth(false); } } // Adds the new WShape to the WingedEdge structure _winged_edge->addWShape(&shape); return true; }