1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4 	This file is part of COLLADAStreamWriter.
5 
6     Licensed under the MIT Open Source License,
7     for details please see LICENSE file or the website
8     http://www.opensource.org/licenses/mit-license.php
9 */
10 
11 #ifndef __COLLADASTREAMWRITER_LIBRARY_GEOMETRY_H__
12 #define __COLLADASTREAMWRITER_LIBRARY_GEOMETRY_H__
13 
14 #include "COLLADASWPrerequisites.h"
15 #include "COLLADASWLibrary.h"
16 #include "COLLADASWInputList.h"
17 
18 namespace COLLADASW
19 {
20 
21     /** Class to simply the creation of @a \<library_geometries\> and @a \<geometry\>'s*/
22 
23     class LibraryGeometries : public Library
24     {
25 
26     public:
27 
28         static const String GEOMETRY_ID_PRAEFIX ;
29 		static const String POSITIONS_SOURCE_ID_SUFFIX;
30 		static const String INTANGENT_SOURCE_ID_SUFFIX;
31 		static const String OUTTANGENT_SOURCE_ID_SUFFIX;
32 		static const String INTERPOLATION_SOURCE_ID_SUFFIX;
33         static const String NORMALS_SOURCE_ID_SUFFIX;
34 		static const String TEXCOORDS_SOURCE_ID_SUFFIX;
35         static const String COLORS_SOURCE_ID_SUFFIX;
36 		static const String TEXTANGENT_SOURCE_ID_SUFFIX;
37 		static const String TEXBINORMAL_SOURCE_ID_SUFFIX;
38         static const String ARRAY_ID_SUFFIX;
39         static const String VERTICES_ID_SUFFIX;
40         static const String TANGENT_ID_SUFFIX;
41         static const String BINORMAL_ID_SUFFIX;
42 
43     private:
44 
45         TagCloser mCurrentGeometryCloser;  //!< Used to close the current geometry
46         TagCloser mCurrentMeshOrSplineCloser;   //!< Used to close the current mesh
47 		TagCloser mCurrentConvexMeshCloser;   //!< Used to close the current mesh
48         TagCloser mCurrentExtraCloser;   //!< Used to close the current extra
49 
50     public:
51         /** Constructor
52         @param streamWriter The stream the @a \<library_geometries\> and @a \<geometry\>'s
53         should be written to.
54         */
55         LibraryGeometries ( StreamWriter* streamWriter );
56 
~LibraryGeometries()57         virtual ~LibraryGeometries() {}
58 
59     protected:
60         /** Writes the opening @a \<geometry\> and @a \<mesh\> tags and, if necessary the opening @a \<library_geometry\> tag.
61         closeMesh() must be use to close the opened tags.
62         @param geoId The id of the geometry
63         @param geoName The Name of the geometry*/
64         void openMesh ( const String& geoId, const String& geoName = EMPTY_STRING );
65 		void openConvexMesh(const String &convexHullOf, const String& geoId, const String& geoName = EMPTY_STRING);
66 
67 		/** Writes the opening @a \<geometry\> and @a \<spline\> tags and, if necessary the opening @a \<library_geometry\> tag.
68 		closeMesh() must be use to close the opened tags.
69 		@param closed Indicates if the spline si closed or open
70 		@param geoName The Name of the geometry*/
71 		void openSpline ( bool closed, const String & geoId, const String & geoName );
72 
73 		/** Closes the tag opened by openMesh()*/
74 		void closeMesh();
75 		void closeConvexMesh();
76 
77 		/** Closes the tag opened by openSpline()*/
78 		void closeSpline();
79 
80         /** Writes the opening @a \<mesh\> tag and, if necessary the opening @a \<library_geometry\> tag.
81         closeGeometry() must be use to close the opened tags.
82         @param id The id of the geometry.
83         @param name The name of the geometry.*/
84         void openGeometry ( const String& id, const String& name = EMPTY_STRING );
85 
86         /** Closes the tag open by openGeometry()*/
87         void closeGeometry();
88 
89         /** Returns the suffix string of the given type semantic. */
90         static String getSuffixBySemantic ( InputSemantic::Semantics type );
91     };
92 
93 } //namespace COLLADASW
94 
95 #endif //__COLLADASTREAMWRITER_LIBRARY_GEOMETRY_H__
96