Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Line


    private Spatial createLines() {
        final FloatBuffer verts = BufferUtils.createVector3Buffer(3);
        verts.put(0).put(0).put(0);
        verts.put(5).put(5).put(0);
        verts.put(0).put(5).put(0);
        final Line line = new Line("Lines", verts, null, null, null);
        // since we do not set texture coords, but we'll have a texture state applied at root, we need to turn off
        // textures on this Line to prevent bleeding of texture coordinates from other shapes.
        line.getSceneHints().setTextureCombineMode(TextureCombineMode.Off);
        line.getMeshData().setIndexMode(IndexMode.LineStrip);
        line.setLineWidth(2);
        line.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        return line;
    }
View Full Code Here


    protected void initExample() {
        _canvas.setTitle("Lines");
        _lightState.setEnabled(false);

        // Create a line with our example "makeLine" method. See method below.
        final Line regular = makeLine(new Grapher() {
            @Override
            double getYforX(final double x) {
                // Line eq will be y = x^3 - 2x^2
                return Math.pow(x, 3) - (2 * Math.pow(x, 2));
            }
        }, -5, 5, .25);
        // Set some properties on this line.
        // Set our line width - for lines this in in screen space... not world space.
        regular.setLineWidth(3.25f);
        // This line will be green
        regular.setDefaultColor(ColorRGBA.GREEN);

        // Add our line to the scene.
        _root.attachChild(regular);

        // Create a line with our example "makeLine" method. See method below.
        final Line antialiased = makeLine(new Grapher() {
            @Override
            double getYforX(final double x) {
                // Line eq will be y = -x^3 - 2(-x^2)
                return Math.pow(-x, 3) - (2 * Math.pow(-x, 2));
            }
        }, -5, 5, .25);
        // Set some properties on this line.
        // Set our line width - for lines this in in screen space... not world space.
        antialiased.setLineWidth(3.25f);
        // This line will be Cyan.
        antialiased.setDefaultColor(ColorRGBA.CYAN);
        // Finally let us make this antialiased... see also BlendState below.
        antialiased.setAntialiased(true);

        // Uncomment to see a dashed line. :)
        // antialiased.setStipplePattern((short) 0xFFF0);

        // Antialiased lines work by adding small pixels to the line with alpha blending values.
        // To make use of this, you need to add a blend state that blends the source color
        // with the destination color using the source alpha.
        final BlendState blend = new BlendState();
        blend.setBlendEnabled(true);
        // use source color * source alpha + (1-source color) * destination color.
        // (Note: for an interesting effect, switch them so it is OneMinusSourceAlpha/SourceAlpha.
        // This will show you the pixels that are being added to your line in antialiasing.)
        blend.setSourceFunction(SourceFunction.SourceAlpha);
        blend.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha);
        antialiased.setRenderState(blend);

        // Add our antialiased line to the scene.
        _root.attachChild(antialiased);
    }
View Full Code Here

            final Vector3 vert = new Vector3(x, grapher.getYforX(x), -10);
            vertexList.add(vert);
        }

        // Create our Line object using the vertex data. We will not be providing normals, colors or texture coords.
        final Line line = new Line("graphed line: " + grapher, vertexList.toArray(new Vector3[vertexList.size()]),
                null, null, null);
        // The type of line we are making is a LineStrip. You can experiment and try making this Lines, or a Line Loop.
        line.getMeshData().setIndexMode(IndexMode.LineStrip);
        // Update the model bound of our line to fit the data we've provided.
        line.updateModelBound();
        // Send back our Line.
        return line;
    }
View Full Code Here

        path.add(new Vector3(2, 2, 16));
        path.add(new Vector3(2, 3, 20));
        path.add(new Vector3(3, 4, 24));

        // Linestrip
        final Line lineStrip = createLineStrip(false);
        lineStrip.setTranslation(-10, -20, 0);
        _root.attachChild(lineStrip);
        final Extrusion extrusion = new Extrusion("Extrusion", lineStrip, path, Vector3.UNIT_Y);
        extrusion.setTranslation(10, -20, 0);
        _root.attachChild(extrusion);

        // Lines
        final Line lines = createLines();
        lines.setTranslation(-10, 0, 0);
        _root.attachChild(lines);
        final Extrusion extrusion2 = new Extrusion("Extrusion", lines, path, Vector3.UNIT_Y);
        extrusion2.setTranslation(10, 0, 0);
        _root.attachChild(extrusion2);

        // LineLoop
        final Line lineLoop = createLineStrip(true);
        lineLoop.setTranslation(-10, 20, 0);
        _root.attachChild(lineLoop);
        final Extrusion extrusion3 = new Extrusion("Extrusion", lineLoop, path, Vector3.UNIT_Y);
        extrusion3.setTranslation(10, 20, 0);
        _root.attachChild(extrusion3);
    }
