
#ifndef __WFX_SCENE_TRIMESH_H__
#define __WFX_SCENE_TRIMESH_H__

#include <WFX/WFXIncludes.h>

#include <WFX/scene/Node.h>

namespace WFX {

    namespace renderer {
        class Renderer;
    }
    
    namespace scene {

        /**
         * a basic triangle mesh
         * vertices are stored in GeometryNode.vertices
         * additionaly this class stores an array of
         * UInts and a triangle count 
         * 
         */
        class TriMesh : public GeometryNode {
            public:
                /** describes how to interpret Connectivity and Normals/Texture coordinates */
                enum MeshMode {
                    MM_Triangles,   // one normal/texcoord per vertex
                    MM_TriStrip,    //  "   "       "       "   "
                    MM_TriFan       //  "   "       "       "   "
                };
                /**
                 * Ctor/Dtor
                 */
                TriMesh();
                virtual ~TriMesh();

                /** returns triangle count */
                inline UInt getFaceCount() {
                    return FaceCount;
                }

                /** returns connectivity */
                inline UInt* getConnectivity() {
                    return Connectivity;
                }

                /** returns mode */
                inline MeshMode getMeshMode() {
                    return Mode;
                }

                /** sets triangle count */
                inline void setFaceCount(UInt fc) {
                    FaceCount = fc;
                }

                /** sets connectivity */
                inline void setConnectivity(UInt* c) {
                    Connectivity = c;
                }

                /** sets mode */
                inline void getMeshMode(MeshMode m) {
                    Mode = m;
                }

                /**
                 * implement render functionality
                 */
                void draw(WFX::renderer::Renderer* r);

                /** implement vertex normal calculations */
                void calcNormals();

                /** accept a SceneGraphVisitor */
                void accept(SceneGraphVisitor& v);

                /**
                 * returns a new TriMesh containing the 
                 * triangles indicated in tris
                 */
                TriMesh* split(std::vector<bool>& tris);

            protected:
                friend class GeometryFactory;
                friend class SceneGraphTransformer;
                friend class X3DLoader;
                friend class OBJLoader;
                friend class StudioLoader;

                /** mode */
                MeshMode Mode;
                /** triangle count */
                UInt FaceCount;
                /** face connectivity array */
                UInt* Connectivity;
                

                TriMesh(TriMesh& cp) {
                    LOG("FICKEN");
                }
                
        };

    }

}


#endif //include guard


