Commit c0822cdb authored by Robert Menzel's avatar Robert Menzel
Browse files

untested ATB loading

parent c72474f0
......@@ -34,8 +34,8 @@ private:
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
DataControlFile(const std::string& _filename)
: Resource::FileController<DATA_FILE_TYPE>(_filename, Base::Settings::the()->getFullTexturePath())
DataControlFile(const std::string& _filename, const std::string& _resourcePath)
: Resource::FileController<DATA_FILE_TYPE>(_filename, _resourcePath)
{}
virtual ~DataControlFile(void) {}
......@@ -61,12 +61,12 @@ public:
return SharedDATA_FILE_TYPE();
}
virtual bool update(SharedDATA_FILE_TYPE& _texture)
virtual bool update(SharedDATA_FILE_TYPE& _data)
{
if (Resource::FileController<DATA_FILE_TYPE>::fileIsUpToDate())
return false;
if(!load(_texture))
if(!load(_data))
return false;
Resource::FileController<DATA_FILE_TYPE>::updateFileModificationTime();
......
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, 2012 Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEATB_HH
#define ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEATB_HH
/**
* A minimal obj loader.
*/
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Controller/DataControlFile.hh>
#include <ACGL/OpenGL/InitStaticFileTypes.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
namespace ACGL{
namespace OpenGL{
class GeometryDataControlFileOBJ;
class GeometryDataControlFileATB : public ACGL::OpenGL::GeometryDataControlFile
{
friend void initStaticFileTypes(void);
public:
GeometryDataControlFileATB(const std::string& _filename)
: GeometryDataControlFile(_filename,Base::Settings::the()->getFullGeometryPath()),
mOBJLoader(_filename)
{}
virtual ~GeometryDataControlFileATB(void) {}
// the entry point that gets registered in registerType()
static SharedGeometryDataControlFile creator(const std::string& _filename) { return SharedGeometryDataControlFile(new GeometryDataControlFileATB(_filename)); }
private:
virtual bool load(SharedGeometryData& geometry) const;
private:
// register the file extension 'obj' for this loader
static ACGL::int_t registerType(void)
{
sTypeID = GeometryDataControlFileFactory::the()->registerType("atb", &GeometryDataControlFileATB::creator);
return sTypeID;
}
GeometryDataControlFileOBJ mOBJLoader;
};
ACGL_SMARTPOINTER_TYPEDEFS(GeometryDataControlFileATB)
} // OpenGL
} // ACGL
#endif // ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEATB_HH
......@@ -19,11 +19,14 @@
namespace ACGL{
namespace OpenGL{
class GeometryDataControlFileATB;
class GeometryDataControlFileOBJ : public ACGL::OpenGL::GeometryDataControlFile
{
friend void initStaticFileTypes(void);
friend class GeometryDataControlFileATB;
public:
GeometryDataControlFileOBJ(const std::string& _filename) : GeometryDataControlFile(_filename) {}
GeometryDataControlFileOBJ(const std::string& _filename) : GeometryDataControlFile(_filename,Base::Settings::the()->getFullGeometryPath()) {}
virtual ~GeometryDataControlFileOBJ(void) {}
// the entry point that gets registered in registerType()
......
......@@ -23,7 +23,7 @@ class TextureDataControlFileJPG : public TextureDataControlFile
// ========================================================================================================= \/
public:
TextureDataControlFileJPG(const std::string& _filename)
: TextureDataControlFile(_filename)
: TextureDataControlFile(_filename,Base::Settings::the()->getFullTexturePath())
{}
virtual ~TextureDataControlFileJPG(void) {}
......
......@@ -23,7 +23,7 @@ class TextureDataControlFilePNG : public TextureDataControlFile
// ========================================================================================================= \/
public:
TextureDataControlFilePNG(const std::string& _filename)
: TextureDataControlFile(_filename)
: TextureDataControlFile(_filename,Base::Settings::the()->getFullTexturePath())
{}
virtual ~TextureDataControlFilePNG(void) {}
......
......@@ -28,7 +28,7 @@ class TextureDataControlFilePPM : public TextureDataControlFile
// ========================================================================================================= \/
public:
TextureDataControlFilePPM(const std::string& _filename)
: TextureDataControlFile(_filename)
: TextureDataControlFile(_filename,Base::Settings::the()->getFullTexturePath())
{}
virtual ~TextureDataControlFilePPM(void) {}
......
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, 2012 Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#include <ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.hh>
#include <ACGL/OpenGL/Controller/GeometryDataControlFileATB.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
#include <sstream>
using namespace ACGL;
using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
using namespace ACGL::Base;
bool GeometryDataControlFileATB::load(SharedGeometryData& geometry) const
{
bool ok = mOBJLoader.load( geometry );
if (ok) {
if ( geometry->mAttributes.size() == 1 ) geometry->mAttributes[0].name = mFilename;
for (unsigned int i = 0; i < geometry->mAttributes.size(); ++i) {
std::stringstream sstream (std::stringstream::in | std::stringstream::out);
sstream << i;
geometry->mAttributes[i].name = mFilename+sstream.str();
}
}
return ok;
}
......@@ -11,6 +11,7 @@
#include <vector>
#include <iostream>
#include <fstream>
#include <cstring>
using namespace ACGL;
using namespace ACGL::OpenGL;
......@@ -267,9 +268,8 @@ bool GeometryDataControlFileOBJ::load(SharedGeometryData& geometry) const
geometry->setSize( index * components * sizeof(float) );
float *data = new float[ index * components ];
for (unsigned int i = 0; i < index * components; ++i) {
data[i] = interleavedDataVector[i];
}
std::memcpy( data, &interleavedDataVector[0], index * components * sizeof(float) );
geometry->setData( (GLubyte*)data );
geometry->setStrideSize( components*sizeof(float) );
......
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