Search in sources :

Example 11 with ArgParser

use of argparser.ArgParser in project artisynth_core by artisynth.

the class NURBSViewer method main.

public static void main(String[] args) {
    StringHolder fileName = new StringHolder();
    IntHolder width = new IntHolder(400);
    IntHolder height = new IntHolder(400);
    ArgParser parser = new ArgParser("java maspack.geometry.NURBSViewer");
    parser.addOption("-width %d #width (pixels)", width);
    parser.addOption("-height %d #height (pixels)", height);
    parser.addOption("-drawAxes %v #draw coordinate axes", drawAxes);
    parser.addOption("-file %s #wavefront file name", fileName);
    parser.addOption("-sphere %v #create a NURBS sphere", addSphere);
    parser.addOption("-circle %v #create a NURBS circle", addCircle);
    parser.addOption("-mesh %v #create a mesh for surfaces", addMesh);
    parser.addOption("-collider %v #create a colliding object for meshes", collider);
    parser.addOption("-axisLength %f #coordinate axis length", axisLength);
    parser.addOption("-GLVersion %d{2,3} " + "#version of openGL for graphics", glVersion);
    parser.matchAllArgs(args);
    NURBSViewer viewFrame = null;
    try {
        GLVersion glv = (glVersion.value == 3 ? GLVersion.GL3 : GLVersion.GL2);
        viewFrame = new NURBSViewer(width.value, height.value, glv);
        GLViewer viewer = viewFrame.getViewer();
        if (fileName.value != null) {
            viewFrame.addNURBS(new File(fileName.value));
        }
        if (addSphere.value) {
            NURBSSurface sphere = new NURBSSurface();
            sphere.setSphere(0, 0, 0, 10);
            if (addMesh.value) {
                viewFrame.addNURBSWithMesh(sphere);
            } else {
                viewFrame.addNURBS(sphere);
            }
        }
        if (addCircle.value) {
            NURBSCurve3d circle = new NURBSCurve3d();
            circle.setCircle(0, 0, 10);
            viewFrame.addNURBS(circle);
        }
        viewer.autoFitPerspective();
        if (drawAxes.value) {
            if (axisLength.value > 0) {
                viewer.setAxisLength(axisLength.value);
            } else {
                viewer.setAxisLength(GLViewer.AUTO_FIT);
            }
        }
        if (collider.value) {
            viewFrame.addCollidable();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    viewFrame.setVisible(true);
}
Also used : GLVersion(maspack.render.GL.GLViewer.GLVersion) GLViewer(maspack.render.GL.GLViewer) StringHolder(argparser.StringHolder) NURBSCurve3d(maspack.geometry.NURBSCurve3d) IntHolder(argparser.IntHolder) ArgParser(argparser.ArgParser) File(java.io.File) IOException(java.io.IOException) NURBSSurface(maspack.geometry.NURBSSurface)

Example 12 with ArgParser

use of argparser.ArgParser in project artisynth_core by artisynth.

the class AnimatedGifWriter method parseArgs.

/**
 * Parses options, fills in the delay and loop values
 * @param args list of arguments
 * @param delayHolder output delay time (s)
 * @param loopHolder output loop count
 */
public static String[] parseArgs(String[] args, DoubleHolder delayHolder, IntHolder loopHolder) {
    ArgParser parser = new ArgParser("java java.core.moviemaker.AnimatedGifWriter [options] " + "<list of input files> < output file>");
    DoubleHolder fpsHolder = new DoubleHolder(0);
    parser.addOption("-help %h #prints help message", null);
    parser.addOption("-delay %f #delay between frames (s)", delayHolder);
    parser.addOption("-fps %f #frames per second", fpsHolder);
    parser.addOption("-loop %d #number of times to play (-1 for infinite)", loopHolder);
    String[] left = parser.matchAllArgs(args, 0, 0);
    // favour fps
    if (fpsHolder.value > 0) {
        delayHolder.value = 1.0 / fpsHolder.value;
    }
    return left;
}
Also used : DoubleHolder(argparser.DoubleHolder) ArgParser(argparser.ArgParser)

Aggregations

ArgParser (argparser.ArgParser)12 IntHolder (argparser.IntHolder)4 File (java.io.File)4 PolygonalMesh (maspack.geometry.PolygonalMesh)4 StringHolder (argparser.StringHolder)2 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 RigidTransform3d (maspack.matrix.RigidTransform3d)2 GLVersion (maspack.render.GL.GLViewer.GLVersion)2 DoubleHolder (argparser.DoubleHolder)1 MovieMaker (artisynth.core.moviemaker.MovieMaker)1 WayPoint (artisynth.core.probes.WayPoint)1 RootModel (artisynth.core.workspace.RootModel)1 Color (java.awt.Color)1 Point (java.awt.Point)1 WindowEvent (java.awt.event.WindowEvent)1 WindowListener (java.awt.event.WindowListener)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1