1 /* 2 * NodeMaterial.h 3 * 4 * Copyright (C) 1999 Stephen F. White 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program (see the file "COPYING" for details); if 18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave, 19 * Cambridge, MA 02139, USA. 20 */ 21 22 #pragma once 23 24 #include "Node.h" 25 #include "ProtoMacros.h" 26 #include "Proto.h" 27 #include "swt.h" 28 #include "SFMFTypes.h" 29 30 class ProtoMaterial : public WonderlandExportProto { 31 public: 32 ProtoMaterial(Scene *scene); 33 virtual Node *create(Scene *scene); 34 getType()35 virtual int getType() const { return VRML_MATERIAL; } getNodeClass()36 virtual int getNodeClass() const { return MATERIAL_NODE; } 37 isDeclaredInRwd_h()38 virtual bool isDeclaredInRwd_h() { return true; } 39 40 FieldIndex ambientIntensity; 41 FieldIndex diffuseColor; 42 FieldIndex emissiveColor; 43 FieldIndex shininess; 44 FieldIndex specularColor; 45 FieldIndex transparency; 46 FieldIndex mirror; 47 FieldIndex reflSpecular; 48 FieldIndex reflDiffuse; 49 FieldIndex transSpecular; 50 FieldIndex transDiffuse; 51 FieldIndex reflSpecularExp; 52 FieldIndex transSpecularExp; 53 }; 54 55 class NodeMaterial : public Node { 56 public: 57 NodeMaterial(Scene *scene, Proto *proto); 58 59 virtual int getProfile(void) const; getX3dVersion(void)60 virtual int getX3dVersion(void) const { return 0; } copy()61 virtual Node *copy() const { return new NodeMaterial(*this); } 62 isInvalidChildNode(void)63 virtual bool isInvalidChildNode(void) { return true; } 64 virtual int getAnimationCommentID(void); 65 66 virtual void bind(); 67 virtual void unbind(); 68 69 void diffuse2emissive(void); 70 void emissive2diffuse(void); 71 72 virtual bool isTransparent(void); getTransparency(void)73 virtual float getTransparency(void) 74 { 75 return transparency() ? transparency()->getValue() : 0; 76 } 77 78 virtual void reInit(); 79 hasKambiFields(void)80 virtual bool hasKambiFields(void) { return true; } 81 82 virtual int writeAc3dMaterial(int filedes, int indent, 83 const char *name); 84 virtual void handleAc3dMaterial(ac3dMaterialCallback callback, 85 Scene* scene); getAc3dMaterialIndex(void)86 int getAc3dMaterialIndex(void) { return m_ac3dMaterialIndex; } setAc3dMaterialIndex(int index)87 virtual void setAc3dMaterialIndex(int index) 88 { m_ac3dMaterialIndex = index; } getIncAc3dMaterialIndex(void)89 virtual int getIncAc3dMaterialIndex(void) { return 1; } 90 91 virtual int writeLdrawDat(int filedes, int indent); 92 93 fieldMacros(SFFloat, ambientIntensity, ProtoMaterial) 94 fieldMacros(SFColor, diffuseColor, ProtoMaterial) 95 fieldMacros(SFColor, emissiveColor, ProtoMaterial) 96 fieldMacros(SFFloat, shininess, ProtoMaterial) 97 fieldMacros(SFColor, specularColor, ProtoMaterial) 98 fieldMacros(SFFloat, transparency, ProtoMaterial) 99 fieldMacros(SFFloat, mirror, ProtoMaterial) 100 fieldMacros(MFColor, reflSpecular, ProtoMaterial) 101 fieldMacros(MFColor, reflDiffuse, ProtoMaterial) 102 fieldMacros(MFColor, transSpecular, ProtoMaterial) 103 fieldMacros(MFColor, transDiffuse, ProtoMaterial) 104 fieldMacros(SFFloat, reflSpecularExp, ProtoMaterial) 105 fieldMacros(SFFloat, transSpecularExp, ProtoMaterial) 106 107 protected: 108 109 int m_ac3dMaterialIndex; 110 bool m_isFirstLdrawColor; 111 112 public: 113 float *m_verifiedColor; 114 }; 115 116