View Full Code Here

                new Vector3(-5, 5, 0), //
                new Vector3(-5, 5, 0), //
                new Vector3(-5, -5, 0), //
        };

        final Line line = new Line("curve", vectors, null, null, null);

        line.getMeshData().setIndexMode(IndexMode.Lines);

        return line;
    }
View Full Code Here

        // Create our curve from the control points and a spline
        final Curve curve = new Curve(controls, new CatmullRomSpline());

        // Create a line from the curve so its easy to check the box is following it
        final Line line = curve.toRenderableLine(10);

        if (loop) {
            line.getMeshData().setIndexMode(IndexMode.LineLoop);
        }

        return line;
    }
View Full Code Here

                new Vector3(0, 0, 20), //
                new Vector3(10, 0, 0), //
                new Vector3(10, 10, 10) };

        // Create a line from our vectors
        final Line line = new Line("line", vectors, null, null, null);
        line.getMeshData().setIndexMode(IndexMode.LineStrip);
        _root.attachChild(line);

        // Create some points from our vectors
        final Point point = new Point("point", vectors, null, null, null);
        point.setPointSize(10f);
View Full Code Here

        // Create our curve from the control points and a spline
        final Curve curve = new Curve(controls, new CatmullRomSpline());

        // Create a line from the curve so its easy to check the box is following it
        final Line line = curve.toRenderableLine(10);
        line.setRandomColors();

        _root.attachChild(line);

        // Create points from the curve so the actual control points can be easily seen
        final Point point = curve.toRenderablePoint(2);
View Full Code Here

                    }
                }
            }
            if (cMesh.getChild("lines") != null) {
                for (final Element l : cMesh.getChildren("lines")) {
                    final Line child = buildMeshLines(colladaGeometry, l);
                    if (child != null) {
                        if (child.getName() == null) {
                            child.setName(meshNode.getName() + "_lines");
                        }
                        meshNode.attachChild(child);
                        hasChild = true;
                    }
                }
View Full Code Here

    public Line buildMeshLines(final Element colladaGeometry, final Element lines) {
        if (lines == null || lines.getChild("input") == null || lines.getChild("p") == null) {
            return null;
        }
        final Line lineMesh = new Line(extractName(colladaGeometry, lines));

        // Build and set RenderStates for our material
        _colladaMaterialUtils.applyMaterial(lines.getAttributeValue("material"), lineMesh);

        final LinkedList<ColladaInputPipe> pipes = new LinkedList<ColladaInputPipe>();
        final int maxOffset = extractPipes(lines, pipes);
        final int interval = maxOffset + 1;

        // use interval & size of p array to determine buffer sizes.
        final int[] vals = _colladaDOMUtil.parseIntArray(lines.getChild("p"));
        final int numEntries = vals.length / interval;

        // Construct nio buffers for specified inputs.
        for (final ColladaInputPipe pipe : pipes) {
            pipe.setupBuffer(numEntries, lineMesh.getMeshData(), _dataCache);
        }

        // Add to vert mapping
        final int[] indices = new int[numEntries];
        final MeshVertPairs mvp = new MeshVertPairs(lineMesh, indices);
        _dataCache.getVertMappings().put(colladaGeometry, mvp);

        // go through the p entry
        // for each p, iterate using max offset
        final int[] currentVal = new int[interval];

        // Go through entries and add to buffers.
        for (int j = 0, max = numEntries; j < max; j++) {
            // add entry to buffers
            System.arraycopy(vals, j * interval, currentVal, 0, interval);
            final int rVal = processPipes(pipes, currentVal);
            if (rVal != Integer.MIN_VALUE) {
                indices[j] = rVal;
            }
        }

        if (_optimizeMeshes) {
            final VertMap map = GeometryTool.minimizeVerts(lineMesh, _optimizeSettings);
            _dataCache.setMeshVertMap(lineMesh, map);
        }

        lineMesh.updateModelBound();

        return lineMesh;
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.Line

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.