20 #include <boost/lexical_cast.hpp> 21 #include <boost/tokenizer.hpp> 30 typedef boost::tokenizer<boost::char_separator<char> >
tokenizer;
55 std::ifstream xmlFile (_fileName.c_str() );
56 if(!xmlFile.is_open())
58 std::cerr<<
"Could not open file\n";
61 std::vector<char>
buffer((std::istreambuf_iterator<char>(xmlFile)), std::istreambuf_iterator<char>());
62 buffer.push_back(
'\0');
69 std::cerr<<
"this is not a pointbake file \n";
80 std::cerr<<
"NumVerts "<<
m_nVerts<<
"\n";
91 m_data.resize(m_numFrames);
97 data.resize(m_nVerts);
99 unsigned int CurrentFrame=0;
104 boost::char_separator<char> sep(
" \t\r\n");
108 std::cerr<<
"doing frame "<<child->
first_attribute(
"number")->value()<<
"\n";
109 CurrentFrame=boost::lexical_cast<
unsigned int>(child->
first_attribute(
"number")->value());
111 std::flush(std::cerr);
115 unsigned int index=boost::lexical_cast<
unsigned int>(vertex->first_attribute(
"number")->value());
116 lineBuffer=vertex->value();
117 tokenizer tokens(lineBuffer, sep);
118 tokenizer::iterator firstWord = tokens.begin();
119 Real x=boost::lexical_cast<
Real>(*firstWord++);
120 Real y=boost::lexical_cast<
Real>(*firstWord++);
121 Real z=boost::lexical_cast<
Real>(*firstWord++);
122 m_data[CurrentFrame][
index].set(x,y,z);
157 std::cerr<<
"problems Opening File "<<_fileName<<std::endl;
162 file.read(header,10*
sizeof(
char));
166 if(strcmp(header,
"ngl::binpb"))
170 std::cout<<
"this is not an ngl::binpb file "<<std::endl;
177 file.read(reinterpret_cast <char *>(&
m_numFrames),
sizeof(
unsigned int));
178 file.read(reinterpret_cast <char *>(&
m_currFrame),
sizeof(
unsigned int));
179 file.read(reinterpret_cast <char *>(&
m_nVerts),
sizeof(
unsigned int));
180 file.read(reinterpret_cast <char *>(&
m_startFrame),
sizeof(
unsigned int));
181 file.read(reinterpret_cast <char *>(&
m_binFile),
sizeof(
bool));
182 std::cout <<
"Loaded header\n";
189 m_data.resize(m_numFrames);
190 for(
unsigned int frame =0; frame<
m_numFrames; ++frame)
192 m_data[frame].resize(m_nVerts);
195 file.read( reinterpret_cast <char *>(&
m_data[frame][
v].m_x),
sizeof(
Real));
196 file.read( reinterpret_cast <char *>(&
m_data[frame][
v].m_y),
sizeof(
Real));
197 file.read( reinterpret_cast <char *>(&
m_data[frame][
v].m_z),
sizeof(
Real));
212 std::cerr<<
"problems Opening File "<<_fileName<<std::endl;
218 file.write(header.c_str(),
static_cast<long>(header.length()));
220 file.write(reinterpret_cast <char *>(&
m_numFrames),
sizeof(
unsigned int));
221 file.write(reinterpret_cast <char *>(&
m_currFrame),
sizeof(
unsigned int));
222 file.write(reinterpret_cast <char *>(&
m_nVerts),
sizeof(
unsigned int));
223 file.write(reinterpret_cast <char *>(&
m_startFrame),
sizeof(
unsigned int));
224 file.write(reinterpret_cast <char *>(&
m_binFile),
sizeof(
bool));
232 for(
unsigned int frame =0; frame<
m_numFrames; ++frame)
236 file.write( reinterpret_cast <char *>(&
m_data[frame][
v].m_x),
sizeof(
Real));
237 file.write( reinterpret_cast <char *>(&
m_data[frame][
v].m_y),
sizeof(
Real));
238 file.write( reinterpret_cast <char *>(&
m_data[frame][
v].m_z),
sizeof(
Real));
254 for(
auto face : faces)
262 for(
unsigned int j=0;j<3;++j)
264 ptr[step+5]=
m_data[_frame][
face.m_vert[j]].m_x;
265 ptr[step+6]=
m_data[_frame][
face.m_vert[j]].m_y;
266 ptr[step+7]=
m_data[_frame][
face.m_vert[j]].m_z;
283 std::cout<<
"doing attach mesh\n";
286 std::cerr <<
" Mesh can't be attached to this data as vert count does not match\n";
287 std::cerr<<
"mesh verts "<<_mesh->m_nVerts<<
" file verts "<<
m_nVerts<<
"\n";
This file contains rapidxml parser and DOM implementation.
bool loadBinaryPointBake(const std::string &_fileName) noexcept
method to load a binary point baked file
void setFrame(const unsigned int frame) noexcept
Set the current Frame and map the clip for that frame to the obj.
unsigned int m_startFrame
the start frame
std::vector< std::vector< Vec3 > > m_data
The actual data of the clip stored per vertex in sequence v0 - vn and then per frame frame index is a...
bool attachMesh(AbstractMesh *_mesh) noexcept
method to attach a mesh to the data this method will check for basic vetex compatibility and then re-...
GLint GLint GLint GLint GLint GLint y
unsigned int m_nVerts
Number of verts in the actual clip.
bool m_binFile
flag to indicate if we have a binary or xml based file loaded
GLint GLenum GLsizei GLint GLsizei const void * data
bool saveBinaryPointBake(const std::string &_fileName) noexcept
method to save a binary point baked file basically re-ordered data only
implementation files for RibExport class
boost::tokenizer< boost::char_separator< char > > tokenizer
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
~NCCAPointBake() noexcept
the dtor erases all clip data allocated and also destroys the Obj reference held in the clip ...
simple point baked animation data for animation data export
an abstract base mesh used to build specific meshes such as Obj
const GLuint GLenum const void * binary
bool loadPointBake(const std::string &_fileName) noexcept
method to load a point baked file
unsigned int m_numFrames
the number of frames in the clip file
std::string m_meshName
the name of the mesh
AbstractMesh * m_mesh
pointer to mesh attatched to data
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
const int parse_trim_whitespace
Real * mapVAOVerts() noexcept
map the VBO vertex data
std::vector< Face > getFaceList() noexcept
accessor for the Face data
xml_node< Ch > * next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
std::vector< Vec3 > & getRawDataPointerAtFrame(unsigned int _f) noexcept
get a Raw data pointer to the un-sorted PointBake for a particular frame
GLint GLint GLint GLint GLint x
#define NGL_ASSERT(X)
re-define the standard assert to work for ngl first check to see if assert is defined and undef it th...
void unMapVAO() noexcept
unmap the VBO based
void setMeshToFrame(const unsigned int _frame) noexcept
set the attached mesh to the current frame
NCCAPointBake() noexcept
ctor for the clip
unsigned int m_currFrame
Current active frame when animating.
unsigned int m_endFrame
the end frame
GLsizei const GLchar *const * string
GLenum GLuint GLint GLenum face