Package com.ardor3d.math

Examples of com.ardor3d.math.Vector2


        _center = (Vector3) capsule.readSavable("center", new Vector3(Vector3.ZERO));
        _xAxis = (Vector3) capsule.readSavable("_xAxis", new Vector3(Vector3.UNIT_X));
        _yAxis = (Vector3) capsule.readSavable("yAxis", new Vector3(Vector3.UNIT_Y));
        _zAxis = (Vector3) capsule.readSavable("zAxis", new Vector3(Vector3.UNIT_Z));
        _extent = (Vector3) capsule.readSavable("extent", new Vector3(Vector3.ZERO));
        _texTopRight = (Vector2) capsule.readSavable("texTopRight", new Vector2(1, 1));
        _texTopLeft = (Vector2) capsule.readSavable("texTopLeft", new Vector2(1, 0));
        _texBotRight = (Vector2) capsule.readSavable("texBotRight", new Vector2(0, 1));
        _texBotLeft = (Vector2) capsule.readSavable("texBotLeft", new Vector2(0, 0));
        _vectorStore = CapsuleUtils.asArray(capsule.readSavableArray("vectorStore", new Vector3[8]), Vector3.class);
        _correctCorners = capsule.readBoolean("correctCorners", false);
    }
View Full Code Here


            final Vector3 v1 = vertex[i1];
            final Vector3 v2 = vertex[i2];
            final Vector3 v3 = vertex[i3];

            final Vector2 w1 = texcoord[i1];
            final Vector2 w2 = texcoord[i2];
            final Vector2 w3 = texcoord[i3];

            final float x1 = v2.getXf() - v1.getXf();
            final float x2 = v3.getXf() - v1.getXf();
            final float y1 = v2.getYf() - v1.getYf();
            final float y2 = v3.getYf() - v1.getYf();
            final float z1 = v2.getZf() - v1.getZf();
            final float z2 = v3.getZf() - v1.getZf();

            final float s1 = w2.getXf() - w1.getXf();
            final float s2 = w3.getXf() - w1.getXf();
            final float t1 = w2.getYf() - w1.getYf();
            final float t2 = w3.getYf() - w1.getYf();

            final float r = 1.0F / (s1 * t2 - s2 * t1);
            if (Float.isNaN(r) || Float.isInfinite(r)) {
                continue;
            }
View Full Code Here

     */
    public static Vector2[] getVector2Array(final FloatBuffer buff) {
        buff.clear();
        final Vector2[] verts = new Vector2[buff.limit() / 2];
        for (int x = 0; x < verts.length; x++) {
            final Vector2 v = new Vector2(buff.get(), buff.get());
            verts[x] = v;
        }
        return verts;
    }
View Full Code Here

        final FloatBuffer buff = data.getBuffer();
        buff.clear();
        final Vector2[] verts = new Vector2[data.getTupleCount()];
        final int tupleSize = data.getValuesPerTuple();
        for (int x = 0; x < verts.length; x++) {
            final Vector2 v = new Vector2(defaults);
            v.setX(buff.get());
            if (tupleSize > 1) {
                v.setY(buff.get());
            }
            if (tupleSize > 2) {
                buff.position(buff.position() + tupleSize - 2);
            }
            verts[x] = v;
View Full Code Here

     *            the buffer to find the Vector2 within
     * @param index
     *            the position (in terms of vectors, not floats) of the vector to normalize
     */
    public static void normalizeVector2(final FloatBuffer buf, final int index) {
        final Vector2 temp = Vector2.fetchTempInstance();
        populateFromBuffer(temp, buf, index);
        temp.normalizeLocal();
        setInBuffer(temp, buf, index);
        Vector2.releaseTempInstance(temp);
    }
View Full Code Here

     *            the buffer to find the Vector2 within
     * @param index
     *            the position (in terms of vectors, not floats) of the vector to add to
     */
    public static void addInBuffer(final ReadOnlyVector2 toAdd, final FloatBuffer buf, final int index) {
        final Vector2 temp = Vector2.fetchTempInstance();
        populateFromBuffer(temp, buf, index);
        temp.addLocal(toAdd);
        setInBuffer(temp, buf, index);
        Vector2.releaseTempInstance(temp);
    }
View Full Code Here

     *            the buffer to find the Vector2 within
     * @param index
     *            the position (in terms of vectors, not floats) of the vector to multiply
     */
    public static void multInBuffer(final ReadOnlyVector2 toMult, final FloatBuffer buf, final int index) {
        final Vector2 temp = Vector2.fetchTempInstance();
        populateFromBuffer(temp, buf, index);
        temp.multiplyLocal(toMult);
        setInBuffer(temp, buf, index);
        Vector2.releaseTempInstance(temp);
    }
View Full Code Here

     * @param index
     *            the position (in terms of vectors, not floats) of the vector in the buffer to check against
     * @return
     */
    public static boolean equals(final ReadOnlyVector2 check, final FloatBuffer buf, final int index) {
        final Vector2 temp = Vector2.fetchTempInstance();
        populateFromBuffer(temp, buf, index);
        final boolean equals = temp.equals(check);
        Vector2.releaseTempInstance(temp);
        return equals;
    }
View Full Code Here

            }

            /* compute interval for triangle 1 */
            {
                final Vector3 abc = Vector3.fetchTempInstance();
                final Vector2 x0x1 = Vector2.fetchTempInstance();
                if (newComputeIntervals(vp0, vp1, vp2, dv0, dv1, dv2, dv0dv1, dv0dv2, abc, x0x1)) {
                    return coplanarTriTri(n1, v0, v1, v2, u0, u1, u2);
                }

                /* compute interval for triangle 2 */
                final Vector3 def = Vector3.fetchTempInstance();
                final Vector2 y0y1 = Vector2.fetchTempInstance();
                if (newComputeIntervals(up0, up1, up2, du0, du1, du2, du0du1, du0du2, def, y0y1)) {
                    return coplanarTriTri(n1, v0, v1, v2, u0, u1, u2);
                }

                xx = x0x1.getX() * x0x1.getY();
                yy = y0y1.getX() * y0y1.getY();
                xxyy = xx * yy;

                tmp = abc.getX() * xxyy;
                isect1[0] = tmp + abc.getY() * x0x1.getY() * yy;
                isect1[1] = tmp + abc.getZ() * x0x1.getX() * yy;

                tmp = def.getX() * xxyy;
                isect2[0] = tmp + def.getY() * xx * y0y1.getY();
                isect2[1] = tmp + def.getZ() * xx * y0y1.getX();

                Vector3.releaseTempInstance(abc);
                Vector3.releaseTempInstance(def);

                Vector2.releaseTempInstance(x0x1);
View Full Code Here

     * @param store
     *            the Ray to store the result in. If false, a new Ray is created and returned.
     * @return the resulting Ray.
     */
    public Ray3 getPickRay(final ReadOnlyVector2 screenPosition, final boolean flipVertical, final Ray3 store) {
        final Vector2 pos = Vector2.fetchTempInstance().set(screenPosition);
        if (flipVertical) {
            pos.setY(getHeight() - screenPosition.getY());
        }

        Ray3 result = store;
        if (result == null) {
            result = new Ray3();
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Vector2

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.