2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Name: 3d_class.cpp
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "3d_viewer.h"
|
|
|
|
|
|
|
|
|
|
|
|
/****************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
S3D_Vertex::S3D_Vertex()
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
x = y = z = 0.0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
|
2008-11-24 06:53:43 +00:00
|
|
|
EDA_BaseStruct( father, NOT_USED )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0;
|
|
|
|
m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_AmbientIntensity = 1.0;
|
|
|
|
m_Transparency = 0.0;
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Shininess = 1.0;
|
|
|
|
m_Name = name;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************/
|
2008-12-06 08:21:54 +00:00
|
|
|
void S3D_MATERIAL::SetMaterial()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
|
|
|
glColor4f( m_DiffuseColor.x * m_AmbientIntensity,
|
|
|
|
m_DiffuseColor.y * m_AmbientIntensity,
|
|
|
|
m_DiffuseColor.z * m_AmbientIntensity,
|
|
|
|
1.0 - m_Transparency );
|
2007-06-05 12:10:51 +00:00
|
|
|
#if 0
|
2008-11-24 06:53:43 +00:00
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR );
|
|
|
|
glColor3f( m_SpecularColor.x, m_SpecularColor.y, m_SpecularColor.z );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2008-11-24 06:53:43 +00:00
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
2008-12-06 08:21:54 +00:00
|
|
|
void S3D_MASTER::Copy( S3D_MASTER* pattern )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Shape3DName = pattern->m_Shape3DName;
|
|
|
|
m_MatScale = pattern->m_MatScale;
|
|
|
|
m_MatRotation = pattern->m_MatRotation;
|
|
|
|
m_MatPosition = pattern->m_MatPosition;
|
|
|
|
m_3D_Drawings = NULL;
|
|
|
|
m_Materials = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MASTER::S3D_MASTER( EDA_BaseStruct* aParent ) :
|
2008-12-04 04:28:11 +00:00
|
|
|
EDA_BaseStruct( aParent, NOT_USED )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
|
|
|
|
m_3D_Drawings = NULL;
|
|
|
|
m_Materials = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************/
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MASTER:: ~S3D_MASTER()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
Struct3D_Shape* next;
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MATERIAL* nextmat;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
|
|
|
|
{
|
|
|
|
next = m_3D_Drawings->Next();
|
|
|
|
delete m_3D_Drawings;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ; m_Materials != NULL; m_Materials = nextmat )
|
|
|
|
{
|
|
|
|
nextmat = m_Materials->Next();
|
|
|
|
delete m_Materials;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2008-12-04 04:28:11 +00:00
|
|
|
Struct3D_Shape::Struct3D_Shape( EDA_BaseStruct* aParent ) :
|
|
|
|
EDA_BaseStruct( aParent, NOT_USED )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_3D_Coord = NULL;
|
|
|
|
m_3D_CoordIndex = NULL;
|
|
|
|
m_3D_Points = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
Struct3D_Shape:: ~Struct3D_Shape()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
delete m_3D_Coord;
|
|
|
|
delete m_3D_CoordIndex;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|