Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
c0822cdb
Commit
c0822cdb
authored
Feb 13, 2012
by
Robert Menzel
Browse files
untested ATB loading
parent
c72474f0
Changes
8
Hide whitespace changes
Inline
Side-by-side
include/ACGL/OpenGL/Controller/DataControlFile.hh
View file @
c0822cdb
...
...
@@ -34,8 +34,8 @@ private:
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
DataControlFile
(
const
std
::
string
&
_filename
)
:
Resource
::
FileController
<
DATA_FILE_TYPE
>
(
_filename
,
Base
::
Settings
::
the
()
->
getFullText
urePath
()
)
DataControlFile
(
const
std
::
string
&
_filename
,
const
std
::
string
&
_resourcePath
)
:
Resource
::
FileController
<
DATA_FILE_TYPE
>
(
_filename
,
_reso
ur
c
ePath
)
{}
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
();
...
...
include/ACGL/OpenGL/Controller/GeometryDataControlFileATB.hh
View file @
c0822cdb
////////////////////////////////////////////////////////////////////////////////
// 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
include/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.hh
View file @
c0822cdb
...
...
@@ -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()
...
...
include/ACGL/OpenGL/Controller/TextureDataControlFileJPG.hh
View file @
c0822cdb
...
...
@@ -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
)
{}
...
...
include/ACGL/OpenGL/Controller/TextureDataControlFilePNG.hh
View file @
c0822cdb
...
...
@@ -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
)
{}
...
...
include/ACGL/OpenGL/Controller/TextureDataControlFilePPM.hh
View file @
c0822cdb
...
...
@@ -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
)
{}
...
...
src/ACGL/OpenGL/Controller/GeometryDataControlFileATB.cc
View file @
c0822cdb
////////////////////////////////////////////////////////////////////////////////
// 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
;
}
src/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.cc
View file @
c0822cdb
...
...
@@ -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
)
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment