/*****************************************************************************
 * $Id: eng_dyna_part.hh,v 1.3 2006/10/20 03:51:47 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Class for a part of a mesh that can transformed (rotated/translated).
 *//*
 * LEGAL:	COPYRIGHT (C) 2006 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#ifndef ENG_DYNA_PART_HH
#define ENG_DYNA_PART_HH 1

#include "eng_dyna.hh"
#include "eng_dyna_model.hh"

////////////////////////////////////////////////////////////////////////////////
// Class for a part of a mesh that can transformed (rotated/translated).
//
// MeshPart is intended to be a member of a DynaModel class.
// A part of a mesh is defined by a set of vixs and a vertex designated as a pivot.
// Vixs typically originate from an Importation object.
// An Importation object is produced from importing a Blender model.
// A set of vertexs in a Blender model can be associated and named as a Vertex Group.
//
// @pre A derived DynaModel class has overriden DynaModel::GetSavedLocalVertexs()
// to return a copy of original unmodified local vertexs.
//
// Design notes:
// To conserve memory, MeshPart depends on DynaModel having saved a copy of
// the original unmodified local vertexs and local normals.
// MeshPart calls DynaModel::GetSavedLocalVertexs() and GetSavedLocalNormals().
//
class MeshPart
{
PREVENT_COPYING(MeshPart)
public:
            MeshPart( DynaModel& dyna, const vector<Vix>& vixs, const Vix pivotVix );
			~MeshPart() { }
    void    Rotate( const uint axis, const Degree deg, const bool resetMatrix = true );
    void    Translate( const LocalVertex& inc );
    void    Implode( const LocalVertex& point );

private:
    DynaModel&              mDyna;      // Dyna object having a polygon mesh
    const vector<Vix>       mVixs;      // index of vertexs comprising part of mesh
    const LocalVertex       mPivot;     // vertex around which part can rotate
    Matrix                  m;
    vector<Nix>             mNixs;      // indexs of normal vectors (not a 1:1 mapping with vixs)
};

#endif // ENG_DYNA_PART_HH
