70 file->
read( header,80 );
75 verts->
resize(tri_count*3);
76 normals->
resize(tri_count*3);
92 tris.resize( tri_count * 50 );
93 file->
read( &tris[0], tri_count * 50 );
96 for(
unsigned int i=0; i<tri_count; ++i)
98 STriangle& tri = *((STriangle*)&tris[ i * 50 ]);
100 normals->
at(i*3+0) = tri.n;
101 normals->
at(i*3+1) = tri.n;
102 normals->
at(i*3+2) = tri.n;
103 verts->
at(i*3+0) = tri.v0;
104 verts->
at(i*3+1) = tri.v1;
105 verts->
at(i*3+2) = tri.v2;
125 std::vector<fvec3> verts;
126 std::vector<fvec3> norms;
133 sscanf(str.c_str(),
"%s %s %f %f %f", parola1, parola2, &n.
x(), &n.
y(), &n.
z());
136 line_reader.
readLine(str); sscanf(str.c_str(),
"%s %f %f %f", parola1, &v[0].
x(), &v[0].
y(), &v[0].
z());
137 line_reader.
readLine(str); sscanf(str.c_str(),
"%s %f %f %f", parola1, &v[1].
x(), &v[1].
y(), &v[1].
z());
138 line_reader.
readLine(str); sscanf(str.c_str(),
"%s %f %f %f", parola1, &v[2].
x(), &v[2].
y(), &v[2].
z());
147 verts.push_back(v[0]);
148 verts.push_back(v[1]);
149 verts.push_back(v[2]);
154 vertices->
resize(verts.size());
155 normals->
resize(verts.size());
156 memcpy(normals ->ptr(), &norms[0],
sizeof(norms[0])*norms.size());
157 memcpy(vertices->
ptr(), &verts[0],
sizeof(verts[0])*verts.size());
161 geom->setVertexArray(vertices.
get());
162 geom->setNormalArray(normals.
get());
176 char header[] = {1,2,3,4,5,0};
178 file->
read(header,5);
180 if ( strcmp( (
char*)header,
"solid" ) == 0 )
VLGRAPHICS_EXPORT ref< ResourceDatabase > loadSTL(VirtualFile *file)
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
Associates a Renderable object to an Effect and Transform.
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
An abstract class representing a file.
bool readLine(std::string &utf8)
A simple String formatting class.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
const T_Scalar & z() const
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
void setVertexArray(ArrayAbstract *data)
Conventional vertex array.
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
void setNormalArray(ArrayAbstract *data)
Conventional normal array.
ref< ResourceDatabase > loadBinary(VirtualFile *file)
ref< ResourceDatabase > loadAscii(VirtualFile *file)
void setInputFile(VirtualFile *file)
virtual void close()=0
Closes the file.
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Visualization Library main namespace.
const unsigned char * ptr() const
Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() ...
The TextStream class can be used to conveniently read or parse utf8-encoded text files.
const std::vector< ref< Object > > & resources() const
const T_Scalar & y() const
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
bool seekSet(long long offset)
Changes the current read/write position of a file.
Defines the sequence of Shader objects used to render an Actor.
T_VectorType & at(size_t i)
const T_Scalar & x() const
unsigned int readUInt32(bool little_endian_data=true)
Reads single entry.
The ref<> class is used to reference-count an Object.
ref< ResourceDatabase > loadSTL(VirtualFile *file)
Loads a STL file.
Wraps the OpenGL function glDrawArrays().
unsigned short u16
16 bits unsigned integer
The ResourceDatabase class contains and manipulates a set of resources.
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.