Permalink
Browse files

Support for splines

  • Loading branch information...
1 parent f592d9c commit 8839f971bf885e37537f151c60026df0da7b1d2a @crazyjul crazyjul committed Mar 11, 2011
@@ -0,0 +1,98 @@
+/*
+ Copyright (c) 2008-2009 NetAllied Systems GmbH
+
+ This file is part of COLLADAFramework.
+
+ Licensed under the MIT Open Source License,
+ for details please see LICENSE file or the website
+ http://www.opensource.org/licenses/mit-license.php
+*/
+
+#ifndef __COLLADAFW_SPLINE_H__
+#define __COLLADAFW_SPLINE_H__
+
+#include "COLLADAFWPrerequisites.h"
+#include "COLLADAFWGeometry.h"
+#include "COLLADAFWMeshVertexData.h"
+#include "COLLADAFWMeshPrimitive.h"
+
+#include "COLLADABUUtils.h"
+
+
+namespace COLLADAFW
+{
+
+ /**
+ * Describes basic geometric meshes using vertex and primitive information.
+ * Meshes embody a general form of geometric description that primarily
+ * includes vertex and primitive information.
+ * Vertex information is the set of attributes associated with a point on
+ * the surface of the mesh. Each vertex includes data for attributes such as:
+ * • Vertex position
+ * • Vertex color
+ * • Vertex normal
+ * • Vertex texture coordinate
+ * The mesh also includes a description of how the vertices are organized to
+ * form the geometric shape of the mesh. The mesh vertices are collated into
+ * geometric primitives such as polygons, triangles, or lines.
+ */
+ class Spline : public Geometry
+ {
+ public:
+
+ enum Interpolation
+ {
+ LINEAR,
+ BEZIER
+ };
+
+ typedef ArrayPrimitiveType<Interpolation> InterpolationArray;
+
+ private:
+
+ /**
+ * The positions array. Positions can be stored as float or double values.
+ * Positions have always a stride of three (XYZ parameters). We don't need to store
+ * this information.
+ */
+ MeshVertexData mPositions;
+ MeshVertexData mInTangents;
+ MeshVertexData mOutTangents;
+ InterpolationArray mInterpolations;
+
+ public:
+
+ /** Constructor. */
+ Spline ( const UniqueId& uniqueId );
+
+ /** Destructor. */
+ virtual ~Spline ();
+
+ /**
+ * The positions array.
+ * Positions can be stored as float or double values.
+ * Positions have always a stride of three (X, Y and Z parameter). So we don't need to
+ * store this information.
+ */
+ const MeshVertexData& getPositions () const { return mPositions; }
+
+ /**
+ * The positions array.
+ * Positions can be stored as float or double values.
+ * Positions have always a stride of three (X, Y and Z parameter). So we don't need to
+ * store this information.
+ */
+ MeshVertexData& getPositions () { return mPositions; }
+
+ const MeshVertexData& getInTangents () const { return mInTangents; }
+ MeshVertexData& getInTangents () { return mInTangents; }
+
+ const MeshVertexData& getOutTangents () const { return mOutTangents; }
+ MeshVertexData& getOutTangents () { return mOutTangents; }
+
+ const InterpolationArray& getInterpolations () const { return mInterpolations; }
+ InterpolationArray& getInterpolations () { return mInterpolations; }
+ };
+}
+
+#endif // __COLLADA_MESH_H__
@@ -1042,6 +1042,10 @@
RelativePath="..\src\COLLADAFWSkinControllerData.cpp"
>
</File>
+ <File
+ RelativePath="..\src\COLLADAFWSpline.cpp"
+ >
+ </File>
<File
RelativePath="..\src\COLLADAFWTexture.cpp"
>
@@ -0,0 +1,31 @@
+/*
+ Copyright (c) 2008-2009 NetAllied Systems GmbH
+
+ This file is part of COLLADAFramework.
+
+ Licensed under the MIT Open Source License,
+ for details please see LICENSE file or the website
+ http://www.opensource.org/licenses/mit-license.php
+*/
+
+#include "COLLADAFWStableHeaders.h"
+#include "COLLADAFWSpline.h"
+#include "COLLADAFWTristrips.h"
+#include "COLLADAFWLinestrips.h"
+
+namespace COLLADAFW
+{
+
+ //----------------------------------
+ Spline::Spline( const UniqueId& uniqueId )
+ : Geometry ( uniqueId, Geometry::GEO_TYPE_SPLINE )
+ {
+
+ }
+
+ //----------------------------------
+ Spline::~Spline()
+ {
+ }
+
+} // namespace COLLADAFW
@@ -15,6 +15,7 @@
#include "COLLADASaxFWLSource.h"
#include "COLLADASaxFWLXmlTypes.h"
#include "COLLADASaxFWLMeshLoader.h"
+#include "COLLADASaxFWLSplineLoader.h"
#include "COLLADASaxFWLFilePartLoader.h"
@@ -40,6 +41,9 @@ namespace COLLADASaxFWL
/** The mesh loader used to load the mesh inside the geometry.*/
MeshLoader* mMeshLoader;
+ /** The mesh loader used to load the mesh inside the geometry.*/
+ SplineLoader* mSplineLoader;
+
public:
/** Constructor. */
@@ -66,6 +70,9 @@ namespace COLLADASaxFWL
/** Sax callback function for the beginning of a mesh.*/
virtual bool begin__mesh();
+ /** Sax callback function for the beginning of a spline.*/
+ virtual bool begin__spline(const spline__AttributeData & attributeData);
+
/** Sax callback function for the ending of a geometry.*/
virtual bool end__geometry();
@@ -127,7 +127,7 @@ namespace COLLADASaxFWL
* elements or from different input elements (NORMALS, COLOR, TEXCOORD, ...). It should be
* loaded only once from every input element.
*/
- bool addLoadedInputElement ( InputSemantic::Semantic& semantic )
+ bool addLoadedInputElement ( const InputSemantic::Semantic& semantic )
{
if ( !isLoadedInputElement ( semantic ) )
{
@@ -144,7 +144,7 @@ namespace COLLADASaxFWL
* elements or from different input elements (NORMALS, COLOR, TEXCOORD, ...). It should be
* loaded only once from every input element.
*/
- bool isLoadedInputElement ( InputSemantic::Semantic& semantic )
+ bool isLoadedInputElement ( const InputSemantic::Semantic& semantic )
{
const size_t numLoadedInputElements = mLoadedInputElements.getCount ();
for ( size_t i=0; i<numLoadedInputElements; ++i )
@@ -0,0 +1,110 @@
+/*
+ Copyright (c) 2008-2009 NetAllied Systems GmbH
+
+ This file is part of COLLADASaxFrameworkLoader.
+
+ Licensed under the MIT Open Source License,
+ for details please see LICENSE file or the website
+ http://www.opensource.org/licenses/mit-license.php
+*/
+
+#ifndef __COLLADASAXFWL_SPLINELOADER_H__
+#define __COLLADASAXFWL_SPLINELOADER_H__
+
+#include "COLLADASaxFWLPrerequisites.h"
+#include "COLLADASaxFWLVertices.h"
+#include "COLLADASaxFWLSource.h"
+#include "COLLADASaxFWLMeshPrimitiveInputList.h"
+#include "COLLADASaxFWLSourceArrayLoader.h"
+
+#include "COLLADAFWSpline.h"
+
+
+namespace COLLADASaxFWL
+{
+ class SplineLoader : public SourceArrayLoader
+ {
+ private:
+
+ typedef std::map< String /*Id of the name array*/, StringList> StringListMap;
+ private:
+
+ /** The unique id of the mesh.*/
+ COLLADAFW::UniqueId mSplineUniqueId;
+
+ /**
+ * The framework mesh element, to load the data.
+ */
+ COLLADAFW::Spline* mSpline;
+
+ StringList mInterpolations;
+
+ /**
+ * Describes the mesh-vertex attributes and establishes
+ * their topological identity.
+ */
+ Vertices mVerticesInputs;
+
+ InputUnshared * mCurrentVertexInput;
+
+ /** Flag is true, if we are currently in the vertices part. */
+ bool mInVertices;
+
+ /** Flag for the extra tag preservation, to know if we are parsing in the mesh. */
+ bool mInSpline;
+
+ bool loadPositions();
+ bool loadOutTangents();
+ bool loadInTangents();
+ bool loadInterpolations();
+
+ public:
+
+ /** Constructor. */
+ SplineLoader ( IFilePartLoader* callingFilePartLoader, const String& geometryId, const String& geometryName );
+
+ /** Destructor. */
+ virtual ~SplineLoader () { delete mSpline; }
+
+ /** Returns the unique id of the current parsed object. */
+ virtual const COLLADAFW::UniqueId& getUniqueId();
+
+ /** Returns the mesh that has just been loaded.*/
+ COLLADAFW::Spline* getSpline() { return mSpline; }
+
+ /** Sax callback function for the beginning of a source element.*/
+ virtual bool begin__source(const source__AttributeData& attributes);
+
+ /** Sax callback function for the ending of a source element.*/
+ virtual bool end__source();
+
+ /** Cleans up everything and gives control to calling file part loader.*/
+ virtual bool end__spline();
+
+ /** Flag for the extra tag preservation, to know if we are parsing in the mesh. */
+ const bool& isInSpline () const { return mInSpline; }
+ void setInSpline ( const bool& val ) { mInSpline = val; }
+
+
+ /** Sax callback function for the beginning of a input element.*/
+ virtual bool begin__input____InputLocal( const input____InputLocal__AttributeData& attributeData );
+
+ /** Sax callback function for the ending of a input element.*/
+ virtual bool end__input____InputLocal();
+
+ virtual bool begin__control_vertices();
+ virtual bool end__control_vertices();
+
+ virtual bool begin__Name_array( const Name_array__AttributeData& attributeData );
+ virtual bool end__Name_array();
+ virtual bool data__Name_array( const ParserString* data, size_t length );
+
+ bool beginInterpolationArray( bool isIdArray );
+ bool dataInterpolationArray( const ParserString* data, size_t length );
+
+ private:
+
+ };
+}
+
+#endif // __COLLADASAXFWL_MESHLOADER_H__
@@ -589,6 +589,11 @@ namespace COLLADASaxFWL
const ParserChar* sid;
const ParserChar* name;
};
+
+ struct spline__AttributeData
+ {
+ bool closed;
+ };
struct technique__AttributeData
{
const ParserChar* profile;
@@ -38,6 +38,8 @@ GeometryLoader14(GeometryLoader* loader)
virtual bool begin__mesh();
+virtual bool begin__spline( const COLLADASaxFWL14::spline__AttributeData& attributeData );
+
virtual bool end__geometry();
virtual bool begin__technique( const COLLADASaxFWL14::technique__AttributeData& attributeData );
@@ -0,0 +1,65 @@
+/*
+ Copyright (c) 2008-2009 NetAllied Systems GmbH
+
+ This file is part of COLLADASaxFrameworkLoader.
+
+ Licensed under the MIT Open Source License,
+ for details please see LICENSE file or the website
+ http://www.opensource.org/licenses/mit-license.php
+*/
+
+
+#ifndef __COLLADASAXFWL_SPLINELOADER14_H__
+#define __COLLADASAXFWL_SPLINELOADER14_H__
+
+
+#include "COLLADASaxFWLPrerequisites.h"
+#include "COLLADASaxFWLSplineLoader.h"
+#include "COLLADASaxFWLSourceArrayLoader14.h"
+
+
+namespace COLLADASaxFWL
+{
+
+
+class IFilePartLoader;
+
+
+class SplineLoader14 : public SourceArrayLoader14
+{
+private:
+SplineLoader* mLoader;
+
+public:
+SplineLoader14(SplineLoader* loader)
+ : SourceArrayLoader14(loader)
+ , mLoader(loader)
+{}
+
+
+virtual bool begin__source( const COLLADASaxFWL14::source__AttributeData& attributeData );
+
+virtual bool end__source();
+
+virtual bool end__spline();
+
+virtual bool begin__input____InputLocal( const COLLADASaxFWL14::input____InputLocal__AttributeData& attributeData );
+
+virtual bool end__input____InputLocal();
+
+virtual bool begin__control_vertices();
+virtual bool end__control_vertices();
+
+
+virtual bool begin__Name_array( const COLLADASaxFWL14::Name_array__AttributeData& attributeData );
+virtual bool end__Name_array();
+virtual bool data__Name_array( const ParserString* data, size_t length );
+
+private:
+/** Disable default copy ctor. */
+SplineLoader14(const SplineLoader14&);
+/** Disable default assignment operator. */
+const SplineLoader14& operator=(const SplineLoader14&);
+};
+}
+#endif // __COLLADASAXFWL_MESHLOADER14_H__
Oops, something went wrong.

0 comments on commit 8839f97

Please sign in to comment.