00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef DAEMATERIALS_H
00016 #define DAEMATERIALS_H
00017
00018 #include "pandatoolbase.h"
00019 #include "eggMaterial.h"
00020 #include "eggTexture.h"
00021 #include "eggPrimitive.h"
00022 #include "eggGroup.h"
00023 #include "pointerTo.h"
00024 #include "pt_EggTexture.h"
00025 #include "pt_EggMaterial.h"
00026
00027 #include "pre_fcollada_include.h"
00028 #include "FCollada.h"
00029 #include "FCDocument/FCDGeometryInstance.h"
00030 #include "FCDocument/FCDMaterialInstance.h"
00031 #include "FCDocument/FCDEffectStandard.h"
00032 #include "FCDocument/FCDEffectParameterSampler.h"
00033 #include "FCDocument/FCDExtra.h"
00034
00035
00036
00037
00038
00039
00040
00041 class DaeMaterials : public TypedReferenceCount {
00042 public:
00043 DaeMaterials(const FCDGeometryInstance* geometry_instance);
00044 virtual ~DaeMaterials() {};
00045
00046 void add_material_instance(const FCDMaterialInstance* instance);
00047 void apply_to(const string semantic, const PT(EggPrimitive) to);
00048 void apply_to(const string semantic, const PT(EggGroup) to);
00049 const string get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set);
00050
00051 static EggTexture::TextureType convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type);
00052 static EggTexture::WrapMode convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode);
00053 static EggTexture::FilterType convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type);
00054
00055 private:
00056
00057 struct DaeBlendSettings : public ReferenceCount {
00058 bool _enabled;
00059 LColor _color;
00060 EggGroup::BlendOperand _operand_a;
00061 EggGroup::BlendOperand _operand_b;
00062 };
00063
00064
00065 struct DaeVertexInputBinding : public ReferenceCount {
00066 int32 _input_set;
00067 FUDaeGeometryInput::Semantic _input_semantic;
00068 string _semantic;
00069 };
00070
00071
00072 struct DaeMaterial : public ReferenceCount {
00073 pvector<PT_EggTexture> _egg_textures;
00074 PT_EggMaterial _egg_material;
00075 bool _double_sided;
00076 pvector<PT(DaeVertexInputBinding)> _uvsets;
00077 PT(DaeBlendSettings) _blend;
00078 };
00079
00080 void process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified);
00081 void process_extra(const string semantic, const FCDExtra* extra);
00082 static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency);
00083
00084 pmap<const string, PT(DaeMaterial)> _materials;
00085
00086 public:
00087 virtual TypeHandle get_type() const {
00088 return get_class_type();
00089 }
00090 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00091 static TypeHandle get_class_type() {
00092 return _type_handle;
00093 }
00094 static void init_type() {
00095 TypedReferenceCount::init_type();
00096 register_type(_type_handle, "DaeMaterials",
00097 TypedReferenceCount::get_class_type());
00098 }
00099
00100 private:
00101 static TypeHandle _type_handle;
00102 };
00103
00104 #endif