From f1c718cce66e5651a0dae91375db6ebfaded1a92 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sat, 27 Apr 2019 21:33:41 -0400 Subject: [PATCH] Test unfold UV --- cMaterial.java | 476 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 238 insertions(+), 238 deletions(-) diff --git a/cMaterial.java b/cMaterial.java index 26d3ebe..14519fe 100644 --- a/cMaterial.java +++ b/cMaterial.java @@ -118,244 +118,244 @@ return current / anchor; } - void Draw(CameraPane display, boolean selected) - { - //new Exception().printStackTrace(); - - if (display.IsFrozen() && !selected || display.ambientOcclusion) // || display.drawMode == display.SHADOW) - { - return; - } - - javax.media.opengl.GL gl = display.GetGL(); - - //Color col = Color.getHSBColor(color,modulation,1); - //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); - if (!multiply) - { - display.color = color; - display.saturation = modulation; - } - else - { - display.color *= color*2; - display.saturation *= modulation*2; - } - - cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); - - float[] colorV = GraphreeD.colorV; - - /**/ - if (display.drawMode == display.DEFAULT) // && display.RENDERPROGRAM == 0) - { - colorV[0] = display.modelParams0[0] * diffuse; - colorV[1] = display.modelParams0[1] * diffuse; - colorV[2] = display.modelParams0[2] * diffuse; - colorV[3] = opacity; - - gl.glColor4f(colorV[0], colorV[1], colorV[2], opacity); - //System.out.println("Opacity = " + opacity); - - gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); - //color[0] /= 2; color[1] /= 2; color[2] /= 2; - gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); - - float amb = ambient; - if (amb < cameralight) - { - amb = cameralight; - } - colorV[0] = display.modelParams0[0] * diffuse * amb; - colorV[1] = display.modelParams0[1] * diffuse * amb; - colorV[2] = display.modelParams0[2] * diffuse * amb; - gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); - //color[0] /= 2; color[1] /= 2; color[2] /= 2; - gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); - - /**/ - colorV[0] = ((1 - metalness) + display.modelParams0[0] * metalness) * specular; - colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular; - colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * specular; - gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); - //color[0] /= 2; color[1] /= 2; color[2] /= 2; - gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); - colorV[0] = 10 / shininess; // 1/0.005f; - //System.out.println("shininess = " + colorV[0]); - if (colorV[0] > 128) - { - colorV[0] = 128; - } - gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); - gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); - /**/ - } - /**/ - - //selected = false; - selected = selected && display.flash; - - //display.modelParams0[0] = 0; // pigment.r; - //display.modelParams0[1] = 0; // pigment.g; - //display.modelParams0[2] = 0; // pigment.b; - if (!multiply) - { - display.modelParams0[3] = metalness; - display.modelParams1[0] = diffuse; - display.modelParams1[1] = specular; - display.modelParams1[2] = 1 / shininess; - display.modelParams1[3] = shift; - display.modelParams2[0] = ambient; - display.modelParams2[1] = lightarea; - //System.out.println("light area = " + lightarea); - display.modelParams2[2] = 1 / factor; // diffuseness - display.modelParams2[3] = velvet; - display.modelParams3[0] = sheen; - display.modelParams3[1] = subsurface; - display.modelParams3[2] = bump; // backlit - display.modelParams3[3] = aniso; - display.modelParams4[0] = anisoV; - display.modelParams4[1] = selected ? 100 : cameralight; - //System.out.println("selected = " + selected); - display.modelParams4[2] = diffuseness; - display.modelParams4[3] = shadow; - display.modelParams5[0] = texture; - display.modelParams5[1] = opacity; - display.modelParams5[2] = fakedepth; - display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10; - } - else - { - display.modelParams0[3] *= metalness*2; - display.modelParams1[0] *= diffuse*2; - display.modelParams1[1] *= specular*2; - display.modelParams1[2] *= shininess*2; - display.modelParams1[3] *= shift*2; - display.modelParams2[0] *= ambient*2; - display.modelParams2[1] *= lightarea*2; - display.modelParams2[2] *= factor*2; - display.modelParams2[3] *= velvet*2; - display.modelParams3[0] *= sheen*2; - display.modelParams3[1] *= subsurface*2; - display.modelParams3[2] *= bump*2; - display.modelParams3[3] *= aniso*2; - display.modelParams4[0] *= anisoV*2; - display.modelParams4[1] *= cameralight*2; - //System.out.println("selected = " + selected); - display.modelParams4[2] *= diffuseness*2; - display.modelParams4[3] *= shadow*2; - display.modelParams5[0] *= texture*2; - display.modelParams5[1] *= opacity*2; - display.modelParams5[2] *= fakedepth*2; - display.modelParams5[3] *= shadowbias*2; - } - - display.modelParams6[0] = 0; - display.modelParams6[1] = 0; - display.modelParams6[2] = 0; - display.modelParams6[3] = 0; - - display.modelParams7[0] = 0; - display.modelParams7[1] = 1000; - display.modelParams7[2] = 0; - display.modelParams7[3] = 0; - - display.modelParams6[0] = 100; // criss de bug de bump - - Object3D.cVector2[] extparams = display.vector2buffer; - if (extparams != null && extparams.length > 0 && extparams[0] != null) - { - display.modelParams6[0] = extparams[0].x / 1000.0f; // bump - display.modelParams6[1] = extparams[0].y / 1000.0f; // noise - if (extparams.length > 1) - { - display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade - display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough - if (extparams.length > 2) - { - display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power - float x = extparams[2].y / 1000.0f; - //if (x == 0) - // x = 1f; - display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power - if (extparams[2].y > 0) - { - //System.out.println("extparams[1].y = " + extparams[1].y); - //System.out.println("extparams[2].y = " + extparams[2].y); - //System.out.println("opacity power = " + display.modelParams7[1]); - } - } - } - } - - //if (display.modelParams6[2] != 0) - /* - System.out.println("modelParams0[0] = " + display.modelParams0[0]); - System.out.println("modelParams0[1] = " + display.modelParams0[1]); - System.out.println("modelParams0[2] = " + display.modelParams0[2]); - System.out.println("modelParams0[3] = " + display.modelParams0[3]); - System.out.println("modelParams1[0] = " + display.modelParams1[0]); - System.out.println("modelParams1[1] = " + display.modelParams1[1]); - System.out.println("modelParams1[2] = " + display.modelParams1[2]); - System.out.println("modelParams1[3] = " + display.modelParams1[3]); - System.out.println("modelParams2[0] = " + display.modelParams2[0]); - System.out.println("modelParams2[1] = " + display.modelParams2[1]); - System.out.println("modelParams2[2] = " + display.modelParams2[2]); - System.out.println("modelParams2[3] = " + display.modelParams2[3]); - System.out.println("modelParams3[0] = " + display.modelParams3[0]); - System.out.println("modelParams3[1] = " + display.modelParams3[1]); - System.out.println("modelParams3[2] = " + display.modelParams3[2]); - System.out.println("modelParams3[3] = " + display.modelParams3[3]); - System.out.println("modelParams4[0] = " + display.modelParams4[0]); - System.out.println("modelParams4[1] = " + display.modelParams4[1]); - System.out.println("modelParams4[2] = " + display.modelParams4[2]); - System.out.println("modelParams4[3] = " + display.modelParams4[3]); - System.out.println("modelParams5[0] = " + display.modelParams5[0]); - System.out.println("modelParams5[1] = " + display.modelParams5[1]); - System.out.println("modelParams5[2] = " + display.modelParams5[2]); - System.out.println("modelParams5[3] = " + display.modelParams5[3]); - System.out.println("modelParams6[0] = " + display.modelParams6[0]); - System.out.println("modelParams6[1] = " + display.modelParams6[1]); - System.out.println("modelParams6[2] = " + display.modelParams6[2]); - System.out.println("modelParams6[3] = " + display.modelParams6[3]); - System.out.println("modelParams7[0] = " + display.modelParams7[0]); - System.out.println("modelParams7[1] = " + display.modelParams7[1]); - System.out.println("modelParams7[2] = " + display.modelParams7[2]); - System.out.println("modelParams7[3] = " + display.modelParams7[3]); - /**/ - //assert (display.modelParams6[2] == 0); - - //System.out.println("noise power = " + display.modelParams7[0]); - //System.out.println("shadowbias = " + shadowbias); - - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); - - int mode = display.FP_SHADER; - - if (aniso != anisoV || aniso > 0.002) - { - mode |= display.FP_ANISO; - } - - display.EnableProgram(mode); - - //System.out.println("opacity power = " + display.modelParams7[1]); - - if (!multiply) - { - if (display.drawMode == CameraPane.SHADOW) - gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1); - else - gl.glDepthMask(opacity >= 0.99); - } - } +// void Draw(iCameraPane display, boolean selected) +// { +// //new Exception().printStackTrace(); +// +// if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) +// { +// return; +// } +// +// javax.media.opengl.GL gl = display.GetGL(); +// +// //Color col = Color.getHSBColor(color,modulation,1); +// //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); +// if (!multiply) +// { +// display.color = color; +// display.saturation = modulation; +// } +// else +// { +// display.color *= color*2; +// display.saturation *= modulation*2; +// } +// +// cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); +// +// float[] colorV = GrafreeD.colorV; +// +// /**/ +// if (display.drawMode == display.DEFAULT) // && display.RENDERPROGRAM == 0) +// { +// colorV[0] = display.modelParams0[0] * diffuse; +// colorV[1] = display.modelParams0[1] * diffuse; +// colorV[2] = display.modelParams0[2] * diffuse; +// colorV[3] = opacity; +// +// gl.glColor4f(colorV[0], colorV[1], colorV[2], opacity); +// //System.out.println("Opacity = " + opacity); +// +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); +// //color[0] /= 2; color[1] /= 2; color[2] /= 2; +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); +// +// float amb = ambient; +// if (amb < cameralight) +// { +// amb = cameralight; +// } +// colorV[0] = display.modelParams0[0] * diffuse * amb; +// colorV[1] = display.modelParams0[1] * diffuse * amb; +// colorV[2] = display.modelParams0[2] * diffuse * amb; +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); +// //color[0] /= 2; color[1] /= 2; color[2] /= 2; +// gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); +// +// /**/ +// colorV[0] = ((1 - metalness) + display.modelParams0[0] * metalness) * specular; +// colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular; +// colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * specular; +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); +// //color[0] /= 2; color[1] /= 2; color[2] /= 2; +// gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); +// colorV[0] = 10 / shininess; // 1/0.005f; +// //System.out.println("shininess = " + colorV[0]); +// if (colorV[0] > 128) +// { +// colorV[0] = 128; +// } +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); +// gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); +// /**/ +// } +// /**/ +// +// //selected = false; +// selected = selected && display.flash; +// +// //display.modelParams0[0] = 0; // pigment.r; +// //display.modelParams0[1] = 0; // pigment.g; +// //display.modelParams0[2] = 0; // pigment.b; +// if (!multiply) +// { +// display.modelParams0[3] = metalness; +// display.modelParams1[0] = diffuse; +// display.modelParams1[1] = specular; +// display.modelParams1[2] = 1 / shininess; +// display.modelParams1[3] = shift; +// display.modelParams2[0] = ambient; +// display.modelParams2[1] = lightarea; +// //System.out.println("light area = " + lightarea); +// display.modelParams2[2] = 1 / factor; // diffuseness +// display.modelParams2[3] = velvet; +// display.modelParams3[0] = sheen; +// display.modelParams3[1] = subsurface; +// display.modelParams3[2] = bump; // backlit +// display.modelParams3[3] = aniso; +// display.modelParams4[0] = anisoV; +// display.modelParams4[1] = selected ? 100 : cameralight; +// //System.out.println("selected = " + selected); +// display.modelParams4[2] = diffuseness; +// display.modelParams4[3] = shadow; +// display.modelParams5[0] = texture; +// display.modelParams5[1] = opacity; +// display.modelParams5[2] = fakedepth; +// display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10; +// } +// else +// { +// display.modelParams0[3] *= metalness*2; +// display.modelParams1[0] *= diffuse*2; +// display.modelParams1[1] *= specular*2; +// display.modelParams1[2] *= shininess*2; +// display.modelParams1[3] *= shift*2; +// display.modelParams2[0] *= ambient*2; +// display.modelParams2[1] *= lightarea*2; +// display.modelParams2[2] *= factor*2; +// display.modelParams2[3] *= velvet*2; +// display.modelParams3[0] *= sheen*2; +// display.modelParams3[1] *= subsurface*2; +// display.modelParams3[2] *= bump*2; +// display.modelParams3[3] *= aniso*2; +// display.modelParams4[0] *= anisoV*2; +// display.modelParams4[1] *= cameralight*2; +// //System.out.println("selected = " + selected); +// display.modelParams4[2] *= diffuseness*2; +// display.modelParams4[3] *= shadow*2; +// display.modelParams5[0] *= texture*2; +// display.modelParams5[1] *= opacity*2; +// display.modelParams5[2] *= fakedepth*2; +// display.modelParams5[3] *= shadowbias*2; +// } +// +// display.modelParams6[0] = 0; +// display.modelParams6[1] = 0; +// display.modelParams6[2] = 0; +// display.modelParams6[3] = 0; +// +// display.modelParams7[0] = 0; +// display.modelParams7[1] = 1000; +// display.modelParams7[2] = 0; +// display.modelParams7[3] = 0; +// +// display.modelParams6[0] = 100; // criss de bug de bump +// +// Object3D.cVector2[] extparams = display.vector2buffer; +// if (extparams != null && extparams.length > 0 && extparams[0] != null) +// { +// display.modelParams6[0] = extparams[0].x / 1000.0f; // bump +// display.modelParams6[1] = extparams[0].y / 1000.0f; // noise +// if (extparams.length > 1) +// { +// display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade +// display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough +// if (extparams.length > 2) +// { +// display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power +// float x = extparams[2].y / 1000.0f; +// //if (x == 0) +// // x = 1f; +// display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power +// if (extparams[2].y > 0) +// { +// //System.out.println("extparams[1].y = " + extparams[1].y); +// //System.out.println("extparams[2].y = " + extparams[2].y); +// //System.out.println("opacity power = " + display.modelParams7[1]); +// } +// } +// } +// } +// +// //if (display.modelParams6[2] != 0) +// /* +// System.out.println("modelParams0[0] = " + display.modelParams0[0]); +// System.out.println("modelParams0[1] = " + display.modelParams0[1]); +// System.out.println("modelParams0[2] = " + display.modelParams0[2]); +// System.out.println("modelParams0[3] = " + display.modelParams0[3]); +// System.out.println("modelParams1[0] = " + display.modelParams1[0]); +// System.out.println("modelParams1[1] = " + display.modelParams1[1]); +// System.out.println("modelParams1[2] = " + display.modelParams1[2]); +// System.out.println("modelParams1[3] = " + display.modelParams1[3]); +// System.out.println("modelParams2[0] = " + display.modelParams2[0]); +// System.out.println("modelParams2[1] = " + display.modelParams2[1]); +// System.out.println("modelParams2[2] = " + display.modelParams2[2]); +// System.out.println("modelParams2[3] = " + display.modelParams2[3]); +// System.out.println("modelParams3[0] = " + display.modelParams3[0]); +// System.out.println("modelParams3[1] = " + display.modelParams3[1]); +// System.out.println("modelParams3[2] = " + display.modelParams3[2]); +// System.out.println("modelParams3[3] = " + display.modelParams3[3]); +// System.out.println("modelParams4[0] = " + display.modelParams4[0]); +// System.out.println("modelParams4[1] = " + display.modelParams4[1]); +// System.out.println("modelParams4[2] = " + display.modelParams4[2]); +// System.out.println("modelParams4[3] = " + display.modelParams4[3]); +// System.out.println("modelParams5[0] = " + display.modelParams5[0]); +// System.out.println("modelParams5[1] = " + display.modelParams5[1]); +// System.out.println("modelParams5[2] = " + display.modelParams5[2]); +// System.out.println("modelParams5[3] = " + display.modelParams5[3]); +// System.out.println("modelParams6[0] = " + display.modelParams6[0]); +// System.out.println("modelParams6[1] = " + display.modelParams6[1]); +// System.out.println("modelParams6[2] = " + display.modelParams6[2]); +// System.out.println("modelParams6[3] = " + display.modelParams6[3]); +// System.out.println("modelParams7[0] = " + display.modelParams7[0]); +// System.out.println("modelParams7[1] = " + display.modelParams7[1]); +// System.out.println("modelParams7[2] = " + display.modelParams7[2]); +// System.out.println("modelParams7[3] = " + display.modelParams7[3]); +// /**/ +// //assert (display.modelParams6[2] == 0); +// +// //System.out.println("noise power = " + display.modelParams7[0]); +// //System.out.println("shadowbias = " + shadowbias); +// +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); +// +// int mode = display.FP_SHADER; +// +// if (aniso != anisoV || aniso > 0.002) +// { +// mode |= display.FP_ANISO; +// } +// +// display.EnableProgram(mode); +// +// //System.out.println("opacity power = " + display.modelParams7[1]); +// +// if (!multiply) +// { +// if (display.drawMode == CameraPane.SHADOW) +// gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1); +// else +// gl.glDepthMask(opacity >= 0.99); +// } +// } float color = 0.5f, modulation /*SATURATION*/ = 0.001f, metalness = 0.001f; float diffuse = 0.75f, specular = 0.25f, shininess = 0.75f, shift = 1; -- Gitblit v1.6.2