Updated glViewer and dxViewer for InfSharp patches

Both of these have been updated to expose toggles
to enable refinement and creation of infinitely
sharp patches.
This commit is contained in:
David G. Yu 2016-09-30 11:00:31 -07:00
parent 8257516427
commit c9a3bb4d87
4 changed files with 39 additions and 19 deletions

View File

@ -128,6 +128,7 @@ int g_freeze = 0,
g_adaptive = 1,
g_endCap = kEndCapBSplineBasis,
g_singleCreasePatch = 1,
g_infSharpPatch = 0,
g_drawNormals = 0,
g_mbutton[3] = {0, 0, 0};
@ -293,11 +294,13 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, int kernel, Scheme scheme=
// Adaptive refinement currently supported only for catmull-clark scheme
bool doAdaptive = (g_adaptive!=0 && g_scheme==kCatmark),
doSingleCreasePatch = (g_singleCreasePatch!=0 && g_scheme==kCatmark);
doSingleCreasePatch = (g_singleCreasePatch!=0 && g_scheme==kCatmark),
doInfSharpPatch = (g_infSharpPatch!=0 && g_scheme==kCatmark);
Osd::MeshBitset bits;
bits.set(Osd::MeshAdaptive, doAdaptive);
bits.set(Osd::MeshUseSingleCreasePatch, doSingleCreasePatch);
bits.set(Osd::MeshUseInfSharpPatch, doInfSharpPatch);
bits.set(Osd::MeshEndCapBSplineBasis, g_endCap == kEndCapBSplineBasis);
bits.set(Osd::MeshEndCapGregoryBasis, g_endCap == kEndCapGregoryBasis);
bits.set(Osd::MeshEndCapLegacyGregory, g_endCap == kEndCapLegacyGregory);
@ -1118,6 +1121,12 @@ callbackSingleCreasePatch(bool checked, int /* a */) {
rebuildOsdMesh();
}
static void
callbackInfSharpPatch(bool checked, int /* a */) {
g_infSharpPatch = checked;
rebuildOsdMesh();
}
static void
callbackCheckBox(bool checked, int button) {
switch (button) {
@ -1175,7 +1184,7 @@ initHUD() {
g_hud->AddPullDownButton(compute_pulldown, "HLSL Compute", kDirectCompute);
int displaystyle_pulldown = g_hud->AddPullDown("DisplayStyle (W)", 200, 10, 250,
callbackDisplayStyle, 'w');
callbackDisplayStyle, 'W');
g_hud->AddPullDownButton(displaystyle_pulldown, "Wire", kDisplayStyleWire,
g_displayStyle == kDisplayStyleWire);
g_hud->AddPullDownButton(displaystyle_pulldown, "Shaded", kDisplayStyleShaded,
@ -1184,7 +1193,7 @@ initHUD() {
g_displayStyle == kDisplayStyleWireOnShaded);
int shading_pulldown = g_hud->AddPullDown("Shading (C)", 200, 70, 250,
callbackShadingMode, 'c');
callbackShadingMode, 'C');
g_hud->AddPullDownButton(shading_pulldown, "Material",
kShadingMaterial,
g_shadingMode == kShadingMaterial);
@ -1225,11 +1234,12 @@ initHUD() {
10, y, callbackCheckBox, kHUD_CB_FREEZE, ' ');
y += 20;
g_hud->AddCheckBox("Adaptive (`)", true, 10, 230, callbackAdaptive, 0, '`');
g_hud->AddCheckBox("Single Crease Patch (S)", g_singleCreasePatch!=0, 10, 250, callbackSingleCreasePatch, 0, 'S');
g_hud->AddCheckBox("Adaptive (`)", true, 10, 190, callbackAdaptive, 0, '`');
g_hud->AddCheckBox("Single Crease Patch (S)", g_singleCreasePatch!=0, 10, 210, callbackSingleCreasePatch, 0, 'S');
g_hud->AddCheckBox("Inf Sharp Patch (I)", g_infSharpPatch!=0, 10, 230, callbackInfSharpPatch, 0, 'I');
int endcap_pulldown = g_hud->AddPullDown(
"End cap (E)", 10, 270, 200, callbackEndCap, 'E');
"End cap (E)", 10, 250, 200, callbackEndCap, 'E');
g_hud->AddPullDownButton(endcap_pulldown,"None",
kEndCapNone,
g_endCap == kEndCapNone);
@ -1249,7 +1259,7 @@ initHUD() {
g_hud->AddRadioButton(3, level, i==2, 10, 290+i*20, callbackLevel, i, '0'+(i%10));
}
int shapes_pulldown = g_hud->AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n');
int shapes_pulldown = g_hud->AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'N');
for (int i = 0; i < (int)g_defaultShapes.size(); ++i) {
g_hud->AddPullDownButton(shapes_pulldown, g_defaultShapes[i].name.c_str(),i);
}

