📄 coresubmesh.cpp
字号:
m_vectorvectorTangentSpace.resize(textureCoordinateCount); m_vectorvectorTextureCoordinate.reserve(textureCoordinateCount); m_vectorvectorTextureCoordinate.resize(textureCoordinateCount); int textureCoordinateId; for(textureCoordinateId = 0; textureCoordinateId < textureCoordinateCount; ++textureCoordinateId) { m_vectorvectorTextureCoordinate[textureCoordinateId].reserve(vertexCount); m_vectorvectorTextureCoordinate[textureCoordinateId].resize(vertexCount); if (m_vectorTangentsEnabled[textureCoordinateId]) { m_vectorvectorTangentSpace[textureCoordinateId].reserve(vertexCount); m_vectorvectorTangentSpace[textureCoordinateId].resize(vertexCount); } else { m_vectorvectorTangentSpace[textureCoordinateId].clear(); } } m_vectorFace.reserve(faceCount); m_vectorFace.resize(faceCount); m_vectorSpring.reserve(springCount); m_vectorSpring.resize(springCount); // reserve the space for the physical properties if we have springs in the core submesh instance if(springCount > 0) { m_vectorPhysicalProperty.reserve(vertexCount); m_vectorPhysicalProperty.resize(vertexCount); } return true;} /*****************************************************************************//** Sets the ID of the core material thread. * * This function sets the ID of the core material thread of the core submesh * instance. * * @param coreMaterialThreadId The ID of the core material thread that should * be set. *****************************************************************************/void CalCoreSubmesh::setCoreMaterialThreadId(int coreMaterialThreadId){ m_coreMaterialThreadId = coreMaterialThreadId;} /*****************************************************************************//** Sets a specified face. * * This function sets a specified face in the core submesh instance. * * @param faceId The ID of the face. * @param face The face that should be set. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setFace(int faceId, const Face& face){ if((faceId < 0) || (faceId >= (int)m_vectorFace.size())) return false; m_vectorFace[faceId] = face; return true;} /*****************************************************************************//** Sets the number of LOD steps. * * This function sets the number of LOD steps of the core submesh instance. * * @param lodCount The number of LOD steps that should be set. *****************************************************************************/void CalCoreSubmesh::setLodCount(int lodCount){ m_lodCount = lodCount;} /*****************************************************************************//** Sets the tangent vector associated with a specified texture coordinate pair. * * This function sets the tangent vector associated with a specified * texture coordinate pair in the core submesh instance. * * @param vertexId The ID of the vertex. * @param textureCoordinateId The ID of the texture coordinate channel. * @param tangent The tangent vector that should be stored. * @param crossFactor The cross-product factor that should be stored. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setTangentSpace(int vertexId, int textureCoordinateId, const CalVector& tangent, float crossFactor){ if((vertexId < 0) || (vertexId >= (int)m_vectorVertex.size())) return false; if((textureCoordinateId < 0) || (textureCoordinateId >= (int)m_vectorvectorTextureCoordinate.size())) return false; if(!m_vectorTangentsEnabled[textureCoordinateId]) return false; m_vectorvectorTangentSpace[textureCoordinateId][vertexId].tangent = tangent; m_vectorvectorTangentSpace[textureCoordinateId][vertexId].crossFactor = crossFactor; return true;} /*****************************************************************************//** Sets a specified physical property. * * This function sets a specified physical property in the core submesh * instance. * * @param vertexId The ID of the vertex. * @param physicalProperty The physical property that should be set. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setPhysicalProperty(int vertexId, const PhysicalProperty& physicalProperty){ if((vertexId < 0) || (vertexId >= (int)m_vectorPhysicalProperty.size())) return false; m_vectorPhysicalProperty[vertexId] = physicalProperty; return true;} /*****************************************************************************//** Sets a specified spring. * * This function sets a specified spring in the core submesh instance. * * @param springId The ID of the spring. * @param spring The spring that should be set. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setSpring(int springId, const Spring& spring){ if((springId < 0) || (springId >= (int)m_vectorSpring.size())) return false; m_vectorSpring[springId] = spring; return true;} /*****************************************************************************//** Sets a specified texture coordinate. * * This function sets a specified texture coordinate in the core submesh * instance. * * @param vertexId The ID of the vertex. * @param textureCoordinateId The ID of the texture coordinate. * @param textureCoordinate The texture coordinate that should be set. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setTextureCoordinate(int vertexId, int textureCoordinateId, const TextureCoordinate& textureCoordinate){ if((textureCoordinateId < 0) || (textureCoordinateId >= (int)m_vectorvectorTextureCoordinate.size())) return false; if((vertexId < 0) || (vertexId >= (int)m_vectorvectorTextureCoordinate[textureCoordinateId].size())) return false; m_vectorvectorTextureCoordinate[textureCoordinateId][vertexId] = textureCoordinate; return true;} /*****************************************************************************//** Sets a specified vertex. * * This function sets a specified vertex in the core submesh instance. * * @param vertexId The ID of the vertex. * @param vertex The vertex that should be set. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreSubmesh::setVertex(int vertexId, const Vertex& vertex){ if((vertexId < 0) || (vertexId >= (int)m_vectorVertex.size())) return false; m_vectorVertex[vertexId] = vertex; return true;} /*****************************************************************************//** Adds a core sub morph target. * * This function adds a core sub morph target to the core sub mesh instance. * * @param pCoreSubMorphTarget A pointer to the core sub morph target that should be added. * * @return One of the following values: * \li the assigned sub morph target \b ID of the added core sub morph target * \li \b -1 if an error happend *****************************************************************************/int CalCoreSubmesh::addCoreSubMorphTarget(CalCoreSubMorphTarget *pCoreSubMorphTarget){ // get next sub morph target id int subMorphTargetId; subMorphTargetId = m_vectorCoreSubMorphTarget.size(); m_vectorCoreSubMorphTarget.push_back(pCoreSubMorphTarget); return subMorphTargetId;} /*****************************************************************************//** Provides access to a core sub morph target. * * This function returns the core sub morph target with the given ID. * * @param id The ID of the core sub morph target that should be returned. * * @return One of the following values: * \li a pointer to the core sub morph target * \li \b 0 if an error happend *****************************************************************************/CalCoreSubMorphTarget *CalCoreSubmesh::getCoreSubMorphTarget(int id){ if((id < 0) || (id >= (int)m_vectorCoreSubMorphTarget.size())) { return 0; } return m_vectorCoreSubMorphTarget[id];} /*****************************************************************************//** Returns the number of core sub morph targets. * * This function returns the number of core sub morph targets in the core sub mesh * instance. * * @return The number of core sub morph targets. *****************************************************************************/int CalCoreSubmesh::getCoreSubMorphTargetCount(){ return m_vectorCoreSubMorphTarget.size();} /*****************************************************************************//** Returns the core sub morph target vector. * * This function returns the vector that contains all core sub morph target * of the core submesh instance. * * @return A reference to the core sub morph target vector. *****************************************************************************/std::vector<CalCoreSubMorphTarget *>& CalCoreSubmesh::getVectorCoreSubMorphTarget(){ return m_vectorCoreSubMorphTarget;} /*****************************************************************************//** Scale the Submesh. * * This function rescale all the data that are in the core submesh instance. * * @param factor A float with the scale factor * *****************************************************************************/void CalCoreSubmesh::scale(float factor){ // rescale all vertices for(size_t vertexId = 0; vertexId < m_vectorVertex.size() ; vertexId++) { m_vectorVertex[vertexId].position*=factor; } if(!m_vectorSpring.empty()) { // There is a problem when we resize and that there is // a spring system, I was unable to solve this // problem, so I disable the spring system // if the scale are too big if( fabs(factor - 1.0f) > 0.10) { m_vectorSpring.clear(); m_vectorPhysicalProperty.clear(); }/* for(vertexId = 0; vertexId < m_vectorVertex.size() ; vertexId++) { //m_vectorPhysicalProperty[vertexId].weight *= factor; m_vectorPhysicalProperty[vertexId].weight *= factor*factor; //m_vectorPhysicalProperty[vertexId].weight *= 0.5f; } int springId; for(springId = 0; springId < m_vectorVertex.size() ; springId++) { //m_vectorSpring[springId].idleLength*=factor; CalVector distance = m_vectorVertex[m_vectorSpring[springId].vertexId[1]].position - m_vectorVertex[m_vectorSpring[springId].vertexId[0]].position; m_vectorSpring[springId].idleLength = distance.length(); } */ } }//****************************************************************************//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -