mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-08 13:30:04 +00:00
Updated GL examples for common command line arguments:
- updated all examples/gl* to make use of common/argOptions.h - implemented -yup where user-supplied geometry is imported - updated glPtexViewer to use ObjAnim class for animated geometry
This commit is contained in:
parent
eb72dc847b
commit
329fd509a1
@ -35,7 +35,7 @@ SYNOPSIS
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
:class: codefhead
|
:class: codefhead
|
||||||
|
|
||||||
**glEvalLimit** [**-f**] [**-u**] [**-a**] [**-l** *refinement level*]
|
**glEvalLimit** [**-f**] [**-yup**] [**-u**] [**-a**] [**-l** *refinement level*]
|
||||||
*objfile(s)* [**-catmark**] [**-loop**] [**-bilinear**]
|
*objfile(s)* [**-catmark**] [**-loop**] [**-bilinear**]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
|
@ -35,7 +35,7 @@ SYNOPSIS
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
:class: codefhead
|
:class: codefhead
|
||||||
|
|
||||||
**glPaintTest** [**-f**] [**-l** *adaptive refinement level*]
|
**glPaintTest** [**-f**] [**-yup**] [**-l** *adaptive refinement level*]
|
||||||
*objfile(s)* [**-catmark**] [**-loop**]
|
*objfile(s)* [**-catmark**] [**-loop**]
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ SYNOPSIS
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
:class: codefhead
|
:class: codefhead
|
||||||
|
|
||||||
**glPtexViewer** [**-f**] [**-u**] [**-a**] [**-l** *isolation level*] [**-c** *animation loops*] [**-y**]
|
**glPtexViewer** [**-f**] [**-yup**] [**-u**] [**-a**] [**-l** *isolation level*] [**-c** *animation loops*]
|
||||||
[**-e** *environment map*] [**-d** *HDR diffuse map*] [**-s** *HDR specular map*]
|
[**-e** *environment map*] [**-d** *HDR diffuse map*] [**-s** *HDR specular map*]
|
||||||
[**--disp** *displacement scale*] [**--bump** *bump scale*]
|
[**--disp** *displacement scale*] [**--bump** *bump scale*]
|
||||||
*ptex color file*
|
*ptex color file*
|
||||||
@ -63,9 +63,6 @@ See the description of the
|
|||||||
`common comand line options <code_examples.html#common-command-line-options>`__
|
`common comand line options <code_examples.html#common-command-line-options>`__
|
||||||
for the subset of common options supported here.
|
for the subset of common options supported here.
|
||||||
|
|
||||||
**-y**
|
|
||||||
Swap Z-up geometry to Y-UP.
|
|
||||||
|
|
||||||
**-e** *environment map*
|
**-e** *environment map*
|
||||||
A low dynamic range spherical environment map used as a background. Ideally,
|
A low dynamic range spherical environment map used as a background. Ideally,
|
||||||
a color-normalized version of the HDR light probe.
|
a color-normalized version of the HDR light probe.
|
||||||
|
@ -35,7 +35,7 @@ SYNOPSIS
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
:class: codefhead
|
:class: codefhead
|
||||||
|
|
||||||
**glStencilViewer** [**-f**] [**-u**] [**-a**] [**-l** *refinement level*]
|
**glStencilViewer** [**-f**] [**-yup**] [**-u**] [**-a**] [**-l** *refinement level*]
|
||||||
*objfile(s)* [**-catmark**] [**-loop**] [**-bilinear**]
|
*objfile(s)* [**-catmark**] [**-loop**] [**-bilinear**]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
|
@ -35,17 +35,13 @@ const ObjAnim *
|
|||||||
PopulateAnimShapes(const ArgOptions &args,
|
PopulateAnimShapes(const ArgOptions &args,
|
||||||
std::vector<ShapeDesc> *defaultShapes)
|
std::vector<ShapeDesc> *defaultShapes)
|
||||||
{
|
{
|
||||||
if (!defaultShapes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (args.GetObjFiles().empty())
|
if (args.GetObjFiles().empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
const ObjAnim *objAnim = ObjAnim::Create(args.GetObjFiles(),
|
const ObjAnim *objAnim = ObjAnim::Create(args.GetObjFiles(),
|
||||||
args.GetDefaultScheme());
|
args.GetDefaultScheme());
|
||||||
|
|
||||||
if (objAnim) {
|
if (objAnim && defaultShapes) {
|
||||||
defaultShapes->push_back(ShapeDesc(args.GetObjFiles()[0], "",
|
defaultShapes->push_back(ShapeDesc(args.GetObjFiles()[0], "",
|
||||||
args.GetDefaultScheme()));
|
args.GetDefaultScheme()));
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace ViewerArgsUtils {
|
|||||||
// defaultShapes vector, treating the objs as an animated series, returning
|
// defaultShapes vector, treating the objs as an animated series, returning
|
||||||
// an ObjAnim object.
|
// an ObjAnim object.
|
||||||
const ObjAnim *PopulateAnimShapes(const ArgOptions &args,
|
const ObjAnim *PopulateAnimShapes(const ArgOptions &args,
|
||||||
std::vector<ShapeDesc> *defaultShapes);
|
std::vector<ShapeDesc> *defaultShapes = 0);
|
||||||
|
|
||||||
// From the list of obj files in args, populates the
|
// From the list of obj files in args, populates the
|
||||||
// defaultShapes vector.
|
// defaultShapes vector.
|
||||||
|
@ -80,6 +80,8 @@ GLFWmonitor* g_primary=0;
|
|||||||
#include <opensubdiv/far/error.h>
|
#include <opensubdiv/far/error.h>
|
||||||
|
|
||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
|
#include "../common/argOptions.h"
|
||||||
|
#include "../common/viewerArgsUtils.h"
|
||||||
#include "../common/stopwatch.h"
|
#include "../common/stopwatch.h"
|
||||||
#include "../common/simple_math.h"
|
#include "../common/simple_math.h"
|
||||||
#include "../common/glControlMeshDisplay.h"
|
#include "../common/glControlMeshDisplay.h"
|
||||||
@ -106,7 +108,8 @@ enum KernelType { kCPU = 0,
|
|||||||
kGLXFB = 5,
|
kGLXFB = 5,
|
||||||
kGLCompute = 6 };
|
kGLCompute = 6 };
|
||||||
|
|
||||||
enum EndCap { kEndCapBSplineBasis,
|
enum EndCap { kEndCapBilinearBasis,
|
||||||
|
kEndCapBSplineBasis,
|
||||||
kEndCapGregoryBasis };
|
kEndCapGregoryBasis };
|
||||||
|
|
||||||
enum HudCheckBox { kHUD_CB_DISPLAY_CONTROL_MESH_EDGES,
|
enum HudCheckBox { kHUD_CB_DISPLAY_CONTROL_MESH_EDGES,
|
||||||
@ -116,6 +119,8 @@ enum HudCheckBox { kHUD_CB_DISPLAY_CONTROL_MESH_EDGES,
|
|||||||
kHUD_CB_RANDOM_START,
|
kHUD_CB_RANDOM_START,
|
||||||
kHUD_CB_FREEZE,
|
kHUD_CB_FREEZE,
|
||||||
kHUD_CB_ADAPTIVE,
|
kHUD_CB_ADAPTIVE,
|
||||||
|
kHUD_CB_SMOOTH_CORNER_PATCH,
|
||||||
|
kHUD_CB_SINGLE_CREASE_PATCH,
|
||||||
kHUD_CB_INF_SHARP_PATCH };
|
kHUD_CB_INF_SHARP_PATCH };
|
||||||
|
|
||||||
enum DrawMode { kUV,
|
enum DrawMode { kUV,
|
||||||
@ -134,6 +139,8 @@ int g_currentShape = 0,
|
|||||||
g_level = 2,
|
g_level = 2,
|
||||||
g_kernel = kCPU,
|
g_kernel = kCPU,
|
||||||
g_endCap = kEndCapGregoryBasis,
|
g_endCap = kEndCapGregoryBasis,
|
||||||
|
g_smoothCornerPatch = 0,
|
||||||
|
g_singleCreasePatch = 0,
|
||||||
g_infSharpPatch = 0,
|
g_infSharpPatch = 0,
|
||||||
g_numElements = 3;
|
g_numElements = 3;
|
||||||
|
|
||||||
@ -156,6 +163,8 @@ float g_rotate[2] = {0, 0},
|
|||||||
g_size = 0,
|
g_size = 0,
|
||||||
g_moveScale = 0.0f;
|
g_moveScale = 0.0f;
|
||||||
|
|
||||||
|
bool g_yup = false;
|
||||||
|
|
||||||
GLuint g_transformUB = 0,
|
GLuint g_transformUB = 0,
|
||||||
g_transformBinding = 0;
|
g_transformBinding = 0;
|
||||||
|
|
||||||
@ -658,14 +667,13 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level) {
|
|||||||
bool hasFVarData = !shape->uvs.empty();
|
bool hasFVarData = !shape->uvs.empty();
|
||||||
|
|
||||||
{
|
{
|
||||||
bool doInfSharpPatch = (g_infSharpPatch!=0 && g_adaptive);
|
|
||||||
|
|
||||||
if (g_adaptive) {
|
if (g_adaptive) {
|
||||||
// Apply feature adaptive refinement to the mesh so that we can use the
|
// Apply feature adaptive refinement to the mesh so that we can use the
|
||||||
// limit evaluation API features.
|
// limit evaluation API features.
|
||||||
Far::TopologyRefiner::AdaptiveOptions options(level);
|
Far::TopologyRefiner::AdaptiveOptions options(level);
|
||||||
options.considerFVarChannels = hasFVarData;
|
options.considerFVarChannels = hasFVarData;
|
||||||
options.useInfSharpPatch = doInfSharpPatch;
|
options.useSingleCreasePatch = g_singleCreasePatch;
|
||||||
|
options.useInfSharpPatch = g_infSharpPatch;
|
||||||
topologyRefiner->RefineAdaptive(options);
|
topologyRefiner->RefineAdaptive(options);
|
||||||
} else {
|
} else {
|
||||||
Far::TopologyRefiner::UniformOptions options(level);
|
Far::TopologyRefiner::UniformOptions options(level);
|
||||||
@ -695,14 +703,19 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level) {
|
|||||||
|
|
||||||
// Generate bi-cubic patch table for the limit surface
|
// Generate bi-cubic patch table for the limit surface
|
||||||
Far::PatchTableFactory::Options poptions(level);
|
Far::PatchTableFactory::Options poptions(level);
|
||||||
if (g_endCap == kEndCapBSplineBasis) {
|
if (g_endCap == kEndCapBilinearBasis) {
|
||||||
|
poptions.SetEndCapType(
|
||||||
|
Far::PatchTableFactory::Options::ENDCAP_BILINEAR_BASIS);
|
||||||
|
} else if (g_endCap == kEndCapBSplineBasis) {
|
||||||
poptions.SetEndCapType(
|
poptions.SetEndCapType(
|
||||||
Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS);
|
Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS);
|
||||||
} else {
|
} else {
|
||||||
poptions.SetEndCapType(
|
poptions.SetEndCapType(
|
||||||
Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS);
|
Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS);
|
||||||
}
|
}
|
||||||
poptions.useInfSharpPatch = doInfSharpPatch;
|
poptions.generateLegacySharpCornerPatches = !g_smoothCornerPatch;
|
||||||
|
poptions.useSingleCreasePatch = g_singleCreasePatch;
|
||||||
|
poptions.useInfSharpPatch = g_infSharpPatch;
|
||||||
poptions.generateFVarTables = hasFVarData;
|
poptions.generateFVarTables = hasFVarData;
|
||||||
poptions.generateFVarLegacyLinearPatches = false;
|
poptions.generateFVarLegacyLinearPatches = false;
|
||||||
poptions.includeFVarBaseLevelIndices = true;;
|
poptions.includeFVarBaseLevelIndices = true;;
|
||||||
@ -1053,7 +1066,9 @@ display() {
|
|||||||
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
if (!g_yup) {
|
||||||
|
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
||||||
|
}
|
||||||
translate(g_transformData.ModelViewMatrix,
|
translate(g_transformData.ModelViewMatrix,
|
||||||
-g_center[0], -g_center[1], -g_center[2]);
|
-g_center[0], -g_center[1], -g_center[2]);
|
||||||
perspective(g_transformData.ProjectionMatrix,
|
perspective(g_transformData.ProjectionMatrix,
|
||||||
@ -1314,6 +1329,14 @@ callbackCheckBox(bool checked, int button) {
|
|||||||
g_adaptive = checked;
|
g_adaptive = checked;
|
||||||
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
||||||
break;
|
break;
|
||||||
|
case kHUD_CB_SMOOTH_CORNER_PATCH:
|
||||||
|
g_smoothCornerPatch = checked;
|
||||||
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
||||||
|
return;
|
||||||
|
case kHUD_CB_SINGLE_CREASE_PATCH:
|
||||||
|
g_singleCreasePatch = checked;
|
||||||
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
||||||
|
return;
|
||||||
case kHUD_CB_INF_SHARP_PATCH:
|
case kHUD_CB_INF_SHARP_PATCH:
|
||||||
g_infSharpPatch = checked;
|
g_infSharpPatch = checked;
|
||||||
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
||||||
@ -1377,18 +1400,6 @@ initHUD() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_hud.AddCheckBox("Inf Sharp Patch (I)", g_infSharpPatch!=0,
|
|
||||||
10, 130, callbackCheckBox, kHUD_CB_INF_SHARP_PATCH, 'i');
|
|
||||||
|
|
||||||
int endcap_pulldown = g_hud.AddPullDown("End cap (E)", 10, 150, 200,
|
|
||||||
callbackEndCap, 'e');
|
|
||||||
g_hud.AddPullDownButton(endcap_pulldown, "Regular",
|
|
||||||
kEndCapBSplineBasis,
|
|
||||||
g_endCap == kEndCapBSplineBasis);
|
|
||||||
g_hud.AddPullDownButton(endcap_pulldown, "Gregory",
|
|
||||||
kEndCapGregoryBasis,
|
|
||||||
g_endCap == kEndCapGregoryBasis);
|
|
||||||
|
|
||||||
int shading_pulldown = g_hud.AddPullDown("Shading (W)", 250, 10, 250, callbackDisplayVaryingColors, 'w');
|
int shading_pulldown = g_hud.AddPullDown("Shading (W)", 250, 10, 250, callbackDisplayVaryingColors, 'w');
|
||||||
g_hud.AddPullDownButton(shading_pulldown, "(u,v)", kUV, g_drawMode==kUV);
|
g_hud.AddPullDownButton(shading_pulldown, "(u,v)", kUV, g_drawMode==kUV);
|
||||||
g_hud.AddPullDownButton(shading_pulldown, "Varying", kVARYING, g_drawMode==kVARYING);
|
g_hud.AddPullDownButton(shading_pulldown, "Varying", kVARYING, g_drawMode==kVARYING);
|
||||||
@ -1397,12 +1408,28 @@ initHUD() {
|
|||||||
g_hud.AddPullDownButton(shading_pulldown, "FaceVarying", kFACEVARYING, g_drawMode==kFACEVARYING);
|
g_hud.AddPullDownButton(shading_pulldown, "FaceVarying", kFACEVARYING, g_drawMode==kFACEVARYING);
|
||||||
g_hud.AddPullDownButton(shading_pulldown, "Mean Curvature", kMEAN_CURVATURE, g_drawMode==kMEAN_CURVATURE);
|
g_hud.AddPullDownButton(shading_pulldown, "Mean Curvature", kMEAN_CURVATURE, g_drawMode==kMEAN_CURVATURE);
|
||||||
|
|
||||||
g_hud.AddCheckBox("Adaptive (`)", g_adaptive != 0, 10, 190, callbackCheckBox, kHUD_CB_ADAPTIVE, '`');
|
g_hud.AddCheckBox("Adaptive (`)", g_adaptive != 0, 10, 150, callbackCheckBox, kHUD_CB_ADAPTIVE, '`');
|
||||||
|
|
||||||
|
g_hud.AddCheckBox("Smooth Corner Patch (O)", g_smoothCornerPatch!=0,
|
||||||
|
10, 170, callbackCheckBox, kHUD_CB_SMOOTH_CORNER_PATCH, 'o');
|
||||||
|
// g_hud.AddCheckBox("Single Crease Patch (S)", g_singleCreasePatch!=0,
|
||||||
|
// 10, 190, callbackCheckBox, kHUD_CB_SINGLE_CREASE_PATCH, 's');
|
||||||
|
g_hud.AddCheckBox("Inf Sharp Patch (I)", g_infSharpPatch!=0,
|
||||||
|
10, 190, callbackCheckBox, kHUD_CB_INF_SHARP_PATCH, 'i');
|
||||||
|
|
||||||
|
int endcap_pulldown = g_hud.AddPullDown("End cap (E)", 10, 230, 200,
|
||||||
|
callbackEndCap, 'e');
|
||||||
|
g_hud.AddPullDownButton(endcap_pulldown, "Linear", kEndCapBilinearBasis,
|
||||||
|
g_endCap == kEndCapBilinearBasis);
|
||||||
|
g_hud.AddPullDownButton(endcap_pulldown, "Regular", kEndCapBSplineBasis,
|
||||||
|
g_endCap == kEndCapBSplineBasis);
|
||||||
|
g_hud.AddPullDownButton(endcap_pulldown, "Gregory", kEndCapGregoryBasis,
|
||||||
|
g_endCap == kEndCapGregoryBasis);
|
||||||
|
|
||||||
for (int i = 1; i < 11; ++i) {
|
for (int i = 1; i < 11; ++i) {
|
||||||
char level[16];
|
char level[16];
|
||||||
sprintf(level, "Lv. %d", i);
|
sprintf(level, "Lv. %d", i);
|
||||||
g_hud.AddRadioButton(3, level, i==g_level, 10, 210+i*20, callbackLevel, i, '0'+(i%10));
|
g_hud.AddRadioButton(3, level, i==g_level, 10, 270+i*20, callbackLevel, i, '0'+(i%10));
|
||||||
}
|
}
|
||||||
|
|
||||||
int pulldown_handle = g_hud.AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n');
|
int pulldown_handle = g_hud.AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n');
|
||||||
@ -1440,48 +1467,22 @@ callbackErrorGLFW(int error, const char* description) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
bool fullscreen = false;
|
ArgOptions args;
|
||||||
Scheme defaultScheme = kCatmark;
|
|
||||||
std::vector<char const *> objfiles;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
args.Parse(argc, argv);
|
||||||
if (strstr(argv[i], ".obj")) {
|
args.PrintUnrecognizedArgsWarnings();
|
||||||
objfiles.push_back(argv[i]);
|
|
||||||
} else if (!strcmp(argv[i], "-a")) {
|
|
||||||
g_adaptive = true;
|
|
||||||
} else if (!strcmp(argv[i], "-u")) {
|
|
||||||
g_adaptive = false;
|
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
|
||||||
if (++i < argc) g_level = atoi(argv[i]);
|
|
||||||
} else if (!strcmp(argv[i], "-f")) {
|
|
||||||
fullscreen = true;
|
|
||||||
} else if (!strcmp(argv[i], "-bilinear")) {
|
|
||||||
defaultScheme = kBilinear;
|
|
||||||
} else if (!strcmp(argv[i], "-catmark")) {
|
|
||||||
defaultScheme = kCatmark;
|
|
||||||
} else if (!strcmp(argv[i], "-loop")) {
|
|
||||||
defaultScheme = kLoop;
|
|
||||||
} else {
|
|
||||||
printf("Warning: unrecognized argument '%s' ignored\n", argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < (int)objfiles.size(); ++i) {
|
|
||||||
std::ifstream ifs(objfiles[i]);
|
|
||||||
if (ifs) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << ifs.rdbuf();
|
|
||||||
ifs.close();
|
|
||||||
std::string str = ss.str();
|
|
||||||
g_defaultShapes.push_back(ShapeDesc(objfiles[i], str.c_str(), defaultScheme));
|
|
||||||
} else {
|
|
||||||
printf("Warning: cannot open shape file '%s'\n", objfiles[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Far::SetErrorCallback(callbackError);
|
g_yup = args.GetYUp();
|
||||||
|
g_adaptive = args.GetAdaptive();
|
||||||
|
g_level = args.GetLevel();
|
||||||
|
g_repeatCount = args.GetRepeatCount();
|
||||||
|
|
||||||
|
ViewerArgsUtils::PopulateShapes(args, &g_defaultShapes);
|
||||||
|
|
||||||
initShapes();
|
initShapes();
|
||||||
|
|
||||||
|
Far::SetErrorCallback(callbackError);
|
||||||
|
|
||||||
glfwSetErrorCallback(callbackErrorGLFW);
|
glfwSetErrorCallback(callbackErrorGLFW);
|
||||||
if (! glfwInit()) {
|
if (! glfwInit()) {
|
||||||
printf("Failed to initialize GLFW\n");
|
printf("Failed to initialize GLFW\n");
|
||||||
@ -1492,7 +1493,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
GLUtils::SetMinimumGLVersion();
|
GLUtils::SetMinimumGLVersion();
|
||||||
|
|
||||||
if (fullscreen) {
|
if (args.GetFullScreen()) {
|
||||||
|
|
||||||
g_primary = glfwGetPrimaryMonitor();
|
g_primary = glfwGetPrimaryMonitor();
|
||||||
|
|
||||||
@ -1514,7 +1515,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
||||||
fullscreen && g_primary ? g_primary : NULL, NULL))) {
|
args.GetFullScreen() && g_primary ? g_primary : NULL, NULL))) {
|
||||||
std::cerr << "Failed to create OpenGL context.\n";
|
std::cerr << "Failed to create OpenGL context.\n";
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
#include <opensubdiv/osd/glMesh.h>
|
#include <opensubdiv/osd/glMesh.h>
|
||||||
|
|
||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
|
#include "../common/argOptions.h"
|
||||||
#include "../common/patchColors.h"
|
#include "../common/patchColors.h"
|
||||||
#include "../common/stb_image_write.h" // common.obj has an implementation.
|
#include "../common/stb_image_write.h" // common.obj has an implementation.
|
||||||
#include "../common/glShaderCache.h"
|
#include "../common/glShaderCache.h"
|
||||||
@ -459,7 +460,7 @@ void runTest(ShapeDesc const &shapeDesc, std::string const &kernel,
|
|||||||
|
|
||||||
static void usage(const char *program) {
|
static void usage(const char *program) {
|
||||||
std::cout
|
std::cout
|
||||||
<< "Usage %s : " << program << "\n"
|
<< "Usage: " << program << "\n"
|
||||||
<< " -a : adaptive refinement (default)\n"
|
<< " -a : adaptive refinement (default)\n"
|
||||||
<< " -u : uniform refinement\n"
|
<< " -u : uniform refinement\n"
|
||||||
<< " -l <isolation level> : isolation level (default = 2)\n"
|
<< " -l <isolation level> : isolation level (default = 2)\n"
|
||||||
@ -485,30 +486,34 @@ int main(int argc, char ** argv) {
|
|||||||
std::string displayMode = "PATCH_TYPE";
|
std::string displayMode = "PATCH_TYPE";
|
||||||
std::vector<std::string> kernels;
|
std::vector<std::string> kernels;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
ArgOptions args;
|
||||||
if (!strcmp(argv[i], "-a")) {
|
|
||||||
adaptive = true;
|
args.Parse(argc, argv);
|
||||||
} else if (!strcmp(argv[i], "-u")) {
|
|
||||||
adaptive = false;
|
adaptive = args.GetAdaptive();
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
isolationLevel = args.GetLevel();
|
||||||
isolationLevel = atoi(argv[++i]);
|
|
||||||
} else if (!strcmp(argv[i], "-k")) {
|
// Parse remaining args
|
||||||
std::stringstream ss(argv[++i]);
|
const std::vector<const char *> &argvRem = args.GetRemainingArgs();
|
||||||
|
for (size_t i = 0; i < argvRem.size(); ++i) {
|
||||||
|
if (!strcmp(argvRem[i], "-k")) {
|
||||||
|
std::stringstream ss(argvRem[++i]);
|
||||||
std::string kernel;
|
std::string kernel;
|
||||||
while(std::getline(ss, kernel, ',')) {
|
while(std::getline(ss, kernel, ',')) {
|
||||||
kernels.push_back(kernel);
|
kernels.push_back(kernel);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(argv[i], "-t")) {
|
} else if (!strcmp(argvRem[i], "-t")) {
|
||||||
tessLevel = atoi(argv[++i]);
|
tessLevel = atoi(argvRem[++i]);
|
||||||
} else if (!strcmp(argv[i], "-w")) {
|
} else if (!strcmp(argvRem[i], "-w")) {
|
||||||
writeToFile = true;
|
writeToFile = true;
|
||||||
prefix = argv[++i];
|
prefix = argvRem[++i];
|
||||||
} else if (!strcmp(argv[i], "-s")) {
|
} else if (!strcmp(argvRem[i], "-s")) {
|
||||||
width = atoi(argv[++i]);
|
width = atoi(argvRem[++i]);
|
||||||
height = atoi(argv[++i]);
|
height = atoi(argvRem[++i]);
|
||||||
} else if (!strcmp(argv[i], "-d")) {
|
} else if (!strcmp(argvRem[i], "-d")) {
|
||||||
displayMode = argv[++i];
|
displayMode = argvRem[++i];
|
||||||
} else {
|
} else {
|
||||||
|
args.PrintUnrecognizedArgWarning(argvRem[i]);
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ GLFWmonitor* g_primary=0;
|
|||||||
OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||||
|
|
||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
|
#include "../common/argOptions.h"
|
||||||
|
#include "../common/viewerArgsUtils.h"
|
||||||
#include "../common/stopwatch.h"
|
#include "../common/stopwatch.h"
|
||||||
#include "../common/simple_math.h"
|
#include "../common/simple_math.h"
|
||||||
#include "../common/glHud.h"
|
#include "../common/glHud.h"
|
||||||
@ -64,6 +66,8 @@ float g_rotate[2] = {0, 0},
|
|||||||
g_center[3] = {0, 0, 0},
|
g_center[3] = {0, 0, 0},
|
||||||
g_size = 0;
|
g_size = 0;
|
||||||
|
|
||||||
|
bool g_yup = false;
|
||||||
|
|
||||||
int g_prev_x = 0,
|
int g_prev_x = 0,
|
||||||
g_prev_y = 0;
|
g_prev_y = 0;
|
||||||
|
|
||||||
@ -114,16 +118,6 @@ GLuint g_ptexPages = 0,
|
|||||||
|
|
||||||
int g_pageSize = 512;
|
int g_pageSize = 512;
|
||||||
|
|
||||||
struct SimpleShape {
|
|
||||||
std::string name;
|
|
||||||
Scheme scheme;
|
|
||||||
std::string data;
|
|
||||||
|
|
||||||
SimpleShape() { }
|
|
||||||
SimpleShape( std::string const & idata, char const * iname, Scheme ischeme )
|
|
||||||
: name(iname), scheme(ischeme), data(idata) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
int g_currentShape = 0;
|
int g_currentShape = 0;
|
||||||
|
|
||||||
#define NUM_FPS_TIME_SAMPLES 6
|
#define NUM_FPS_TIME_SAMPLES 6
|
||||||
@ -628,7 +622,9 @@ display() {
|
|||||||
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
if (!g_yup) {
|
||||||
|
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
||||||
|
}
|
||||||
translate(g_transformData.ModelViewMatrix,
|
translate(g_transformData.ModelViewMatrix,
|
||||||
-g_center[0], -g_center[1], -g_center[2]);
|
-g_center[0], -g_center[1], -g_center[2]);
|
||||||
perspective(g_transformData.ProjectionMatrix,
|
perspective(g_transformData.ProjectionMatrix,
|
||||||
@ -1082,41 +1078,18 @@ callbackErrorGLFW(int error, const char* description) {
|
|||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
|
||||||
bool fullscreen = false;
|
ArgOptions args;
|
||||||
Scheme defaultScheme = kCatmark;
|
|
||||||
std::vector<char const *> objfiles;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
args.Parse(argc, argv);
|
||||||
if (strstr(argv[i], ".obj")) {
|
args.PrintUnrecognizedArgsWarnings();
|
||||||
objfiles.push_back(argv[i]);
|
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
g_yup = args.GetYUp();
|
||||||
g_level = atoi(argv[++i]);
|
g_level = args.GetLevel();
|
||||||
} else if (!strcmp(argv[i], "-f")) {
|
|
||||||
fullscreen = true;
|
ViewerArgsUtils::PopulateShapes(args, &g_defaultShapes);
|
||||||
} else if (!strcmp(argv[i], "-catmark")) {
|
|
||||||
defaultScheme = kCatmark;
|
|
||||||
} else if (!strcmp(argv[i], "-loop")) {
|
|
||||||
defaultScheme = kLoop;
|
|
||||||
} else if (!strcmp(argv[i], "-bilinear")) {
|
|
||||||
printf("Warning: -bilinear ignored, Bilinear shapes not supported\n");
|
|
||||||
} else {
|
|
||||||
printf("Warning: unrecognized argument '%s' ignored\n", argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < (int)objfiles.size(); ++i) {
|
|
||||||
std::ifstream ifs(objfiles[i]);
|
|
||||||
if (ifs) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << ifs.rdbuf();
|
|
||||||
ifs.close();
|
|
||||||
std::string str = ss.str();
|
|
||||||
g_defaultShapes.push_back(ShapeDesc(objfiles[i], str.c_str(), defaultScheme));
|
|
||||||
} else {
|
|
||||||
printf("Warning: cannot open shape file '%s'\n", objfiles[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initShapes();
|
initShapes();
|
||||||
|
|
||||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||||
|
|
||||||
glfwSetErrorCallback(callbackErrorGLFW);
|
glfwSetErrorCallback(callbackErrorGLFW);
|
||||||
@ -1129,7 +1102,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
GLUtils::SetMinimumGLVersion();
|
GLUtils::SetMinimumGLVersion();
|
||||||
|
|
||||||
if (fullscreen) {
|
if (args.GetFullScreen()) {
|
||||||
|
|
||||||
g_primary = glfwGetPrimaryMonitor();
|
g_primary = glfwGetPrimaryMonitor();
|
||||||
|
|
||||||
@ -1151,7 +1124,7 @@ int main(int argc, char ** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
||||||
fullscreen && g_primary ? g_primary : NULL, NULL))) {
|
args.GetFullScreen() && g_primary ? g_primary : NULL, NULL))) {
|
||||||
printf("Failed to open window.\n");
|
printf("Failed to open window.\n");
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -93,6 +93,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
|||||||
#include "PtexUtils.h"
|
#include "PtexUtils.h"
|
||||||
|
|
||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
|
#include "../common/argOptions.h"
|
||||||
|
#include "../common/objAnim.h"
|
||||||
#include "../common/stopwatch.h"
|
#include "../common/stopwatch.h"
|
||||||
#include "../common/simple_math.h"
|
#include "../common/simple_math.h"
|
||||||
#include "../common/glControlMeshDisplay.h"
|
#include "../common/glControlMeshDisplay.h"
|
||||||
@ -244,7 +246,7 @@ float g_animTime = 0;
|
|||||||
std::vector<float> g_positions,
|
std::vector<float> g_positions,
|
||||||
g_normals;
|
g_normals;
|
||||||
|
|
||||||
std::vector<std::vector<float> > g_animPositions;
|
ObjAnim const * g_objAnim = 0;
|
||||||
|
|
||||||
GLuint g_queries[2] = {0, 0};
|
GLuint g_queries[2] = {0, 0};
|
||||||
GLuint g_vao = 0;
|
GLuint g_vao = 0;
|
||||||
@ -346,23 +348,13 @@ updateGeom() {
|
|||||||
|
|
||||||
int nverts = (int)g_positions.size() / 3;
|
int nverts = (int)g_positions.size() / 3;
|
||||||
|
|
||||||
if (g_moveScale && g_adaptive && !g_animPositions.empty()) {
|
if (g_moveScale && g_adaptive && g_objAnim) {
|
||||||
// baked animation only works with adaptive for now
|
|
||||||
// (since non-adaptive requires normals)
|
|
||||||
int nkey = (int)g_animPositions.size();
|
|
||||||
const float fps = 24.0f;
|
|
||||||
|
|
||||||
float p = fmodf(g_animTime * fps, (float)nkey);
|
|
||||||
int key = (int)p;
|
|
||||||
float b = p - key;
|
|
||||||
|
|
||||||
std::vector<float> vertex;
|
std::vector<float> vertex;
|
||||||
vertex.reserve(nverts*3);
|
vertex.reserve(nverts*3);
|
||||||
for (int i = 0; i < nverts*3; ++i) {
|
|
||||||
float p0 = g_animPositions[key][i];
|
g_objAnim->InterpolatePositions(g_animTime, &vertex[0], 3);
|
||||||
float p1 = g_animPositions[(key+1)%nkey][i];
|
|
||||||
vertex.push_back(p0*(1-b) + p1*b);
|
|
||||||
}
|
|
||||||
g_mesh->UpdateVertexBuffer(&vertex[0], 0, nverts);
|
g_mesh->UpdateVertexBuffer(&vertex[0], 0, nverts);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1117,8 +1109,9 @@ updateConstantUniformBlock() {
|
|||||||
translate(constantData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
translate(constantData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
||||||
rotate(constantData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
rotate(constantData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
||||||
rotate(constantData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
rotate(constantData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
||||||
if (g_yup)
|
if (!g_yup) {
|
||||||
rotate(constantData.ModelViewMatrix, -90, 1, 0, 0);
|
rotate(constantData.ModelViewMatrix, -90, 1, 0, 0);
|
||||||
|
}
|
||||||
translate(constantData.ModelViewMatrix, -g_center[0], -g_center[1], -g_center[2]);
|
translate(constantData.ModelViewMatrix, -g_center[0], -g_center[1], -g_center[2]);
|
||||||
perspective(constantData.ProjectionMatrix, 45.0f, (float)aspect, g_size*0.001f,
|
perspective(constantData.ProjectionMatrix, 45.0f, (float)aspect, g_size*0.001f,
|
||||||
g_size+g_dolly);
|
g_size+g_dolly);
|
||||||
@ -1708,7 +1701,7 @@ void usage(const char *program) {
|
|||||||
printf(" -d <diffseEnvMap.hdr> : diffuse environment map for IBL\n");
|
printf(" -d <diffseEnvMap.hdr> : diffuse environment map for IBL\n");
|
||||||
printf(" -e <specularEnvMap.hdr> : specular environment map for IBL\n");
|
printf(" -e <specularEnvMap.hdr> : specular environment map for IBL\n");
|
||||||
printf(" -s <shaderfile.glsl> : custom shader file\n");
|
printf(" -s <shaderfile.glsl> : custom shader file\n");
|
||||||
printf(" -y : Y-up model\n");
|
printf(" -yup : Y-up model\n");
|
||||||
printf(" -m level : max mipmap level (default=10)\n");
|
printf(" -m level : max mipmap level (default=10)\n");
|
||||||
printf(" -x <ptex limit MB> : ptex target memory size\n");
|
printf(" -x <ptex limit MB> : ptex target memory size\n");
|
||||||
printf(" --disp <scale> : Displacement scale\n");
|
printf(" --disp <scale> : Displacement scale\n");
|
||||||
@ -1730,55 +1723,53 @@ callbackErrorGLFW(int error, const char* description) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
|
||||||
std::vector<std::string> animobjs;
|
ArgOptions args;
|
||||||
|
args.Parse(argc, argv);
|
||||||
|
|
||||||
|
const std::vector<const char *> &animobjs = args.GetObjFiles();
|
||||||
|
bool fullscreen = args.GetFullScreen();
|
||||||
|
|
||||||
|
g_yup = args.GetYUp();
|
||||||
|
g_adaptive = args.GetAdaptive();
|
||||||
|
g_level = args.GetLevel();
|
||||||
|
g_repeatCount = args.GetRepeatCount();
|
||||||
|
|
||||||
|
// Retrieve and parse remaining args:
|
||||||
|
const std::vector<const char *> &argvRem = args.GetRemainingArgs();
|
||||||
|
|
||||||
const char *diffuseEnvironmentMap = NULL, *specularEnvironmentMap = NULL;
|
const char *diffuseEnvironmentMap = NULL, *specularEnvironmentMap = NULL;
|
||||||
const char *colorFilename = NULL, *displacementFilename = NULL,
|
const char *colorFilename = NULL, *displacementFilename = NULL,
|
||||||
*occlusionFilename = NULL, *specularFilename = NULL;
|
*occlusionFilename = NULL, *specularFilename = NULL;
|
||||||
int memLimit = 0, colorMem = 0, displacementMem = 0,
|
int memLimit = 0, colorMem = 0, displacementMem = 0,
|
||||||
occlusionMem = 0, specularMem = 0;
|
occlusionMem = 0, specularMem = 0;
|
||||||
bool fullscreen = false;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (size_t i = 0; i < argvRem.size(); ++i) {
|
||||||
if (strstr(argv[i], ".obj"))
|
if (!strcmp(argvRem[i], "-d"))
|
||||||
animobjs.push_back(argv[i]);
|
diffuseEnvironmentMap = argvRem[++i];
|
||||||
else if (!strcmp(argv[i], "-a"))
|
else if (!strcmp(argvRem[i], "-e"))
|
||||||
g_adaptive = true;
|
specularEnvironmentMap = argvRem[++i];
|
||||||
else if (!strcmp(argv[i], "-u"))
|
else if (!strcmp(argvRem[i], "-s"))
|
||||||
g_adaptive = false;
|
g_shaderFilename = argvRem[++i];
|
||||||
else if (!strcmp(argv[i], "-l"))
|
else if (!strcmp(argvRem[i], "-m"))
|
||||||
g_level = atoi(argv[++i]);
|
g_maxMipmapLevels = atoi(argvRem[++i]);
|
||||||
else if (!strcmp(argv[i], "-c"))
|
else if (!strcmp(argvRem[i], "-x"))
|
||||||
g_repeatCount = atoi(argv[++i]);
|
memLimit = atoi(argvRem[++i]);
|
||||||
else if (!strcmp(argv[i], "-d"))
|
else if (!strcmp(argvRem[i], "--disp"))
|
||||||
diffuseEnvironmentMap = argv[++i];
|
g_displacementScale = (float)atof(argvRem[++i]);
|
||||||
else if (!strcmp(argv[i], "-e"))
|
|
||||||
specularEnvironmentMap = argv[++i];
|
|
||||||
else if (!strcmp(argv[i], "-s"))
|
|
||||||
g_shaderFilename = argv[++i];
|
|
||||||
else if (!strcmp(argv[i], "-f"))
|
|
||||||
fullscreen = true;
|
|
||||||
else if (!strcmp(argv[i], "-y"))
|
|
||||||
g_yup = true;
|
|
||||||
else if (!strcmp(argv[i], "-m"))
|
|
||||||
g_maxMipmapLevels = atoi(argv[++i]);
|
|
||||||
else if (!strcmp(argv[i], "-x"))
|
|
||||||
memLimit = atoi(argv[++i]);
|
|
||||||
else if (!strcmp(argv[i], "--disp"))
|
|
||||||
g_displacementScale = (float)atof(argv[++i]);
|
|
||||||
else if (colorFilename == NULL) {
|
else if (colorFilename == NULL) {
|
||||||
colorFilename = argv[i];
|
colorFilename = argvRem[i];
|
||||||
colorMem = memLimit;
|
colorMem = memLimit;
|
||||||
} else if (displacementFilename == NULL) {
|
} else if (displacementFilename == NULL) {
|
||||||
displacementFilename = argv[i];
|
displacementFilename = argvRem[i];
|
||||||
displacementMem = memLimit;
|
displacementMem = memLimit;
|
||||||
g_displacement = DISPLACEMENT_BILINEAR;
|
g_displacement = DISPLACEMENT_BILINEAR;
|
||||||
g_normal = NORMAL_BIQUADRATIC;
|
g_normal = NORMAL_BIQUADRATIC;
|
||||||
} else if (occlusionFilename == NULL) {
|
} else if (occlusionFilename == NULL) {
|
||||||
occlusionFilename = argv[i];
|
occlusionFilename = argvRem[i];
|
||||||
occlusionMem = memLimit;
|
occlusionMem = memLimit;
|
||||||
g_occlusion = 1;
|
g_occlusion = 1;
|
||||||
} else if (specularFilename == NULL) {
|
} else if (specularFilename == NULL) {
|
||||||
specularFilename = argv[i];
|
specularFilename = argvRem[i];
|
||||||
specularMem = memLimit;
|
specularMem = memLimit;
|
||||||
g_specular = 1;
|
g_specular = 1;
|
||||||
}
|
}
|
||||||
@ -2034,30 +2025,21 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
// load animation obj sequences (optional)
|
// load animation obj sequences (optional)
|
||||||
if (!animobjs.empty()) {
|
if (!animobjs.empty()) {
|
||||||
for (int i = 0; i < (int)animobjs.size(); ++i) {
|
// The Scheme passed here should ideally match the Ptex geometry (not the
|
||||||
std::ifstream ifs(animobjs[i].c_str());
|
// defaults from the command line), but only the vertex positions of the
|
||||||
if (ifs) {
|
// ObjAnim are used, so it is effectively ignored
|
||||||
std::stringstream ss;
|
g_objAnim = ObjAnim::Create(animobjs, kCatmark);
|
||||||
ss << ifs.rdbuf();
|
if (g_objAnim == 0) {
|
||||||
ifs.close();
|
printf("Error in reading animation Obj file sequence\n");
|
||||||
|
goto error;
|
||||||
printf("Reading %s\r", animobjs[i].c_str());
|
|
||||||
std::string str = ss.str();
|
|
||||||
Shape *shape = Shape::parseObj(str.c_str(), kCatmark);
|
|
||||||
|
|
||||||
if (shape->verts.size() != g_positions.size()) {
|
|
||||||
printf("Error: vertex count doesn't match.\n");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_animPositions.push_back(shape->verts);
|
|
||||||
delete shape;
|
|
||||||
} else {
|
|
||||||
printf("Error in reading %s\n", animobjs[i].c_str());
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
|
||||||
|
const Shape *animShape = g_objAnim->GetShape();
|
||||||
|
if (animShape->verts.size() != g_positions.size()) {
|
||||||
|
printf("Error in animation sequence, does not match ptex vertex count\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ GLFWmonitor* g_primary=0;
|
|||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
#include "init_shapes.h"
|
#include "init_shapes.h"
|
||||||
|
|
||||||
|
#include "../common/argOptions.h"
|
||||||
#include "../common/stopwatch.h"
|
#include "../common/stopwatch.h"
|
||||||
#include "../common/simple_math.h"
|
#include "../common/simple_math.h"
|
||||||
#include "../common/glHud.h"
|
#include "../common/glHud.h"
|
||||||
@ -1172,16 +1173,14 @@ callbackErrorGLFW(int error, const char* description) {
|
|||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
|
||||||
std::string str;
|
ArgOptions args;
|
||||||
for (int i = 1; i < argc; ++i) {
|
|
||||||
if (!strcmp(argv[i], "-l")) {
|
args.Parse(argc, argv);
|
||||||
g_level = atoi(argv[++i]);
|
args.PrintUnrecognizedArgsWarnings();
|
||||||
} else if (!strcmp(argv[i], "-a")) {
|
|
||||||
g_options.adaptive = true;
|
g_options.adaptive = args.GetAdaptive();
|
||||||
} else if (!strcmp(argv[i], "-u")) {
|
g_level = args.GetLevel();
|
||||||
g_options.adaptive = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Far::SetErrorCallback(callbackError);
|
Far::SetErrorCallback(callbackError);
|
||||||
|
|
||||||
glfwSetErrorCallback(callbackErrorGLFW);
|
glfwSetErrorCallback(callbackErrorGLFW);
|
||||||
|
@ -29,6 +29,8 @@ GLFWwindow* g_window=0;
|
|||||||
GLFWmonitor* g_primary=0;
|
GLFWmonitor* g_primary=0;
|
||||||
|
|
||||||
#include "../../regression/common/far_utils.h"
|
#include "../../regression/common/far_utils.h"
|
||||||
|
#include "../common/argOptions.h"
|
||||||
|
#include "../common/viewerArgsUtils.h"
|
||||||
#include "../common/stopwatch.h"
|
#include "../common/stopwatch.h"
|
||||||
#include "../common/simple_math.h"
|
#include "../common/simple_math.h"
|
||||||
#include "../common/glHud.h"
|
#include "../common/glHud.h"
|
||||||
@ -111,13 +113,12 @@ int g_kernel = kCPU,
|
|||||||
int g_running = 1,
|
int g_running = 1,
|
||||||
g_width = 1024,
|
g_width = 1024,
|
||||||
g_height = 1024,
|
g_height = 1024,
|
||||||
g_fullscreen = 0,
|
|
||||||
g_prev_x = 0,
|
g_prev_x = 0,
|
||||||
g_prev_y = 0,
|
g_prev_y = 0,
|
||||||
g_mbutton[3] = {0, 0, 0},
|
g_mbutton[3] = {0, 0, 0},
|
||||||
g_frame=0,
|
g_frame=0,
|
||||||
g_freeze=0,
|
g_freeze=0,
|
||||||
g_repeatCount;
|
g_repeatCount=0;
|
||||||
|
|
||||||
bool g_adaptive=true,
|
bool g_adaptive=true,
|
||||||
g_infSharpPatch=false;
|
g_infSharpPatch=false;
|
||||||
@ -129,6 +130,8 @@ float g_rotate[2] = {0, 0},
|
|||||||
g_size = 0,
|
g_size = 0,
|
||||||
g_moveScale = 0.0f;
|
g_moveScale = 0.0f;
|
||||||
|
|
||||||
|
bool g_yup = false;
|
||||||
|
|
||||||
struct Transform {
|
struct Transform {
|
||||||
float ModelViewMatrix[16];
|
float ModelViewMatrix[16];
|
||||||
float ProjectionMatrix[16];
|
float ProjectionMatrix[16];
|
||||||
@ -730,7 +733,9 @@ display() {
|
|||||||
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
||||||
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
if (!g_yup) {
|
||||||
|
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
||||||
|
}
|
||||||
translate(g_transformData.ModelViewMatrix,
|
translate(g_transformData.ModelViewMatrix,
|
||||||
-g_center[0], -g_center[1], -g_center[2]);
|
-g_center[0], -g_center[1], -g_center[2]);
|
||||||
perspective(g_transformData.ProjectionMatrix,
|
perspective(g_transformData.ProjectionMatrix,
|
||||||
@ -1059,43 +1064,17 @@ callbackErrorGLFW(int error, const char* description) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
bool fullscreen = false;
|
ArgOptions args;
|
||||||
Scheme defaultScheme = kCatmark;
|
|
||||||
std::vector<char const *> objfiles;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
args.Parse(argc, argv);
|
||||||
if (strstr(argv[i], ".obj")) {
|
args.PrintUnrecognizedArgsWarnings();
|
||||||
objfiles.push_back(argv[i]);
|
|
||||||
} else if (!strcmp(argv[i], "-a")) {
|
g_yup = args.GetYUp();
|
||||||
g_adaptive = true;
|
g_adaptive = args.GetAdaptive();
|
||||||
} else if (!strcmp(argv[i], "-u")) {
|
g_isolationLevel = args.GetLevel();
|
||||||
g_adaptive = false;
|
g_repeatCount = args.GetRepeatCount();
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
|
||||||
g_isolationLevel = atoi(argv[++i]);
|
ViewerArgsUtils::PopulateShapes(args, &g_defaultShapes);
|
||||||
} else if (!strcmp(argv[i], "-f")) {
|
|
||||||
fullscreen = true;
|
|
||||||
} else if (!strcmp(argv[i], "-bilinear")) {
|
|
||||||
defaultScheme = kBilinear;
|
|
||||||
} else if (!strcmp(argv[i], "-catmark")) {
|
|
||||||
defaultScheme = kCatmark;
|
|
||||||
} else if (!strcmp(argv[i], "-loop")) {
|
|
||||||
defaultScheme = kLoop;
|
|
||||||
} else {
|
|
||||||
printf("Warning: unrecognized argument '%s' ignored\n", argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < (int)objfiles.size(); ++i) {
|
|
||||||
std::ifstream ifs(objfiles[i]);
|
|
||||||
if (ifs) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << ifs.rdbuf();
|
|
||||||
ifs.close();
|
|
||||||
std::string str = ss.str();
|
|
||||||
g_defaultShapes.push_back(ShapeDesc(objfiles[i], str.c_str(), defaultScheme));
|
|
||||||
} else {
|
|
||||||
printf("Warning: cannot open shape file '%s'\n", objfiles[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initShapes();
|
initShapes();
|
||||||
|
|
||||||
@ -1109,7 +1088,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
GLUtils::SetMinimumGLVersion();
|
GLUtils::SetMinimumGLVersion();
|
||||||
|
|
||||||
if (fullscreen) {
|
if (args.GetFullScreen()) {
|
||||||
|
|
||||||
g_primary = glfwGetPrimaryMonitor();
|
g_primary = glfwGetPrimaryMonitor();
|
||||||
|
|
||||||
@ -1131,7 +1110,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
if (! (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
||||||
fullscreen && g_primary ? g_primary : NULL, NULL))) {
|
args.GetFullScreen() && g_primary ? g_primary : NULL, NULL))) {
|
||||||
std::cerr << "Failed to create OpenGL context.\n";
|
std::cerr << "Failed to create OpenGL context.\n";
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user