00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "colladaBindMaterial.h"
00016 #include "colladaPrimitive.h"
00017
00018
00019 #include "pre_collada_include.h"
00020 #include <dom/domBind_material.h>
00021 #include <dom/domEffect.h>
00022 #include <dom/domInstance_effect.h>
00023 #include <dom/domInstance_material.h>
00024 #include <dom/domMaterial.h>
00025
00026 #if PANDA_COLLADA_VERSION >= 15
00027 #include <dom/domFx_profile.h>
00028 #else
00029 #include <dom/domFx_profile_abstract.h>
00030 #define domFx_profile domFx_profile_abstract
00031 #define domFx_profile_Array domFx_profile_abstract_Array
00032 #define getFx_profile_array getFx_profile_abstract_array
00033 #endif
00034
00035
00036
00037
00038
00039
00040 CPT(RenderState) ColladaBindMaterial::
00041 get_material(const ColladaPrimitive *prim) const {
00042 if (prim == NULL || _states.count(prim->get_material()) == 0) {
00043 return NULL;
00044 }
00045 return _states.find(prim->get_material())->second;
00046 }
00047
00048
00049
00050
00051
00052
00053 CPT(RenderState) ColladaBindMaterial::
00054 get_material(const string &symbol) const {
00055 if (_states.count(symbol) == 0) {
00056 return NULL;
00057 }
00058 return _states.find(symbol)->second;
00059 }
00060
00061
00062
00063
00064
00065 void ColladaBindMaterial::
00066 load_bind_material(domBind_material &bind_mat) {
00067 domInstance_material_Array &mat_instances
00068 = bind_mat.getTechnique_common()->getInstance_material_array();
00069
00070 for (size_t i = 0; i < mat_instances.getCount(); ++i) {
00071 load_instance_material(*mat_instances[i]);
00072 }
00073 }
00074
00075
00076
00077
00078
00079 void ColladaBindMaterial::
00080 load_instance_material(domInstance_material &inst) {
00081 domMaterialRef mat = daeSafeCast<domMaterial> (inst.getTarget().getElement());
00082 nassertv(mat != NULL);
00083
00084 domInstance_effectRef einst = mat->getInstance_effect();
00085 nassertv(einst != NULL);
00086
00087 domInstance_effect::domSetparam_Array &setparams = einst->getSetparam_array();
00088
00089 domEffectRef effect = daeSafeCast<domEffect>
00090 (mat->getInstance_effect()->getUrl().getElement());
00091
00092
00093
00094 const domFx_profile_Array &profiles = effect->getFx_profile_array();
00095 for (size_t i = 0; i < profiles.getCount(); ++i) {
00096
00097 }
00098 }