///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-1996 Virtual Design All Rights Reserved.
//
// Permission to use,  copy,  modify,  and  distribute  this  software and its
// documentation for NON-COMMERCIAL purposes and without fee is hereby granted.
//
// VIRTUAL DESIGN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
// OF THE SOFTWARE, EITHER EXPRESS  OR  IMPLIED,  INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
// OR NON-INFRINGEMENT. VIRTUAL DESIGN SHALL  NOT  BE LIABLE FOR ANY DAMAGES
// SUFFERED BY  LICENSEE AS A RESULT OF USING,  MODIFYING OR DISTRIBUTING THIS
// SOFTWARE OR ITS DERIVATIVES.
//
// THIS SOFTWARE  IS   NOT  DESIGNED  OR  INTENDED FOR USE OR RESALE AS ONLINE
// OR NOT ONLINE CONTROL  EQUIPMENT IN HAZARDOUS  ENVIRONMENTS REQUIRING  FAIL-
// SAFE PERFORMANCE,  SUCH  AS  IN   THE   OPERATION   OF  NUCLEAR  FACILITIES,
// AIRCRAFT   NAVIGATION  OR  COMMUNICATION  SYSTEMS,  AIR   TRAFFIC   CONTROL,
// DIRECT LIFE  SUPPORT  MACHINES, OR WEAPONS SYSTEMS, IN  WHICH  THE  FAILURE
// OF  THE SOFTWARE COULD  LEAD DIRECTLY  TO DEATH, PERSONAL INJURY, OR SEVERE
// PHYSICAL OR ENVIRONMENTAL  DAMAGE ("HIGH RISK ACTIVITIES").  VIRTUAL DESIGN
// SPECIFICALLY DISCLAIMS  ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH
// RISK ACTIVITIES.
///////////////////////////////////////////////////////////////////////////////

/**
 * Classe de base des sommets.
 * @author Guillaume Pelletier.
 * @version 1.0
 */

////////////////////////////////////////////////////////////////////////////////
/**
 * Classe des pixels. Coordonées écrans.
 */
////////////////////////////////////////////////////////////////////////////////
class Pixel
 {
 public int m_x, m_y ;

/**
 *  constructeur vide
 */
 public Pixel() { this(0,0);}

/**
 *  constructeur parametré
 */
 public Pixel( int p_x, int p_y )
  {
  m_x = p_x ; m_y = p_y ;
  }

/**
 *  constructeur de copie.
 */
 public Pixel( Pixel p_s )
  {
  this( p_s.m_x, p_s.m_y);
  }
 }

////////////////////////////////////////////////////////////////////////////////
/**
 * Classe des sommets 2D.
 */
////////////////////////////////////////////////////////////////////////////////
class Sommet2D
 {
 public float m_x, m_y ;

/**
 *  constructeur vide
 */
 public Sommet2D() { this(0.0f,0.0f);}

/**
 *  constructeur parametré
 */
 public Sommet2D( float p_x, float p_y )
  {
  m_x = p_x ; m_y = p_y ;
  }

/**
 *  constructeur de copie.
 */
 public Sommet2D( Sommet2D p_s )
  {
  this( p_s.m_x, p_s.m_y);
  }
 }

////////////////////////////////////////////////////////////////////////////////

/**
 * Classe des sommets 3D.
 */
////////////////////////////////////////////////////////////////////////////////
class Sommet3D extends Sommet2D
 {
 public float m_z ;

/**
 *  constructeur vide
 */
 public Sommet3D() { m_z = 0.0f ;}

/**
 *  constructeur parametré
 */
 public Sommet3D( float p_x, float p_y, float p_z )
  {
  super(p_x,p_y); m_z = p_z ;
  }

/**
 *  constructeur de copie.
 */
 public Sommet3D( Sommet3D p_s )
  {
  this( p_s.m_x, p_s.m_y, p_s.m_z);
  }
 }


////////////////////////////////////////////////////////////////////////////////
/**
 * Classe des sommets 3D en coordonnées homogènes.
 */
////////////////////////////////////////////////////////////////////////////////
class Sommet3DH extends Sommet3D
 {
 public float m_w ;

/**
 *  constructeur vide
 */
 public Sommet3DH() { m_w = 1.0f; }

/**
 *  constructeur parametré
 */
 public Sommet3DH( float p_x, float p_y, float p_z, float p_w )
  {
  super(p_x, p_y, p_z); m_w = p_w ;
  }

/**
 *  constructeur de copie.
 */
 public Sommet3DH( Sommet3DH p_s )
  {
  this( p_s.m_x, p_s.m_y, p_s.m_z, p_s.m_w);
  }

/**
 *  Multiplication par une matrice de transformation générale.
 */
 public void multiplyByMatrix( Matrice44 p_m )
   {
   float l_x = m_x * p_m.m_xx + m_y * p_m.m_yx +
               m_z * p_m.m_zx + m_w * p_m.m_wx ;

   float l_y = m_x * p_m.m_xy + m_y * p_m.m_yy +
               m_z * p_m.m_zy + m_w * p_m.m_wy ;

   float l_z = m_x * p_m.m_xz + m_y * p_m.m_yz +
               m_z * p_m.m_zz + m_w * p_m.m_wz ;

   float l_w = m_x * p_m.m_xw + m_y * p_m.m_yw +
               m_z * p_m.m_zw + m_w * p_m.m_ww ;

   m_x = l_x ;
   m_y = l_y ;
   m_z = l_z ;
   m_w = l_w ;
   }
 }
