mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
add vertex-color flag
This commit is contained in:
parent
f7cc219531
commit
106d8cb648
@ -1353,6 +1353,10 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
|
|||||||
// will be different from world space.
|
// will be different from world space.
|
||||||
LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv();
|
LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv();
|
||||||
|
|
||||||
|
// Save this modeling flag for the vertex color check later (see the
|
||||||
|
// comment below).
|
||||||
|
bool egg_vertex_color = egg_group->has_object_type("vertex-color");
|
||||||
|
|
||||||
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);
|
||||||
@ -1376,11 +1380,18 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
|
|||||||
|
|
||||||
const MayaShaderColorDef &color_def = shader->_color;
|
const MayaShaderColorDef &color_def = shader->_color;
|
||||||
|
|
||||||
// Since a texture completely replaces a polygon or vertex color,
|
// Should we extract the color from the vertices? Normally, in
|
||||||
// we need to know up front whether we have a texture.
|
// Maya a texture completely replaces the vertex color, so we
|
||||||
bool has_texture = false;
|
// should ignore the vertex color if we have a texture.
|
||||||
|
|
||||||
|
// However, this is an inconvenient property of Maya; sometimes we
|
||||||
|
// really do want both vertex color and texture applied to the
|
||||||
|
// same object. To allow this, we define the special egg flag
|
||||||
|
// "vertex-color", which when set indicates that we should
|
||||||
|
// respect the vertex color anyway.
|
||||||
|
bool ignore_vertex_color = false;
|
||||||
if (shader != (MayaShader *)NULL) {
|
if (shader != (MayaShader *)NULL) {
|
||||||
has_texture = color_def._has_texture;
|
ignore_vertex_color = color_def._has_texture && !egg_vertex_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the vertices for the polygon.
|
// Get the vertices for the polygon.
|
||||||
@ -1434,7 +1445,7 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pi.hasColor() && !has_texture) {
|
if (pi.hasColor() && !ignore_vertex_color) {
|
||||||
MColor c;
|
MColor c;
|
||||||
status = pi.getColor(c, i);
|
status = pi.getColor(c, i);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -1923,13 +1934,8 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader) {
|
|||||||
// Also apply an overall color to the primitive.
|
// Also apply an overall color to the primitive.
|
||||||
Colorf rgba = shader.get_rgba();
|
Colorf rgba = shader.get_rgba();
|
||||||
|
|
||||||
// This is a placeholder for a parameter on the shader or group that
|
// The existence of a texture on either color channel completely
|
||||||
// we have yet to define.
|
// replaces the corresponding flat color.
|
||||||
static const bool modulate = false;
|
|
||||||
|
|
||||||
if (!modulate) {
|
|
||||||
// If modulate is not specified, the existence of a texture on
|
|
||||||
// either color channel completely replaces the flat color.
|
|
||||||
if (color_def._has_texture) {
|
if (color_def._has_texture) {
|
||||||
rgba[0] = 1.0f;
|
rgba[0] = 1.0f;
|
||||||
rgba[1] = 1.0f;
|
rgba[1] = 1.0f;
|
||||||
@ -1938,7 +1944,6 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader) {
|
|||||||
if (trans_def._has_texture) {
|
if (trans_def._has_texture) {
|
||||||
rgba[3] = 1.0f;
|
rgba[3] = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// But the color gain always gets applied.
|
// But the color gain always gets applied.
|
||||||
rgba[0] *= color_def._color_gain[0];
|
rgba[0] *= color_def._color_gain[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user