Package com.jme3.math

Examples of com.jme3.math.Vector2f


            fadeInfo = null;
            fadeLength = 0;
            postshadowMat.clearParam("FadeInfo");
        } else {
            if (zFarOverride == 0) {
                fadeInfo = new Vector2f(0, 0);
            } else {
                fadeInfo = new Vector2f(zFarOverride - length, 1.0f / length);
            }
            fadeLength = length;
            postshadowMat.setVector2("FadeInfo", fadeInfo);
        }
    }
View Full Code Here


     */
    public static void updateFrustumPoints2(Camera viewCam, Vector3f[] points) {
        int w = viewCam.getWidth();
        int h = viewCam.getHeight();

        points[0].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), 0));
        points[1].set(viewCam.getWorldCoordinates(new Vector2f(0, h), 0));
        points[2].set(viewCam.getWorldCoordinates(new Vector2f(w, h), 0));
        points[3].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), 0));

        points[4].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), 1));
        points[5].set(viewCam.getWorldCoordinates(new Vector2f(0, h), 1));
        points[6].set(viewCam.getWorldCoordinates(new Vector2f(w, h), 1));
        points[7].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), 1));
    }
View Full Code Here

        if (output.capacity() < input.capacity())
            throw new RuntimeException("Output must be at least as large as input!");

        input.clear();
        output.clear();
        Vector2f temp = new Vector2f();
        int vertexCount = input.capacity() / 2;

        ShortBuffer sb = null;
        IntBuffer ib = null;

        if (output instanceof ShortBuffer)
            sb = (ShortBuffer) output;
        else if (output instanceof IntBuffer)
            ib = (IntBuffer) output;
        else
            throw new UnsupportedOperationException();

        for (int i = 0; i < vertexCount; i++){
            BufferUtils.populateFromBuffer(temp, input, i);

            if (sb != null){
                sb.put( (short) (temp.getX()*Short.MAX_VALUE) );
                sb.put( (short) (temp.getY()*Short.MAX_VALUE) );
            }else{
                int v1 = (int) (temp.getX() * ((float)(1 << 16)));
                int v2 = (int) (temp.getY() * ((float)(1 << 16)));
                ib.put(v1).put(v2);
            }
        }
    }
View Full Code Here

                     return Float.parseFloat(split[0]);
                case Vector2:
                    if (split.length != 2){
                        throw new IOException("Vector2 value parameter must have 2 entries: " + value);
                    }
                    return new Vector2f(Float.parseFloat(split[0]),
                                                               Float.parseFloat(split[1]));
                case Vector3:
                    if (split.length != 3){
                        throw new IOException("Vector3 value parameter must have 3 entries: " + value);
                    }
View Full Code Here

        int[] index = new int[3];
        Vector3f[] v = new Vector3f[3];
        Vector2f[] t = new Vector2f[3];
        for (int i = 0; i < 3; i++) {
            v[i] = new Vector3f();
            t[i] = new Vector2f();
        }
       
        if (mesh.getBuffer(Type.Normal) == null) {
            throw new IllegalArgumentException("The given mesh has no normal data!");
        }
View Full Code Here

            Vector3f vTemp = v[0];
            v[0] = v[1];
            v[1] = v[2];
            v[2] = vTemp;
           
            Vector2f tTemp = t[0];
            t[0] = t[1];
            t[1] = t[2];
            t[2] = tTemp;
           
            index[0] = index[1];
View Full Code Here

           
            Vector3f vTemp = v[1];
            v[1] = v[2];
            v[2] = vTemp;
           
            Vector2f tTemp = t[1];
            t[1] = t[2];
            t[2] = tTemp;
           
            index[1] = index[2];
        }
View Full Code Here

   
    public static TriangleData processTriangle(int[] index,
            Vector3f[] v, Vector2f[] t) {
        Vector3f edge1 = new Vector3f();
        Vector3f edge2 = new Vector3f();
        Vector2f edge1uv = new Vector2f();
        Vector2f edge2uv = new Vector2f();
       
        Vector3f tangent = new Vector3f();
        Vector3f binormal = new Vector3f();
        Vector3f normal = new Vector3f();
       
View Full Code Here

        FloatBuffer normalBuffer = mesh.getFloatBuffer(Type.Normal);
        FloatBuffer texcoordBuffer = mesh.getFloatBuffer(Type.TexCoord);
       
        Vector3f position = new Vector3f();
        Vector3f normal = new Vector3f();
        Vector2f texCoord = new Vector2f();
       
        final int size = vertexBuffer.limit() / 3;
        for (int i = 0; i < size; i++) {
           
            populateFromBuffer(position, vertexBuffer, i);
            populateFromBuffer(normal, normalBuffer, i);
            populateFromBuffer(texCoord, texcoordBuffer, i);
           
            boolean found = false;
            //Nehon 07/07/2013
            //Removed this part, joining splitted vertice to compute tangent space makes no sense to me
            //separate vertice should have separate tangent space  
            if(!splitMirrored){
                for (int j = 0; j < vertexMap.size(); j++) {
                    VertexInfo vertexInfo = vertexMap.get(j);
                    if (approxEqual(vertexInfo.position, position) &&
                        approxEqual(vertexInfo.normal, normal) &&
                        approxEqual(vertexInfo.texCoord, texCoord))
                    {
                        vertexInfo.indices.add(i);
                        found = true;
                        break
                    }
                }
            }
            if (!found) {
                VertexInfo vertexInfo = new VertexInfo(position.clone(), normal.clone(), texCoord.clone());
                vertexInfo.indices.add(i);
                vertexMap.add(vertexInfo);
            }
        }
       
View Full Code Here

        public Vector2f getLocation(Vector2f previousLocation) {
            float x = (float) getX() / (float) atlasWidth;
            float y = (float) getY() / (float) atlasHeight;
            float w = (float) getWidth() / (float) atlasWidth;
            float h = (float) getHeight() / (float) atlasHeight;
            Vector2f location = new Vector2f(x, y);
            float prevX = previousLocation.x;
            float prevY = previousLocation.y;
            location.addLocal(prevX * w, prevY * h);
            return location;
        }
View Full Code Here

TOP

Related Classes of com.jme3.math.Vector2f

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.