2012-08-21 10:45:54 +00:00
|
|
|
/**
|
|
|
|
* @file 3d_class.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_viewer.h>
|
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 ) :
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM( 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;
|
2009-11-04 20:46:53 +00:00
|
|
|
m_Transparency = 0.0;
|
|
|
|
m_Shininess = 1.0;
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Name = name;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +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,
|
2009-11-04 20:46:53 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) :
|
|
|
|
EDA_ITEM( 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
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
STRUCT_3D_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;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
for( ; m_Materials != NULL; m_Materials = nextmat )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
nextmat = m_Materials->Next();
|
|
|
|
delete m_Materials;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
STRUCT_3D_SHAPE::STRUCT_3D_SHAPE( EDA_ITEM* aParent ) :
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM( aParent, NOT_USED )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
m_3D_Coord = NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
m_3D_CoordIndex = NULL;
|
|
|
|
m_3D_Points = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
STRUCT_3D_SHAPE:: ~STRUCT_3D_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
|
|
|
}
|