source: NonGTP/FCollada/FCDocument/FCDGeometry.h @ 964

Revision 964, 5.3 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*
2        Copyright (C) 2005-2006 Feeling Software Inc.
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5
6/**
7        @file FCDGeometry.h
8        This file contains the FCDGeometry class.
9        The FCDGeometry class holds the information for one mesh or spline
10        entity, within the COLLADA geometry library.
11*/
12#ifndef _FCD_GEOMETRY_H_
13#define _FCD_GEOMETRY_H_
14
15#include "FCDocument/FCDEntity.h"
16#include "FUtils/FUDaeEnum.h"
17
18class FCDocument;
19class FCDGeometryMesh;
20class FCDGeometrySpline;
21
22/**
23        @defgroup FCDGeometry COLLADA Document Geometry Entity
24        @addtogroup FCDocument
25*/
26
27/**
28        A COLLADA geometry entity.
29        There are two types of COLLADA geometry entities: meshes and splines.
30
31        Meshes are collections of polygons where the vertices always have a position,
32        usually have a normal to define smooth or hard edges and may be colored or textured.
33
34        Splines are a sequence of control points used to generate a smooth curve.
35
36        @ingroup FCDGeometry
37*/
38
39class FCOLLADA_EXPORT FCDGeometry : public FCDEntity
40{
41private:
42        DeclareObjectType;
43
44        // Contains only one of the following, in order of importance.
45        FCDGeometryMesh* mesh;
46        FCDGeometrySpline* spline;
47
48public:
49        /** Contructor: do not use directly. Create new geometries using the FCDocument::AddGeometry function,
50                or the FCDLibrary::AddEntity function.
51                @param document The COLLADA document which owns the new geometry entity. */
52        FCDGeometry(FCDocument* document);
53
54        /** Destructor: only release cloned geometries directly.
55                Release original geometries using the FCDLibrary::ReleaseEntity function.
56                All original geometries are released with the document that they belong to. */
57        virtual ~FCDGeometry();
58
59        /** Retrieves the entity class type.
60                This function is a part of the FCDEntity interface.
61                @return The entity class type: GEOMETRY. */
62        virtual Type GetType() const { return GEOMETRY; }
63
64        /** Retrieves whether the type of this geometry is a mesh.
65                @return Whether this geometry is a mesh. */
66        bool IsMesh() const { return mesh != NULL; }
67
68        /** Retrieves the mesh information structure for this geometry.
69                Verify that this geometry is a mesh using the IsMesh function prior to calling this function.
70                @return The mesh information structure. This pointer will be NULL when the geometry is a spline or is undefined. */
71        FCDGeometryMesh* GetMesh() { return mesh; }
72        const FCDGeometryMesh* GetMesh() const { return mesh; } /**< See above. */
73
74        /** Sets the type of this geometry to mesh and creates an empty mesh structure.
75                This function will release any mesh or spline structure that the geometry may already contain
76                @return The mesh information structure. This pointer will always be valid. */
77        FCDGeometryMesh* CreateMesh();
78
79        /** Retrieves whether the type of this geometry is a spline.
80                @return Whether this geometry is a spline. */
81        bool IsSpline() const { return spline != NULL; }
82
83        /** Retrieves the spline information structure for this geometry.
84                Verify that this geometry is a spline using the IsSpline function prior to calling this function.
85                @return The spline information structure. This pointer will be NULL when the geometry is a mesh or is undefined. */
86        FCDGeometrySpline* GetSpline() { return spline; }
87        const FCDGeometrySpline* GetSpline() const { return spline; } /**< See above. */
88
89        /** Sets the type of this geometry to spline and creates an empty spline structure.
90                This function will release any mesh or spline structure that the geometry may already contain.
91                @return The spline information structure. This pointer will always be valid. */
92        FCDGeometrySpline* CreateSpline();
93
94        /** @deprecated [INTERNAL] Clones the geometry entity.
95                Works only on mesh geometry. Creates a full copy of the geometry, with the vertices overwritten
96                by the given data: this is used when importing COLLADA 1.3 skin controllers.
97                You will need to release the cloned entity.
98                @param newPositions The list of vertex position that will
99                        overwrite the current mesh vertex positions. This list may be empty.
100                @param newPositionsStride The stride, in bytes, of the newPositions list.
101                        For an empty newPositions list, this value is discarded.
102                @param newNormals The list of vertex normals that will overwrite
103                        the current mesh vertex normals. This list may be empty.
104                @param newNormalsStride The stride, in bytes, of the newNormals list.
105                        For an empty newNormals list, this value is discarded.
106                @return The cloned geometry entity. This pointer will be NULL,
107                        if the geometry is not a mesh. You will need to release this pointer. */
108        FCDGeometry* Clone(FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride);
109
110        /** [INTERNAL] Reads in the \<geometry\> element from a given COLLADA XML tree node.
111                @param node The COLLADA XML tree node.
112                @return The status of the import. If the status is not successful,
113                        it may be dangerous to extract information from the geometry.*/
114        virtual FUStatus LoadFromXML(xmlNode* node);
115
116        /** [INTERNAL] Writes out the \<geometry\> element to the given COLLADA XML tree node.
117                @param parentNode The COLLADA XML parent node in which to insert the geometry information.
118                @return The created \<geometry\> element XML tree node. */
119        virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
120};
121
122#endif // _FCD_GEOMETRY_H_
Note: See TracBrowser for help on using the repository browser.