Commit d619e70b authored by Jan Möbius's avatar Jan Möbius
Browse files

Basic per face texture mapping

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4550 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 151b127f
......@@ -183,7 +183,7 @@
mesh_->request_vertex_texcoords2D();
mesh_->request_halfedge_texcoords2D();
if ( manipulatorNode() == NULL)
if ( manipulatorNode() == NULL)
std::cerr << "Error when creating Mesh Object! manipulatorNode is NULL!" << std::endl;
statusNode_ = new ACG::SceneGraph::SelectionNodeT<MeshT>(*mesh_,manipulatorNode(),"NEW StatusNode for mesh " );
......@@ -447,14 +447,29 @@
meshNode_->boundingBox(_bbMin,_bbMax);
}
/** Add a texture to the object.
* @param _property Name of the mesh property handle containing the texture.
* @param _textureFile Name of the texturefile used (has to be in the Textures dir of OpenFlipper)
*/
template < class MeshT , DataType objectDataType >
void MeshObject< MeshT , objectDataType >::addTexture(QString _property, QString _textureFile )
void MeshObject< MeshT , objectDataType >::addTexture(QImage& _image , int _id )
{
textures.push_back( std::pair<QString,QString>(_property,_textureFile) );
if ( textures_.empty() ) {
std::cerr << "No texture set." << std::endl;
}
if ( _id >= textures_.size() ) {
std::cerr << "Expanded texture index vector." << std::endl;
textures_.resize(_id + 1,0);
}
std::cerr << "Add texture" << std::endl;
textures_[_id] = textureNode_->add_texture(_image);
meshNode_->set_texture_map(&textures_);
if ( textures_.size() > 1 && !mesh_.has_face_texture_index() ) {
std::cerr << " More than one textures available but no faceindex set. Only first texture will be used." << std::endl;
}
}
......
......@@ -273,15 +273,18 @@ class DLLEXPORT MeshObject : public BaseObjectData {
//===========================================================================
public :
void addTexture(QString _property, QString _textureFile );
/** This vector is used to store the available Textures, which will be handled
* by the texture control plugin. For meshes the first String identifies the mesh
* property used for the texture coordinates. The second String identifies the
* texture file. Use addTexture() to add additional textures. If the property does not exist,
* nothing happens if you select it.
/** Add a texture to the object.
* @param _image Image to use as texture
* @param _id Id of the texture in the texture_index property of the mesh
*/
void addTexture( QImage& _image , int _id );
/** This vector is used to store the available Textures. Each call to addTexture will load
* the texture in the textureNode. The MeshNode will use only the first texture unless
* the mesh has requested a face_index_texture with request_face_texture_index. Additionally
* request_halfedge_texcoords2D has to be used to set per face texture coordinates.
*/
std::vector< std::pair < QString , QString > > textures;
std::vector< GLuint > textures_;
/** @} */
//===========================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment