You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.2 KiB

17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: 3d_class.cpp
  3. /////////////////////////////////////////////////////////////////////////////
  4. #include "fctsys.h"
  5. #include "3d_viewer.h"
  6. S3D_Vertex::S3D_Vertex()
  7. {
  8. x = y = z = 0.0;
  9. }
  10. S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
  11. EDA_ITEM( father, NOT_USED )
  12. {
  13. m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0;
  14. m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0;
  15. m_AmbientIntensity = 1.0;
  16. m_Transparency = 0.0;
  17. m_Shininess = 1.0;
  18. m_Name = name;
  19. }
  20. void S3D_MATERIAL::SetMaterial()
  21. {
  22. glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
  23. glColor4f( m_DiffuseColor.x * m_AmbientIntensity,
  24. m_DiffuseColor.y * m_AmbientIntensity,
  25. m_DiffuseColor.z * m_AmbientIntensity,
  26. 1.0 - m_Transparency );
  27. #if 0
  28. glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR );
  29. glColor3f( m_SpecularColor.x, m_SpecularColor.y, m_SpecularColor.z );
  30. #endif
  31. glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
  32. }
  33. void S3D_MASTER::Copy( S3D_MASTER* pattern )
  34. {
  35. m_Shape3DName = pattern->m_Shape3DName;
  36. m_MatScale = pattern->m_MatScale;
  37. m_MatRotation = pattern->m_MatRotation;
  38. m_MatPosition = pattern->m_MatPosition;
  39. m_3D_Drawings = NULL;
  40. m_Materials = NULL;
  41. }
  42. S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) :
  43. EDA_ITEM( aParent, NOT_USED )
  44. {
  45. m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
  46. m_3D_Drawings = NULL;
  47. m_Materials = NULL;
  48. }
  49. S3D_MASTER:: ~S3D_MASTER()
  50. {
  51. Struct3D_Shape* next;
  52. S3D_MATERIAL* nextmat;
  53. for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
  54. {
  55. next = m_3D_Drawings->Next();
  56. delete m_3D_Drawings;
  57. }
  58. for( ; m_Materials != NULL; m_Materials = nextmat )
  59. {
  60. nextmat = m_Materials->Next();
  61. delete m_Materials;
  62. }
  63. }
  64. Struct3D_Shape::Struct3D_Shape( EDA_ITEM* aParent ) :
  65. EDA_ITEM( aParent, NOT_USED )
  66. {
  67. m_3D_Coord = NULL;
  68. m_3D_CoordIndex = NULL;
  69. m_3D_Points = 0;
  70. }
  71. Struct3D_Shape:: ~Struct3D_Shape()
  72. {
  73. delete m_3D_Coord;
  74. delete m_3D_CoordIndex;
  75. }