TFMarkerArrows::TFMarkerArrows(rviz::DisplayContext* context, Ogre::SceneNode* parentNode, TFMarker* parent, const Ogre::Quaternion& orientation, const Ogre::Vector3& scale, double distance) : TFMarkerControl(context, parentNode, parent, true, false, "<b>Left-Click:</b> Move."), positiveArrow(new rviz::Arrow(context->getSceneManager(), sceneNode)), negativeArrow(new rviz::Arrow(context->getSceneManager(), sceneNode)) { cursor = rviz::makeIconCursor("package://rviz/icons/move1d.svg"); positiveArrow->setOrientation(Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo( Ogre::Vector3::UNIT_X)); positiveArrow->set(0.5, 0.6, 0.5, 1.0); negativeArrow->setOrientation(Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo( Ogre::Vector3::NEGATIVE_UNIT_X)); negativeArrow->set(0.5, 0.6, 0.5, 1.0); setOrientation(orientation); setScale(scale); setDistance(distance); addMaterial(positiveArrow->getShaft()->getMaterial()); addMaterial(positiveArrow->getHead()->getMaterial()); addMaterial(negativeArrow->getShaft()->getMaterial()); addMaterial(negativeArrow->getHead()->getMaterial()); }
void * addFont(zoneInfo_t* info, const char* name, char* data, int dataLen) { if (dataLen > 0) { Com_Error(false, "Can't add new fonts!"); return NULL; } Font* font = (Font*)data; addAsset(info, ASSET_TYPE_MATERIAL, font->image->name, addMaterial(info, font->image->name, (char*)font->image, -1)); addAsset(info, ASSET_TYPE_MATERIAL, font->glowImage->name, addMaterial(info, font->glowImage->name, (char*)font->glowImage, -1)); return data; }
// Set the current material GLC_uint GLC_Mesh::setCurrentMaterial(GLC_Material* pMaterial, int lod, double accuracy) { // Test if a primitive group hash exists for the specified lod if (!m_PrimitiveGroups.contains(lod)) { m_PrimitiveGroups.insert(lod, new LodPrimitiveGroups()); m_MeshData.appendLod(accuracy); } GLC_uint returnId; if (NULL == pMaterial) { returnId= m_DefaultMaterialId; // Default material id // Test if the material has been already load if (m_DefaultMaterialId == 0) { pMaterial= new GLC_Material(); // Add the material to the mesh addMaterial(pMaterial); m_DefaultMaterialId= pMaterial->id(); returnId= m_DefaultMaterialId; } // Test if a primitive group for this material exist if (!m_PrimitiveGroups.value(lod)->contains(returnId)) { m_PrimitiveGroups.value(lod)->insert(returnId, new GLC_PrimitiveGroup(returnId)); } } else { returnId= pMaterial->id(); // Test if the material has been already load if (!containsMaterial(returnId)) { // Add the material to the mesh addMaterial(pMaterial); m_PrimitiveGroups.value(lod)->insert(returnId, new GLC_PrimitiveGroup(returnId)); } else if (!m_PrimitiveGroups.value(lod)->contains(returnId)) { // Add the material to the group m_PrimitiveGroups.value(lod)->insert(returnId, new GLC_PrimitiveGroup(returnId)); } } return returnId; }
void ResourceManager::addTextureMaterialSprite( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, const std::string& texturePath, unsigned frameRate, bool repeat, unsigned begin, unsigned end, int layer, const glm::vec2& size, const glm::vec2& texSize, const glm::vec2& texOffset, unsigned textureFlags, unsigned materialFlags ) { // texture addTexture( id, resourceGroup, texturePath, frameRate, repeat, begin, end, textureFlags ); // material addMaterial( id, resourceGroup, shader, colour, id, materialFlags ); // sprite addSprite( id, resourceGroup, layer, id, size, texSize, texOffset ); }
void ResourceManager::addTextureMaterialGeometryMesh( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, const std::string& texturePath, unsigned frameRate, bool repeat, unsigned begin, unsigned end, const std::string& geometryPath, int layer, unsigned textureFlags, unsigned materialFlags ) { // texture addTexture( id, resourceGroup, texturePath, frameRate, repeat, begin, end, textureFlags ); // material addMaterial( id, resourceGroup, shader, colour, id, materialFlags ); // geometry addGeometry( id, resourceGroup, geometryPath ); // mesh addMesh( id, resourceGroup, layer, id, id ); }
/* ============================================================================= ADD MATERIAL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\* This function adds a material to our model manually since .obj has no such info ADD MATERIAL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\* =============================================================================== */ int C3DModel::addMaterial(string strName, string strFile, color clr, int iTxMode) { CMaterialPtr pMat = new CMaterial(); pMat->setTextureId(-1); pMat->setColor(clr); pMat->setHeight(0); pMat->setWidth(0); pMat->setName(strName); // If we have a file name passed in, copy it to our material structure if (strFile.size()) { int w, h; pMat->setLink(strFile); GLuint txID = createTexture(pMat->getLink(), w, h, iTxMode); pMat->setTextureId(txID); pMat->setHeight(h); pMat->setWidth(w); } pMat->setShared(false); addMaterial(pMat); return pMat->getTextureId(); }
void WldModel::readAllMaterials() { WLD* wld = m_wld; auto& frag30s = wld->getFragsByType(0x30); if (frag30s.size() == 0) throw 1; //fixme if (m_materialIndicesByF30.size() > 0) return; // Materials uint32_t i = 1; // Zeroth material is the NULL material for (Fragment* frag : frag30s) { Frag30* f30 = (Frag30*)frag; addMaterial(new WldMaterial(wld->getFragName(f30), f30->visibilityFlag)); m_materialIndicesByF30[f30] = i++; } // VertexBuffers initVertexBuffers(); // Textures for (Fragment* frag : frag30s) { Frag30* f30 = (Frag30*)frag; handleF30(f30); } }
void parseMaterials(GeometryConverter *cvt, std::ostream &os, const fs::path &texturesDir, const fs::path &mtlFileName, std::set<std::string> &mtlList) { SLog(EInfo, "Loading OBJ materials from \"%s\" ..", mtlFileName.file_string().c_str()); fs::ifstream is(mtlFileName); if (is.bad() || is.fail()) SLog(EError, "Unexpected I/O error while accessing material file '%s'!", mtlFileName.file_string().c_str()); std::string buf, line; std::string mtlName; Spectrum diffuse(0.0f); std::string diffuseMap, maskMap; while (is >> buf) { if (buf == "newmtl") { mtlList.insert(mtlName); addMaterial(cvt, os, mtlName, texturesDir, diffuse, diffuseMap, maskMap); std::getline(is, line); mtlName = trim(line.substr(1, line.length()-1)); diffuse = Spectrum(0.0f); diffuseMap = ""; maskMap = ""; } else if (buf == "Kd") { Float r, g, b; is >> r >> g >> b; if (cvt->m_srgb) diffuse.fromSRGB(r, g, b); else diffuse.fromLinearRGB(r, g, b); } else if (buf == "map_Kd") {
void WldModel::readMaterials(Frag36* f36) { WLD* wld = m_wld; // f36 -> f31 -> f30 Frag31* f31 = (Frag31*)wld->getFrag(f36->materialListRef); if (!f31) throw 1; //fixme for (uint32_t i = 0; i < f31->refCount; i++) { Frag30* f30 = (Frag30*)wld->getFrag(f31->refList[i]); addMaterial(new WldMaterial(wld->getFragName(f30), f30->visibilityFlag)); m_materialIndicesByF30[f30] = i + 1; } initVertexBuffers(); for (uint32_t i = 0; i < f31->refCount; i++) { Frag30* f30 = (Frag30*)wld->getFrag(f31->refList[i]); handleF30(f30); } }
void CMC_ModelData::loadFromTZW(const char *fileName) { // load All materials auto data = tzw::Tfile::getInstance()->getData (fileName,true); rapidjson::Document d; d.Parse((const char *)data.getBytes ()); auto& materialsObj= d["materials"]; for(auto iter = materialsObj.Begin ();iter!=materialsObj.End ();iter++) { auto& materialObj = *iter; auto material = new CMC_Material(); material->loadFromTZW (materialObj); addMaterial (material); } //load all meshes. auto& meshesObj = d["meshes"]; for(auto iter = meshesObj.Begin ();iter!= meshesObj.End ();iter++) { auto& meshObj = *iter; auto mesh = new CMC_MeshData(); mesh->loadFromTZW (meshObj); addMesh (mesh); } }
// Load the mesh from binary data stream void GLC_Mesh::loadFromDataStream(QDataStream& stream, const MaterialHash& materialHash, const QHash<GLC_uint, GLC_uint>& materialIdMap) { quint32 chunckId; stream >> chunckId; Q_ASSERT(chunckId == m_ChunkId); // The mesh name QString meshName; stream >> meshName; setName(meshName); // The wire data stream >> GLC_Geometry::m_WireData; // The mesh next primitive local id GLC_uint localId; stream >> localId; setNextPrimitiveLocalId(localId); // Retrieve geom mesh data stream >> m_MeshData; // Retrieve primitiveGroupLodList QList<int> primitiveGroupLodList; stream >> primitiveGroupLodList; // Retrieve primitiveGroup list QList<QList<GLC_PrimitiveGroup> > primitiveListOfGroupList; stream >> primitiveListOfGroupList; // Construct mesh primitiveGroupHash const int lodCount= primitiveGroupLodList.size(); for (int i= 0; i < lodCount; ++i) { GLC_Mesh::LodPrimitiveGroups* pCurrentPrimitiveGroup= new GLC_Mesh::LodPrimitiveGroups(); m_PrimitiveGroups.insert(primitiveGroupLodList.at(i), pCurrentPrimitiveGroup); const int groupCount= primitiveListOfGroupList.at(i).size(); for (int iGroup= 0; iGroup < groupCount; ++iGroup) { Q_ASSERT(materialIdMap.contains(primitiveListOfGroupList.at(i).at(iGroup).id())); const GLC_uint newId= materialIdMap.value(primitiveListOfGroupList.at(i).at(iGroup).id()); // Test if the mesh contains the material if (!containsMaterial(newId)) { addMaterial(materialHash.value(newId)); } GLC_PrimitiveGroup* pGroup= new GLC_PrimitiveGroup(primitiveListOfGroupList.at(i).at(iGroup), newId); Q_ASSERT(! m_PrimitiveGroups.value(primitiveGroupLodList.at(i))->contains(newId)); m_PrimitiveGroups.value(primitiveGroupLodList.at(i))->insert(newId, pGroup); } } stream >> m_NumberOfVertice; stream >> m_NumberOfNormals; finishSerialized(); //qDebug() << "Mesh mem size= " << memmorySize(); }
void * addTracer(zoneInfo_t* info, const char* name, char* data, int dataLen) { if (dataLen > 0) { Com_Error(false, "Can only export built in Tracers!"); return NULL; } Tracer* t = (Tracer*)data; addAsset(info, ASSET_TYPE_MATERIAL, t->material->name, addMaterial(info, t->material->name, (char*)t->material, -1)); return t; }
OBJGroup::OBJGroup( const std::string& name ) : m_name( name ), m_hasTextureCoordinates( false ), m_hasNormals( true ) { addMaterial( "" ); }
Mesh::Mesh(const DFFGeometry& geometry, bool autoSubmeshes) : vertexCount(geometry.getVertexCount()), frame(NULL) { flags = 0; const float* vertices = geometry.getVertices(); const float* normals = geometry.getNormals(); const uint8_t* colors = geometry.getVertexColors(); const float* texCoords = NULL; const uint8_t* boneIndices = geometry.getBoneIndices(); const float* boneWeights = geometry.getBoneWeights(); if (geometry.getUVSetCount() > 0) { texCoords = geometry.getUVCoordSet(0); } if (geometry.isTriangleStripFormat()) { vertexFormat = VertexFormatTriangleStrips; } else { vertexFormat = VertexFormatTriangles; } if (normals) { flags |= MeshNormals; } if (texCoords) { flags |= MeshTexCoords; } if (colors) { flags |= MeshVertexColors; } if (boneIndices) { flags |= MeshSkinData; } if (geometry.isDynamicLightingEnabled()) { flags |= MeshDynamicLighting; } DFFGeometry::ConstMaterialIterator it; for (it = geometry.getMaterialBegin() ; it != geometry.getMaterialEnd() ; it++) { Material* material = new Material(**it); addMaterial(material); } if (autoSubmeshes) { DFFGeometry::ConstPartIterator pit; for (pit = geometry.getPartBegin() ; pit != geometry.getPartEnd() ; pit++) { Submesh* submesh = new Submesh(this, **pit); } } const DFFBoundingSphere* b = geometry.getBounds(); setBounds(b->x, b->y, b->z, b->radius); init(flags, vertices, normals, texCoords, colors, boneIndices, boneWeights); }
////////////////////////////////////////////// //Interface branch void FEMesh::addInterfaceElement(InterfaceElement *ed) { edgement.push_back(ed); //Caution! Assume that normal elements (triangles and quads) get added //first before edge elements. ed->set_index(element.size()+edgement.size()-1); //std::cout << *ed << std::endl; if(ed->material()) addMaterial(ed->material()); }
void CScene::init (const string& fileName) { m_boundingSpheresMode = false; m_selectedItem = NULL; addMaterial(new CMaterial(this)); cout << "Chargement de la scène " << fileName << endl; ObjImporter::import(this,fileName,m_objectsArray); computeBoundingBox(); }
// Replace the Master material void GLC_Geometry::replaceMasterMaterial(GLC_Material* pMaterial) { Q_ASSERT(!m_IsWire); if (!m_MaterialHash.isEmpty()) { if (pMaterial != firstMaterial()) { // Remove the first material MaterialHash::iterator iMaterial= m_MaterialHash.begin(); removeMaterial(iMaterial.value()->id()); // Add the new material addMaterial(pMaterial); } } else { addMaterial(pMaterial); } }
// Replace the Master material void GLC_Mesh::replaceMasterMaterial(GLC_Material* pMat) { if (hasMaterial()) { GLC_uint oldId= firstMaterial()->id(); replaceMaterial(oldId, pMat); } else { addMaterial(pMat); } }
void ResourceManager::addMatrialKeyFrameMesh( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, int layer, const std::string& keyFramePath, unsigned materialFlags ) { addMaterial( id, resourceGroup, shader, colour, materialFlags ); addKeyFrameMesh( id, resourceGroup, layer, id, keyFramePath ); }
/* ============================================================================= routine to add a material from another already created texture =============================================================================== */ int C3DModel::addMaterial(string strName, int txID, int sizeX, int sizeY, color clr, bool bMipMap) { CMaterialPtr pMat = new CMaterial(); pMat->setTextureId(txID); pMat->setColor(clr); pMat->setHeight(sizeY); pMat->setWidth(sizeX); pMat->setName(strName); pMat->setShared(true); pMat->setMipMap(bMipMap); addMaterial(pMat); return pMat->getTextureId(); }
void ResourceManager::addTextureMatrialKeyFrameMesh( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const std::string& texturePath, int layer, const std::string& keyFramePath, unsigned textureFlags, unsigned materialFlags ) { addTexture( id, resourceGroup, texturePath, textureFlags ); addMaterial( id, resourceGroup, shader, id, materialFlags ); addKeyFrameMesh( id, resourceGroup, layer, id, keyFramePath ); }
void ResourceManager::addMaterialText( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, int layer, const std::string& font, const std::string& str, float size, unsigned materialFlags ) { addMaterial( id, resourceGroup, shader, colour, materialFlags ); addText( id, resourceGroup, layer, id, font, str, size ); }
GameComponentPtr MeshRenderComponent::clone() const noexcept { auto result = std::make_shared<MeshRenderComponent>(); result->setCastShadow(this->getCastShadow()); result->setReceiveShadow(this->getReceiveShadow()); result->setName(this->getName()); for (auto& it : this->getSharedMaterials()) { result->addMaterial(it); result->addSharedMaterial(it); } return result; }
//=================================================================== Mesh::Mesh(QObject *parent) : QObject(parent), mDebugView(false), mMode(GL_TRIANGLES), mTexture(0), mTextureImage(0), mOpacity(1) { // ctor mShaderProgram = new QOpenGLShaderProgram(this); mVertexBuffer = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); mIndexBuffer = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer); mTexture = new QOpenGLTexture(QOpenGLTexture::Target2D); resetTransform(); addMaterial(Material()); }
void ResourceManager::addMaterialGeometryMesh( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, const std::string& geometryPath, int layer, unsigned materialFlags ) { // material addMaterial( id, resourceGroup, shader, colour, materialFlags ); // geometry addGeometry( id, resourceGroup, geometryPath ); // mesh addMesh( id, resourceGroup, layer, id, id ); }
void FEMesh::refreshMaterials(PyObject *skeletoncontext) { for(ElementIterator ei=element_iterator(); !ei.end(); ++ei) { Element *element = ei.element(); const Material *oldmat = element->material(); element->refreshMaterial(skeletoncontext); const Material *newmat = element->material(); if(newmat != oldmat) { if(oldmat) removeMaterial(oldmat); if(newmat) addMaterial(newmat); } } // TODO INTERFACE: Should this just be in-line here? refreshInterfaceMaterials(skeletoncontext); }
void ResourceManager::addMaterialSprite( const std::string& id, resource_group::ResourceGroup resourceGroup, const std::string& shader, const glm::vec4& colour, int layer, const glm::vec2& size, const glm::vec2& texSize, const glm::vec2& texOffset, unsigned materialFlags ) { // material addMaterial( id, resourceGroup, shader, colour, materialFlags ); // sprite addSprite( id, resourceGroup, layer, id, size, texSize, texOffset ); }
/* ============================================================================= =============================================================================== */ int C3DModel::addMaterial(string strName, const unsigned char *pData, int sizeX, int sizeY, color clr, int iTxMode) { CMaterialPtr pMat = new CMaterial(); pMat->setTextureId(-1); pMat->setColor(clr); pMat->setHeight(0); pMat->setWidth(0); pMat->setName(strName); // If we have a file name passed in, let's copy it to our material structure GLuint txID = createTexture(pData, sizeX, sizeY, GL_RGBA, GL_RGBA, iTxMode); pMat->setTextureId(txID); pMat->setShared(false); addMaterial(pMat); return pMat->getTextureId(); }
//=================================================================== Mesh::Mesh(const Mesh &mesh) { // copy ctor mShaderProgram = new QOpenGLShaderProgram(this); mDebugView = mesh.mDebugView; mIndexBuffer = QOpenGLBuffer(mesh.mIndexBuffer); mMode = mesh.mMode; mTextureImage = mesh.mTextureImage; setTextureImage(mTextureImage); for (int index = 0; index < mesh.mVertices.count(); index++) mVertices.append(mesh.vertices().at(index)) ; addMaterial(Material()); mOpacity = mesh.mOpacity; }
// TODO INTERFACE: Called from FEMesh::refreshMaterials, but possibly // from elsewhere also. Should this function just be in-line in // refreshMaterials, or is there a good reason for it to stand alone? void FEMesh::refreshInterfaceMaterials(PyObject *skelctxt) { for(ElementIterator ei=edgement_iterator(); !ei.end(); ++ei) { Element *el = ei.element(); const Material *om = el->material(); InterfaceElement *ed = dynamic_cast<InterfaceElement*>(el); ed->refreshInterfaceMaterial(skelctxt); const Material *nm = el->material(); if (nm != om) { if (om) removeMaterial(om); if (nm) addMaterial(nm); } } }