Commit b46dd5d1 authored by Jan Möbius's avatar Jan Möbius

Combined support for single and multitexture modes

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5720 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4b52d635
This diff is collapsed.
......@@ -129,8 +129,7 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
// LoadSaveInterface
void fileOpened( int _id );
// TODO: Empty object added has to create textures as well!
void addedEmptyObject( int _id );
private slots:
......@@ -155,6 +154,12 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
bool StringToBool(QString _value);
/// Load an Image from disk ( if filename contains leading "/ " its consedered global otherwise in texturedir)
void getImage( QString& _fileName, QImage& _image );
/// Checks for a correct drawmode and changes if necessary
void switchDrawMode( bool _multiTexture );
QAction* AC_Texture_Settings;
TextureData globalTextures_;
......
......@@ -33,8 +33,12 @@
//-----------------------------------------------------------------------------------
TextureData::TextureData(){
nextInternalID_ = 0;
TextureData::TextureData() :
nextInternalID_(0)
{
// map 0 to no texture
textureMap_[0] = 0;
propertyMap_[0] = "No Texture";;
}
//-----------------------------------------------------------------------------------
......@@ -151,10 +155,36 @@ int TextureData::addTexture ( Texture _texture, GLuint _glName ) {
textureMap_[ _texture.id ] = _texture.glName;
propertyMap_[ _texture.id ] = _texture.name.toStdString();
std::cerr << "Added texture " << _texture.name.toStdString() << std::endl;
return _texture.id;
}
bool TextureData::addMultiTexture( QString _textureName ) {
int textureid = -1;
textureid = getTextureIndex(_textureName);
if ( textureid != -1) {
std::cerr << "Texture exists!" << std::endl;
return false;
}
std::cerr << "TextureData::addMultiTexture" << std::endl;
//generate texture object
Texture tex;
tex.id = nextInternalID_++;
tex.name = _textureName;
tex.glName = 0;
tex.filename = "MultiTexture";
tex.dimension = 0;
tex.enabled = false;
tex.dirty = false;
tex.type = MULTITEXTURE;
textures_.push_back( tex );
return true;
}
/// Stores the given image in the texture information
bool TextureData::setImage( QString _textureName , QImage& _image ) {
int textureid = -1;
......
......@@ -35,6 +35,7 @@
#include <OpenFlipper/common/perObjectData.hh>
#include <QString>
#include <QStringList>
#include <QImage>
#include <ACG/GL/gl.hh>
#include <vector>
......@@ -42,7 +43,7 @@
#include <float.h>
#include <iostream>
enum TextureType { VERTEXBASED = 1 << 0, HALFEDGEBASED = 1 << 1};
enum TextureType { VERTEXBASED = 1 << 0, HALFEDGEBASED = 1 << 1, MULTITEXTURE = 1 << 2};
class TexParameters
{
......@@ -55,7 +56,7 @@ class TexParameters
repeat ( false ),
center ( false ),
abs ( false ),
max_val ( 1.0 ) {std::cerr << "Constructor for parameters" << std::endl;};
max_val ( 1.0 ) {};
bool scale;
......@@ -93,6 +94,10 @@ struct Texture {
TexParameters parameters;
QImage textureImage;
/// If this is a multiTexture, the list will contain all textures for this multi Texture node.
QStringList multiTextureList;
};
class TextureData : public PerObjectData
......@@ -126,6 +131,9 @@ class TextureData : public PerObjectData
/// Add a Texture ( Based on an existing specification )
int addTexture ( Texture _texture, GLuint _glName );
/// Adds a new multiTexture ( This texture will only contain a list of enabled textures for multitexturing )
bool addMultiTexture( QString _textureName );
/// Stores the given image in the texture information
bool setImage( QString _textureName , QImage& _image );
......@@ -147,27 +155,32 @@ class TextureData : public PerObjectData
std::vector< Texture >& textures();
/// Get reference to the textureMap
/** This map maps all available textures for the object which this
* class belongs to to their GLuint. The MeshNode will use this
* map to activate one texture for each face.
*
*/
std::map< int, GLuint >* textureMap();
/// Get reference to the propertyMap
/** This map is used to store the available Textures and map them to their
* corresponding properties.
*/
std::map< int, std::string >* propertyMap();
private :
std::map< int, GLuint> textureMap_;
std::map< int, std::string> propertyMap_;
// internal id for the next texture
/// internal id for the next texture
int nextInternalID_;
//vector containing all textures of an object
/// vector containing all textures of an object
std::vector< Texture > textures_;
// Get the index of a given texture
/// Get the index of a given texture
int getTextureIndex(QString _textureName);
Texture noTexture;
......
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