View File

@ -374,11 +374,11 @@ getAdaptivePatchColor(int3 patchParam, float2 vSegments)
float4(0.0f, 0.8f, 0.75f, 1.0f), // boundary pattern 4
float4(0.0f, 1.0f, 0.0f, 1.0f), // corner
float4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 0
float4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 1
float4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 2
float4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 3
float4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 4
float4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 0
float4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 1
float4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 2
float4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 3
float4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 4
float4(1.0f, 1.0f, 0.0f, 1.0f), // gregory
float4(1.0f, 1.0f, 0.0f, 1.0f), // gregory

View File

@ -162,7 +162,8 @@ enum HudCheckBox { kHUD_CB_DISPLAY_CONTROL_MESH_EDGES,
kHUD_CB_FREEZE,
kHUD_CB_DISPLAY_PATCH_COUNTS,
kHUD_CB_ADAPTIVE,
kHUD_CB_SINGLE_CREASE_PATCH };
kHUD_CB_SINGLE_CREASE_PATCH,
kHUD_CB_INF_SHARP_PATCH };
int g_currentShape = 0;
@ -182,6 +183,7 @@ int g_fullscreen = 0,
g_adaptive = 1,
g_endCap = kEndCapBSplineBasis,
g_singleCreasePatch = 1,
g_infSharpPatch = 0,
g_mbutton[3] = {0, 0, 0},
g_running = 1;
@ -446,10 +448,12 @@ rebuildMesh() {
bool doAdaptive = (g_adaptive!=0 && scheme==kCatmark);
bool interleaveVarying = g_shadingMode == kShadingInterleavedVaryingColor;
bool doSingleCreasePatch = (g_singleCreasePatch!=0 && scheme==kCatmark);
bool doInfSharpPatch = (g_infSharpPatch!=0 && scheme==kCatmark);
Osd::MeshBitset bits;
bits.set(Osd::MeshAdaptive, doAdaptive);
bits.set(Osd::MeshUseSingleCreasePatch, doSingleCreasePatch);
bits.set(Osd::MeshUseInfSharpPatch, doInfSharpPatch);
bits.set(Osd::MeshInterleaveVarying, interleaveVarying);
bits.set(Osd::MeshFVarData, g_shadingMode == kShadingFaceVaryingColor);
bits.set(Osd::MeshEndCapBSplineBasis, g_endCap == kEndCapBSplineBasis);
@ -1402,6 +1406,10 @@ callbackCheckBox(bool checked, int button) {
g_singleCreasePatch = checked;
rebuildMesh();
return;
case kHUD_CB_INF_SHARP_PATCH:
g_infSharpPatch = checked;
rebuildMesh();
return;
default:
break;
}
@ -1535,9 +1543,11 @@ initHUD() {
10, 190, callbackCheckBox, kHUD_CB_ADAPTIVE, '`');
g_hud.AddCheckBox("Single Crease Patch (S)", g_singleCreasePatch!=0,
10, 210, callbackCheckBox, kHUD_CB_SINGLE_CREASE_PATCH, 's');
g_hud.AddCheckBox("Inf Sharp Patch (I)", g_infSharpPatch!=0,
10, 230, callbackCheckBox, kHUD_CB_INF_SHARP_PATCH, 'i');
int endcap_pulldown = g_hud.AddPullDown(
"End cap (E)", 10, 230, 200, callbackEndCap, 'e');
"End cap (E)", 10, 250, 200, callbackEndCap, 'e');
g_hud.AddPullDownButton(endcap_pulldown,"None",
kEndCapNone,
g_endCap == kEndCapNone);

View File

@ -418,11 +418,11 @@ getAdaptivePatchColor(ivec3 patchParam)
vec4(0.0f, 0.8f, 0.75f, 1.0f), // boundary pattern 4
vec4(0.0f, 1.0f, 0.0f, 1.0f), // corner
vec4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 0
vec4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 1
vec4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 2
vec4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 3
vec4(0.25f, 0.25f, 0.25f, 1.0f), // corner pattern 4
vec4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 0
vec4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 1
vec4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 2
vec4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 3
vec4(0.5f, 1.0f, 0.5f, 1.0f), // corner pattern 4
vec4(1.0f, 1.0f, 0.0f, 1.0f), // gregory
vec4(1.0f, 1.0f, 0.0f, 1.0f), // gregory