mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
New maya exporter code basically operational
This commit is contained in:
parent
344a48f43d
commit
d742043ad8
@ -564,8 +564,8 @@ affects_polygon_alpha() const {
|
||||
return false;
|
||||
|
||||
case ET_normal_map:
|
||||
case ET_normal_spower_map:
|
||||
case ET_scolor_spower_map:
|
||||
case ET_gloss_map:
|
||||
case ET_normal_gloss_map:
|
||||
return false;
|
||||
|
||||
case ET_selector_map:
|
||||
@ -883,11 +883,11 @@ string_env_type(const string &string) {
|
||||
} else if (cmp_nocase_uh(string, "normal_map") == 0) {
|
||||
return ET_normal_map;
|
||||
|
||||
} else if (cmp_nocase_uh(string, "normal_spower_map") == 0) {
|
||||
return ET_normal_spower_map;
|
||||
} else if (cmp_nocase_uh(string, "gloss_map") == 0) {
|
||||
return ET_gloss_map;
|
||||
|
||||
} else if (cmp_nocase_uh(string, "scolor_spower_map") == 0) {
|
||||
return ET_scolor_spower_map;
|
||||
} else if (cmp_nocase_uh(string, "normal_gloss_map") == 0) {
|
||||
return ET_normal_gloss_map;
|
||||
|
||||
} else if (cmp_nocase_uh(string, "selector_map") == 0) {
|
||||
return ET_selector_map;
|
||||
@ -1294,11 +1294,11 @@ ostream &operator << (ostream &out, EggTexture::EnvType type) {
|
||||
case EggTexture::ET_normal_map:
|
||||
return out << "normal_map";
|
||||
|
||||
case EggTexture::ET_normal_spower_map:
|
||||
return out << "normal_spower_map";
|
||||
case EggTexture::ET_gloss_map:
|
||||
return out << "gloss_map";
|
||||
|
||||
case EggTexture::ET_scolor_spower_map:
|
||||
return out << "scolor_spower_map";
|
||||
case EggTexture::ET_normal_gloss_map:
|
||||
return out << "normal_gloss_map";
|
||||
|
||||
case EggTexture::ET_selector_map:
|
||||
return out << "selector_map";
|
||||
|
@ -103,8 +103,8 @@ PUBLISHED:
|
||||
ET_add,
|
||||
ET_blend_color_scale,
|
||||
ET_normal_map,
|
||||
ET_normal_spower_map,
|
||||
ET_scolor_spower_map,
|
||||
ET_gloss_map,
|
||||
ET_normal_gloss_map,
|
||||
ET_selector_map,
|
||||
};
|
||||
enum CombineMode {
|
||||
|
@ -1383,12 +1383,12 @@ make_texture_stage(const EggTexture *egg_tex) {
|
||||
stage->set_mode(TextureStage::M_normal_map);
|
||||
break;
|
||||
|
||||
case EggTexture::ET_normal_spower_map:
|
||||
stage->set_mode(TextureStage::M_normal_spower_map);
|
||||
case EggTexture::ET_gloss_map:
|
||||
stage->set_mode(TextureStage::M_gloss_map);
|
||||
break;
|
||||
|
||||
case EggTexture::ET_scolor_spower_map:
|
||||
stage->set_mode(TextureStage::M_scolor_spower_map);
|
||||
case EggTexture::ET_normal_gloss_map:
|
||||
stage->set_mode(TextureStage::M_normal_gloss_map);
|
||||
break;
|
||||
|
||||
case EggTexture::ET_selector_map:
|
||||
|
@ -61,8 +61,8 @@ PUBLISHED:
|
||||
// Modes that are only relevant to shader-based rendering.
|
||||
|
||||
M_normal_map,
|
||||
M_normal_spower_map,
|
||||
M_scolor_spower_map,
|
||||
M_gloss_map,
|
||||
M_normal_gloss_map,
|
||||
M_selector_map,
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ for ($i in $sel)
|
||||
string $attrName = "eggObjectTypes";
|
||||
|
||||
// Modify this line as needed to add your own object types.
|
||||
string $eggFlags = "none:portal:polylight:seq24:seq12:indexed:model:dcs:barrier:sphere:tube:trigger:trigger-sphere:bubble:ghost:keep-all-uvsets"
|
||||
string $eggFlags = "none:portal:polylight:seq24:seq12:indexed:model:dcs:barrier:sphere:tube:trigger:trigger-sphere:bubble:ghost:keep-all-uvsets";
|
||||
|
||||
string $object = ($i + ".eggObjectTypes");
|
||||
|
||||
|
@ -213,10 +213,22 @@ find_textures_modern(MObject shader) {
|
||||
|
||||
string n = shader_fn.name().asChar();
|
||||
|
||||
MayaShaderColorDef::find_textures_modern(n, _color_maps, shader_fn.findPlug("color"));
|
||||
MayaShaderColorDef::find_textures_modern(n, _trans_maps, shader_fn.findPlug("transparency"));
|
||||
MayaShaderColorDef::find_textures_modern(n, _normal_maps, shader_fn.findPlug("normalCamera"));
|
||||
MayaShaderColorDef::find_textures_modern(n, _gloss_maps, shader_fn.findPlug("specularColor"));
|
||||
MayaShaderColorDef::find_textures_modern(n, _color_maps, shader_fn.findPlug("color"), false);
|
||||
if (_color_maps.size() == 0) {
|
||||
MayaShaderColorDef::find_textures_modern(n, _color_maps, shader_fn.findPlug("colorR"), false);
|
||||
}
|
||||
MayaShaderColorDef::find_textures_modern(n, _trans_maps, shader_fn.findPlug("transparency"), true);
|
||||
if (_trans_maps.size() == 0) {
|
||||
MayaShaderColorDef::find_textures_modern(n, _trans_maps, shader_fn.findPlug("transparencyR"), true);
|
||||
}
|
||||
MayaShaderColorDef::find_textures_modern(n, _normal_maps, shader_fn.findPlug("normalCamera"), false);
|
||||
if (_normal_maps.size() == 0) {
|
||||
MayaShaderColorDef::find_textures_modern(n, _normal_maps, shader_fn.findPlug("normalCameraR"), false);
|
||||
}
|
||||
MayaShaderColorDef::find_textures_modern(n, _gloss_maps, shader_fn.findPlug("specularColor"), true);
|
||||
if (_gloss_maps.size() == 0) {
|
||||
MayaShaderColorDef::find_textures_modern(n, _gloss_maps, shader_fn.findPlug("specularColorR"), true);
|
||||
}
|
||||
|
||||
collect_maps();
|
||||
|
||||
@ -289,6 +301,20 @@ calculate_pairings() {
|
||||
try_pair(_normal_maps[i], _gloss_maps[j], false);
|
||||
}
|
||||
}
|
||||
for (size_t i=0; i<_normal_maps.size(); i++) {
|
||||
if (_normal_maps[i]->_opposite) {
|
||||
_normal_maps[i]->_blend_type = MayaShaderColorDef::BT_normal_gloss_map;
|
||||
} else {
|
||||
_normal_maps[i]->_blend_type = MayaShaderColorDef::BT_normal_map;
|
||||
}
|
||||
}
|
||||
for (size_t i=0; i<_gloss_maps.size(); i++) {
|
||||
if (_gloss_maps[i]->_opposite) {
|
||||
_gloss_maps[i]->_blend_type = MayaShaderColorDef::BT_unspecified;
|
||||
} else {
|
||||
_gloss_maps[i]->_blend_type = MayaShaderColorDef::BT_gloss_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -64,6 +64,8 @@ MayaShaderColorDef() {
|
||||
_offset.set(0.0, 0.0);
|
||||
_rotate_uv = 0.0;
|
||||
|
||||
_is_alpha = false;
|
||||
|
||||
_opposite = 0;
|
||||
|
||||
_color_object = (MObject *)NULL;
|
||||
@ -120,6 +122,8 @@ MayaShaderColorDef(MayaShaderColorDef ©) {
|
||||
_offset = copy._offset;
|
||||
_rotate_uv = copy._rotate_uv;
|
||||
|
||||
_is_alpha = copy._is_alpha;
|
||||
|
||||
_map_uvs = copy._map_uvs;
|
||||
_color_object = copy._color_object;
|
||||
|
||||
@ -241,24 +245,18 @@ reset_maya_texture(const Filename &texture) {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShaderColorDef::strip_prefix
|
||||
// Function: MayaShaderColorDef::get_panda_uvset_name
|
||||
// Access: Private
|
||||
// Description: Maya puts a prefix on shader nameswhen files are
|
||||
// imported. This routine strips that out before writing
|
||||
// egg file. //This was a hack: not needed anymore
|
||||
// Description: Maya's default uvset name is "map1". Panda's default
|
||||
// uvset name is "default". Otherwise, leaves uvset
|
||||
// name untranslated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string MayaShaderColorDef::
|
||||
strip_prefix(string full_name) {
|
||||
string axed_name;
|
||||
size_t cut_point = full_name.find(":");
|
||||
if (cut_point != string::npos) {
|
||||
axed_name = full_name.substr(cut_point+1);
|
||||
if (maya_cat.is_spam()) {
|
||||
maya_cat.spam() << "stripped from: " << full_name << "-> to: " << axed_name << endl;
|
||||
}
|
||||
return axed_name;
|
||||
get_panda_uvset_name() {
|
||||
if (_uvset_name == "map1") {
|
||||
return "default";
|
||||
}
|
||||
return full_name;
|
||||
return _uvset_name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -505,7 +503,7 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) {
|
||||
// to the provided MayaShaderColorList.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaShaderColorDef::
|
||||
find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug) {
|
||||
find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha) {
|
||||
|
||||
MPlugArray outplugs;
|
||||
inplug.connectedTo(outplugs, true, false);
|
||||
@ -568,6 +566,8 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
def->_color_gain[2] = color_gain[2];
|
||||
def->_color_gain[3] = alpha_gain;
|
||||
|
||||
def->_is_alpha = is_alpha;
|
||||
|
||||
if (maya_cat.is_debug()) {
|
||||
maya_cat.debug() << "pushed a file texture" << endl;
|
||||
}
|
||||
@ -586,7 +586,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
image_plug.connectedTo(image_pa, true, false);
|
||||
|
||||
for (size_t i = 0; i < image_pa.length(); i++) {
|
||||
find_textures_modern(shadername, list, image_pa[0]);
|
||||
find_textures_modern(shadername, list, image_pa[0], is_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,7 +623,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
|
||||
MPlug inputsPlug = sourceFn.findPlug("inputs");
|
||||
size_t nlayers = inputsPlug.numElements();
|
||||
for (size_t layer=0; layer < nlayers; layer++) {
|
||||
for (int layer=nlayers-1; layer >= 0; layer--) {
|
||||
MPlug elt = inputsPlug.elementByPhysicalIndex(layer);
|
||||
MPlug color;
|
||||
MPlug blend;
|
||||
@ -638,7 +638,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
return;
|
||||
}
|
||||
size_t before = list.size();
|
||||
find_textures_modern(shadername, list, color);
|
||||
find_textures_modern(shadername, list, color, is_alpha);
|
||||
int blendValue;
|
||||
blend.getValue(blendValue);
|
||||
for (size_t sub=before; sub<list.size(); sub++) {
|
||||
@ -650,8 +650,15 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.apiType() == MFn::kReverse) {
|
||||
MPlug input_plug = sourceFn.findPlug("input");
|
||||
find_textures_modern(shadername, list, input_plug, is_alpha);
|
||||
return;
|
||||
}
|
||||
|
||||
// This shader wasn't understood.
|
||||
if (maya_cat.is_debug()) {
|
||||
maya_cat.info()
|
||||
@ -662,9 +669,9 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug
|
||||
// of unsupported shader once.
|
||||
static pset<MFn::Type> bad_types;
|
||||
if (bad_types.insert(source.apiType()).second) {
|
||||
maya_cat.info()
|
||||
<< "**Don't know how to interpret color attribute type "
|
||||
<< source.apiTypeStr() << "\n";
|
||||
maya_cat.warning()
|
||||
<< "Don't know how to export a shader of type "
|
||||
<< source.apiTypeStr() << " " << sourceFn.type() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,10 @@ public:
|
||||
BT_replace,
|
||||
BT_add,
|
||||
BT_blend_color_scale,
|
||||
BT_normal_map,
|
||||
BT_gloss_map,
|
||||
BT_normal_gloss_map,
|
||||
BT_selector_map,
|
||||
};
|
||||
|
||||
enum ProjectionType {
|
||||
@ -96,14 +100,19 @@ public:
|
||||
LVector2f _repeat_uv;
|
||||
LVector2f _offset;
|
||||
double _rotate_uv;
|
||||
|
||||
bool _is_alpha;
|
||||
|
||||
string _uvset_name;
|
||||
MayaShaderColorDef *_opposite;
|
||||
|
||||
string get_panda_uvset_name();
|
||||
|
||||
private:
|
||||
MObject *_color_object;
|
||||
|
||||
private:
|
||||
static void find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug);
|
||||
static void find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha);
|
||||
void find_textures_legacy(MayaShader *shader, MObject color, bool trans=false);
|
||||
|
||||
void set_projection_type(const string &type);
|
||||
@ -135,9 +144,6 @@ private:
|
||||
// * keep_color, keep_alpha, and interpolate are all
|
||||
// adjuncts to blend_mode - it would make more sense just to
|
||||
// add some more blend_modes.
|
||||
//
|
||||
// * uvset_name is a property of a mesh, not a property
|
||||
// of a shader. It varies as you move through the scene.
|
||||
|
||||
public:
|
||||
bool _has_texture; // deprecated, see above.
|
||||
@ -147,7 +153,6 @@ public:
|
||||
bool _keep_color; // deprecated, see above.
|
||||
bool _keep_alpha; // deprecated, see above.
|
||||
bool _interpolate; // deprecated, see above.
|
||||
string _uvset_name; // deprecated, see above.
|
||||
|
||||
};
|
||||
|
||||
|
@ -1861,7 +1861,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
||||
|
||||
// And apply the shader properties to the polygon.
|
||||
if (shader != (MayaShader *)NULL) {
|
||||
set_shader_attributes(*egg_poly, *shader, &pi);
|
||||
set_shader_attributes(*egg_poly, *shader, true);
|
||||
default_color_def = shader->get_color_def();
|
||||
}
|
||||
|
||||
@ -2445,8 +2445,74 @@ get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface,
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
const MItMeshPolygon *pi) {
|
||||
bool mesh) {
|
||||
if (shader._legacy_mode) {
|
||||
set_shader_legacy(primitive, shader, mesh);
|
||||
} else {
|
||||
set_shader_modern(primitive, shader, mesh);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEggConverter::set_shader_modern
|
||||
// Access: Private
|
||||
// Description: The modern implementation of set_shader_attributes.
|
||||
//
|
||||
// In the modern codepath, the MayaShader is a direct,
|
||||
// literal representation of a list of EggTextures.
|
||||
// All this exporter has to do is translate the list
|
||||
// without interpretation. All the complex interpretation
|
||||
// is handled elsewhere, in the MayaShader module.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
set_shader_modern(EggPrimitive &primitive, const MayaShader &shader,
|
||||
bool mesh) {
|
||||
|
||||
for (size_t idx=0; idx < shader._all_maps.size(); idx++) {
|
||||
MayaShaderColorDef *def = shader._all_maps[idx];
|
||||
if ((def->_is_alpha)&&(def->_opposite != 0)) {
|
||||
// This texture represents an alpha-filename. It doesn't get its own <Texture>
|
||||
continue;
|
||||
}
|
||||
|
||||
EggTexture tex(shader.get_name(), "");
|
||||
tex.set_format(def->_is_alpha ? EggTexture::F_alpha : EggTexture::F_rgb);
|
||||
apply_texture_filename(tex, *def);
|
||||
if (def->_opposite) {
|
||||
apply_texture_alpha_filename(tex, *def);
|
||||
}
|
||||
apply_texture_uvprops(tex, *def);
|
||||
apply_texture_blendtype(tex, *def);
|
||||
tex.set_uv_name(def->get_panda_uvset_name());
|
||||
|
||||
EggTexture *new_tex =
|
||||
_textures.create_unique_texture(tex, ~0);
|
||||
primitive.add_texture(new_tex);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEggConverter::set_shader_legacy
|
||||
// Access: Private
|
||||
// Description: The legacy implementation of set_shader_attributes.
|
||||
// The old behavior of the exporter is just plain weird.
|
||||
// It seems to be a result of an inexperienced coder
|
||||
// who made some core mistakes, and then patched them
|
||||
// up with kludges. It seems to produce plausible
|
||||
// results in certain specific cases, but overall, it
|
||||
// doesn't make any sense. Unfortunately, this weird
|
||||
// behavior cannot be discarded - vast numbers of 3D
|
||||
// models have been created that rely on this behavior.
|
||||
// The solution is to compartmentalize the weirdness.
|
||||
// The legacy codepath, when activated, implements the
|
||||
// old weird behavior. A brand-new codepath that
|
||||
// shares almost nothing with the legacy codepath
|
||||
// implements a much more straightforward behavior.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader,
|
||||
bool mesh) {
|
||||
|
||||
// determine if the base texture or any of the top texture need to be rgb only
|
||||
MayaShaderColorDef *color_def = NULL;
|
||||
bool is_rgb = false;
|
||||
@ -2510,7 +2576,7 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
_path_replace->full_convert_path(filename, get_texture_path(), fullpath, outpath);
|
||||
tex.set_filename(outpath);
|
||||
tex.set_fullpath(fullpath);
|
||||
apply_texture_properties(tex, *color_def);
|
||||
apply_texture_uvprops(tex, *color_def);
|
||||
|
||||
// If we also have a texture on transparency, apply it as the
|
||||
// alpha filename.
|
||||
@ -2522,7 +2588,7 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
<< " has contradictory wrap modes on color and texture.\n";
|
||||
}
|
||||
|
||||
if (!compare_texture_properties(tex, trans_def)) {
|
||||
if (!compare_texture_uvprops(tex, trans_def)) {
|
||||
// Only report each broken shader once.
|
||||
static pset<string> bad_shaders;
|
||||
if (bad_shaders.insert(shader.get_name()).second) {
|
||||
@ -2632,7 +2698,7 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
}
|
||||
texDummy.set_filename(outpath);
|
||||
texDummy.set_fullpath(fullpath);
|
||||
apply_texture_properties(texDummy, *color_def);
|
||||
apply_texture_uvprops(texDummy, *color_def);
|
||||
texDummy.set_combine_mode(EggTexture::CC_rgb, EggTexture::CM_modulate);
|
||||
texDummy.set_combine_source(EggTexture::CC_rgb, 0, EggTexture::CS_primary_color);
|
||||
texDummy.set_combine_operand(EggTexture::CC_rgb, 0, EggTexture::CO_src_color);
|
||||
@ -2655,7 +2721,7 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
tex.set_filename(outpath);
|
||||
tex.set_fullpath(fullpath);
|
||||
tex.set_format(EggTexture::F_alpha);
|
||||
apply_texture_properties(tex, trans_def);
|
||||
apply_texture_uvprops(tex, trans_def);
|
||||
}
|
||||
|
||||
if (mayaegg_cat.is_debug()) {
|
||||
@ -2668,7 +2734,7 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
EggTexture *new_tex =
|
||||
_textures.create_unique_texture(tex, ~0);
|
||||
|
||||
if (pi) {
|
||||
if (mesh) {
|
||||
if (uvset_name.find("not found") == -1) {
|
||||
primitive.add_texture(new_tex);
|
||||
if (uvset_name == "map1") // this is the name to look up by in maya
|
||||
@ -2726,14 +2792,14 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShader::apply_texture_properties
|
||||
// Function: MayaShader::apply_texture_uvprops
|
||||
// Access: Private
|
||||
// Description: Applies all the appropriate texture properties to the
|
||||
// EggTexture object, including wrap modes and texture
|
||||
// matrix.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
apply_texture_properties(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
apply_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
// Let's mipmap all textures by default.
|
||||
tex.set_minfilter(EggTexture::FT_linear_mipmap_linear);
|
||||
tex.set_magfilter(EggTexture::FT_linear);
|
||||
@ -2743,7 +2809,7 @@ apply_texture_properties(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
|
||||
tex.set_wrap_u(wrap_u);
|
||||
tex.set_wrap_v(wrap_v);
|
||||
|
||||
|
||||
LMatrix3d mat = color_def.compute_texture_matrix();
|
||||
if (!mat.almost_equal(LMatrix3d::ident_mat())) {
|
||||
tex.set_transform2d(mat);
|
||||
@ -2751,17 +2817,94 @@ apply_texture_properties(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShader::compare_texture_properties
|
||||
// Function: MayaShader::apply_texture_blendtype
|
||||
// Access: Private
|
||||
// Description: Applies the blendtype to the EggTexture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
apply_texture_blendtype(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
switch (color_def._blend_type) {
|
||||
case MayaShaderColorDef::BT_unspecified:
|
||||
tex.set_env_type(EggTexture::ET_unspecified);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_modulate:
|
||||
tex.set_env_type(EggTexture::ET_modulate);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_decal:
|
||||
tex.set_env_type(EggTexture::ET_decal);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_blend:
|
||||
tex.set_env_type(EggTexture::ET_blend);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_replace:
|
||||
tex.set_env_type(EggTexture::ET_replace);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_add:
|
||||
tex.set_env_type(EggTexture::ET_add);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_blend_color_scale:
|
||||
tex.set_env_type(EggTexture::ET_blend_color_scale);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_normal_map:
|
||||
tex.set_env_type(EggTexture::ET_normal_map);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_gloss_map:
|
||||
tex.set_env_type(EggTexture::ET_gloss_map);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_normal_gloss_map:
|
||||
tex.set_env_type(EggTexture::ET_normal_gloss_map);
|
||||
return;
|
||||
case MayaShaderColorDef::BT_selector_map:
|
||||
tex.set_env_type(EggTexture::ET_selector_map);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShader::apply_texture_filename
|
||||
// Access: Private
|
||||
// Description: Applies the filename to the EggTexture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
apply_texture_filename(EggTexture &tex, const MayaShaderColorDef &def) {
|
||||
Filename filename = Filename::from_os_specific(def._texture_filename);
|
||||
Filename fullpath, outpath;
|
||||
_path_replace->full_convert_path(filename, get_texture_path(), fullpath, outpath);
|
||||
tex.set_filename(outpath);
|
||||
tex.set_fullpath(fullpath);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShader::apply_texture_alpha_filename
|
||||
// Access: Private
|
||||
// Description: Applies the alpha filename to the EggTexture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MayaToEggConverter::
|
||||
apply_texture_alpha_filename(EggTexture &tex, const MayaShaderColorDef &def) {
|
||||
if (def._opposite) {
|
||||
tex.set_format(EggTexture::F_rgba);
|
||||
if (def._opposite->_texture_filename != def._texture_filename) {
|
||||
Filename filename = Filename::from_os_specific(def._opposite->_texture_filename);
|
||||
Filename fullpath, outpath;
|
||||
_path_replace->full_convert_path(filename, get_texture_path(), fullpath, outpath);
|
||||
tex.set_alpha_filename(outpath);
|
||||
tex.set_alpha_fullpath(fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaShader::compare_texture_uvprops
|
||||
// Access: Private
|
||||
// Description: Compares the texture properties already on the
|
||||
// texture (presumably set by a previous call to
|
||||
// apply_texture_properties()) and returns false if they
|
||||
// apply_texture_uvprops()) and returns false if they
|
||||
// differ from that specified by the indicated color_def
|
||||
// object, or true if they match.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool MayaToEggConverter::
|
||||
compare_texture_properties(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def) {
|
||||
compare_texture_uvprops(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def) {
|
||||
bool okflag = true;
|
||||
|
||||
EggTexture::WrapMode wrap_u = color_def._wrap_u ? EggTexture::WM_repeat : EggTexture::WM_clamp;
|
||||
|
@ -143,17 +143,23 @@ private:
|
||||
pvector<EggGroup *> &joints, MFloatArray &weights);
|
||||
bool get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface,
|
||||
pvector<EggGroup *> &joints, MFloatArray &weights);
|
||||
// void set_shader_attributes(EggPrimitive &primitive,
|
||||
// const MayaShader &shader);
|
||||
void set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
const MItMeshPolygon *pi = NULL);
|
||||
//const vector_string &uvset_names = vector_string());
|
||||
void apply_texture_properties(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
bool compare_texture_properties(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
|
||||
void apply_texture_uvprops(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
void apply_texture_blendtype(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
void apply_texture_filename(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
void apply_texture_alpha_filename(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
bool compare_texture_uvprops(EggTexture &tex,
|
||||
const MayaShaderColorDef &color_def);
|
||||
bool reparent_decals(EggGroupNode *egg_parent);
|
||||
void set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader,
|
||||
bool mesh = false);
|
||||
void set_shader_modern(EggPrimitive &primitive, const MayaShader &shader,
|
||||
bool mesh);
|
||||
void set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader,
|
||||
bool mesh);
|
||||
|
||||
int round(double value);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user