mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fixed bug in uvset handling
This commit is contained in:
parent
48d9e54a0f
commit
af80d56165
@ -256,7 +256,7 @@ bind_uvsets(MayaFileToUVSetMap &map) {
|
|||||||
MayaShaderColorDef *def = _all_maps[i];
|
MayaShaderColorDef *def = _all_maps[i];
|
||||||
MayaFileToUVSetMap::iterator p = map.find(def->_texture_name);
|
MayaFileToUVSetMap::iterator p = map.find(def->_texture_name);
|
||||||
if (p == map.end()) {
|
if (p == map.end()) {
|
||||||
def->_uvset_name = "default";
|
def->_uvset_name = "map1";
|
||||||
} else {
|
} else {
|
||||||
def->_uvset_name = (*p).second;
|
def->_uvset_name = (*p).second;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ MayaShaderColorDef() {
|
|||||||
_keep_color = false; // classic mode overwrites color: new mode retains color with a 3rd layer
|
_keep_color = false; // classic mode overwrites color: new mode retains color with a 3rd layer
|
||||||
_keep_alpha = false;
|
_keep_alpha = false;
|
||||||
_interpolate = false;
|
_interpolate = false;
|
||||||
_uvset_name = "default";
|
_uvset_name = "map1";
|
||||||
|
|
||||||
_map_uvs = NULL;
|
_map_uvs = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1803,38 +1803,6 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
|||||||
|
|
||||||
_shaders.bind_uvsets(mesh.object());
|
_shaders.bind_uvsets(mesh.object());
|
||||||
|
|
||||||
// MStringArray maya_uvset_names;
|
|
||||||
// status = mesh.getUVSetNames(maya_uvset_names);
|
|
||||||
// if (!status) {
|
|
||||||
// status.perror("MFnMesh getUVSetNames not found");
|
|
||||||
// }
|
|
||||||
// MObjectArray moa;
|
|
||||||
// _tex_names.clear();
|
|
||||||
// _uvset_names.clear();
|
|
||||||
// for (size_t ui=0; ui<maya_uvset_names.length(); ++ui) {
|
|
||||||
// if (mayaegg_cat.is_spam()) {
|
|
||||||
// mayaegg_cat.spam() << "uv_set[" << ui << "] name: " << maya_uvset_names[ui].asChar() << endl;
|
|
||||||
// }
|
|
||||||
// string uvset_name = maya_uvset_names[ui].asChar();
|
|
||||||
// _uvset_names.push_back(uvset_name);
|
|
||||||
//
|
|
||||||
// // Get the tex_names that are connected to those uvnames
|
|
||||||
// mesh.getAssociatedUVSetTextures(maya_uvset_names[ui], moa);
|
|
||||||
// string t_n("");
|
|
||||||
// for (size_t ui=0; ui<moa.length(); ++ui){
|
|
||||||
// MFnDependencyNode dt(moa[ui]);
|
|
||||||
// string t_n = dt.name().asChar();
|
|
||||||
// if (mayaegg_cat.is_spam()) {
|
|
||||||
// mayaegg_cat.spam() << "texture_node:" << t_n << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// _tex_names.push_back(t_n);
|
|
||||||
// }
|
|
||||||
// if (mayaegg_cat.is_spam()) {
|
|
||||||
// mayaegg_cat.spam()
|
|
||||||
// << "done scanning uvs\n";
|
|
||||||
// }
|
|
||||||
|
|
||||||
while (!pi.isDone()) {
|
while (!pi.isDone()) {
|
||||||
EggPolygon *egg_poly = new EggPolygon;
|
EggPolygon *egg_poly = new EggPolygon;
|
||||||
egg_group->add_child(egg_poly);
|
egg_group->add_child(egg_poly);
|
||||||
@ -1925,7 +1893,6 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
|||||||
vert.set_normal(n3d);
|
vert.set_normal(n3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
string uvset_name("");
|
|
||||||
// Go thru all the texture references for this primitive and set uvs
|
// Go thru all the texture references for this primitive and set uvs
|
||||||
if (mayaegg_cat.is_debug()) {
|
if (mayaegg_cat.is_debug()) {
|
||||||
if (shader != (MayaShader *)NULL) {
|
if (shader != (MayaShader *)NULL) {
|
||||||
@ -1935,58 +1902,52 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
|||||||
}
|
}
|
||||||
for (size_t ti=0; ti< _shaders._uvset_names.size(); ++ti) {
|
for (size_t ti=0; ti< _shaders._uvset_names.size(); ++ti) {
|
||||||
// get the eggTexture pointer
|
// get the eggTexture pointer
|
||||||
string colordef_uv_name = uvset_name= _shaders._uvset_names[ti];
|
string uvset_name(_shaders._uvset_names[ti]);
|
||||||
|
string panda_uvset_name = uvset_name;
|
||||||
|
if (panda_uvset_name == "map1") {
|
||||||
|
panda_uvset_name = "default";
|
||||||
|
}
|
||||||
if (mayaegg_cat.is_debug()) {
|
if (mayaegg_cat.is_debug()) {
|
||||||
mayaegg_cat.debug() << "--uvset_name :" << uvset_name << endl;
|
mayaegg_cat.debug() << "--uvset_name :" << uvset_name << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvset_name == "map1") // this is the name to look up by in maya
|
|
||||||
colordef_uv_name = "default";
|
|
||||||
|
|
||||||
// get the shader color def that matches this EggTexture
|
// get the shader color def that matches this EggTexture
|
||||||
// Asad: optimizing uvset: to discard unused uvsets. This for
|
// Asad: optimizing uvset: to discard unused uvsets. This for
|
||||||
// loop figures out which ones are unused.
|
// loop figures out which ones are unused.
|
||||||
//
|
|
||||||
MayaShaderColorDef *color_def = NULL;
|
bool keep_uv = keep_all_uvsets;
|
||||||
bool found = false;
|
bool project_uv = false;
|
||||||
|
TexCoordd uv_projection;
|
||||||
|
|
||||||
if (shader != (MayaShader *)NULL) {
|
if (shader != (MayaShader *)NULL) {
|
||||||
for (size_t tj = 0; tj < shader->_color.size(); ++tj) {
|
for (size_t tj = 0; tj < shader->_all_maps.size(); ++tj) {
|
||||||
color_def = shader->get_color_def(tj);
|
MayaShaderColorDef *def = shader->_all_maps[tj];
|
||||||
if (color_def->_uvset_name == colordef_uv_name) {
|
if (def->_uvset_name == uvset_name) {
|
||||||
if (mayaegg_cat.is_debug()) {
|
if (mayaegg_cat.is_debug()) {
|
||||||
mayaegg_cat.debug() << "matched colordef idx: " << tj << endl;
|
mayaegg_cat.debug() << "matched colordef idx: " << tj << endl;
|
||||||
}
|
}
|
||||||
found = true;
|
keep_uv = true;
|
||||||
|
if (def->has_projection()) {
|
||||||
|
project_uv = true;
|
||||||
|
uv_projection = def->project_uv(p3d, centroid);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && shader->_transparency._uvset_name == colordef_uv_name) {
|
|
||||||
if (mayaegg_cat.is_debug()) {
|
|
||||||
mayaegg_cat.debug() << "matched colordef to transparency\n";
|
|
||||||
}
|
|
||||||
color_def = &shader->_transparency;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if uvset is not used don't add it to the vertex
|
// if uvset is not used don't add it to the vertex
|
||||||
if (!found && !keep_all_uvsets) {
|
if (!keep_uv) {
|
||||||
if (mayaegg_cat.is_spam()) {
|
if (mayaegg_cat.is_spam()) {
|
||||||
mayaegg_cat.spam() << "discarding unused uvset " << uvset_name << endl;
|
mayaegg_cat.spam() << "discarding unused uvset " << uvset_name << endl;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nassertv(color_def != (MayaShaderColorDef *)NULL);
|
|
||||||
|
|
||||||
if (mayaegg_cat.is_debug()) {
|
if (project_uv) {
|
||||||
mayaegg_cat.debug() << "color_def->uvset_name :" << color_def->_uvset_name << endl;
|
|
||||||
}
|
|
||||||
if (color_def->has_projection()) {
|
|
||||||
// If the shader has a projection, use it instead of the
|
// If the shader has a projection, use it instead of the
|
||||||
// polygon's built-in UV's.
|
// polygon's built-in UV's.
|
||||||
vert.set_uv(colordef_uv_name,
|
vert.set_uv(panda_uvset_name, uv_projection);
|
||||||
color_def->project_uv(p3d, centroid));
|
|
||||||
} else {
|
} else {
|
||||||
// Get the UV's from the polygon.
|
// Get the UV's from the polygon.
|
||||||
float2 uvs;
|
float2 uvs;
|
||||||
@ -2011,7 +1972,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
|||||||
mayaegg_cat.debug() << "after rounding uvs[1]: " << uvs[1] << endl;
|
mayaegg_cat.debug() << "after rounding uvs[1]: " << uvs[1] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vert.set_uv(colordef_uv_name, TexCoordd(uvs[0], uvs[1]));
|
vert.set_uv(panda_uvset_name, TexCoordd(uvs[0], uvs[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2737,10 +2698,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader,
|
|||||||
if (mesh) {
|
if (mesh) {
|
||||||
if (uvset_name.find("not found") == -1) {
|
if (uvset_name.find("not found") == -1) {
|
||||||
primitive.add_texture(new_tex);
|
primitive.add_texture(new_tex);
|
||||||
if (uvset_name == "map1") // this is the name to look up by in maya
|
color_def->_uvset_name.assign(uvset_name.c_str());
|
||||||
color_def->_uvset_name.assign("default");
|
|
||||||
else
|
|
||||||
color_def->_uvset_name.assign(uvset_name.c_str());
|
|
||||||
new_tex->set_uv_name(color_def->_uvset_name);
|
new_tex->set_uv_name(color_def->_uvset_name);
|
||||||
if (i == (int)shader._color.size()-1 && is_decal) {
|
if (i == (int)shader._color.size()-1 && is_decal) {
|
||||||
dummy_uvset_name.assign(color_def->_uvset_name);
|
dummy_uvset_name.assign(color_def->_uvset_name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user