Package com.ngt.jopenmetaverse.shared.types

Examples of com.ngt.jopenmetaverse.shared.types.Vector2


    return new org.lwjgl.util.vector.Vector4f(v.X, v.Y, v.Z, v.W);
  }

  public static Vector2 OMVVector2(org.lwjgl.util.vector.Vector2f v)
  {
    return new Vector2(v.x, v.y);
  }
View Full Code Here


        }

        public static float turbulence2(float x, float y, float freq)
        {
            float t;
            Vector2 vec = new Vector2();

            for (t = 0f; freq >= 1f; freq *= 0.5f)
            {
                vec.X = freq * x;
                vec.Y = freq * y;
 
View Full Code Here

        for (int i = 0; i < _numVertices; i++)
            _vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());

        for (int i = 0; i < _numVertices; i++)
            _vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());

        if (_hasDetailTexCoords)
        {
            for (int i = 0; i < _numVertices; i++)
                _vertices[i].DetailTexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
        }

        if (_hasWeights)
        {
            for (int i = 0; i < _numVertices; i++)
                _vertices[i].Weight = input.UnpackFloat();
        }

        _numFaces = input.UnpackUShort();

        _faces = new Face[_numFaces];

        for (int i = 0; i < _numFaces; i++)
            _faces[i].Indices = new short[] { input.UnpackShort(), input.UnpackShort(), input.UnpackShort() };

        if (_hasWeights)
        {
            _numSkinJoints = input.UnpackUShort();
            _skinJoints = new String[_numSkinJoints];

            for (int i = 0; i < _numSkinJoints; i++)
            {
                _skinJoints[i] = Utils.TrimAt0(input.UnpackString(64));
            }
        }
        else
        {
            _numSkinJoints = 0;
            _skinJoints = new String[0];
        }

        // Grab morphs
        List<Morph> morphs = new ArrayList<Morph>();
        String morphName = Utils.TrimAt0(input.UnpackString(64));

        while (!morphName.equalsIgnoreCase(MORPH_FOOTER))
        {
            if (input.getBytePos() + 48 >= input.Data.length) throw new IOException("Encountered end of file while parsing morphs");

            Morph morph = new Morph();
            morph.Name = morphName;
            morph.NumVertices = input.UnpackInt();
            morph.Vertices = new MorphVertex[morph.NumVertices];

            for (int i = 0; i < morph.NumVertices; i++)
            {
                morph.Vertices[i].VertexIndex = input.UnpackUInt();
                morph.Vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                morph.Vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                morph.Vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                morph.Vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
            }

            morphs.add(morph);

            // Grab the next name
View Full Code Here

                    else
                    {
                        // the vertex is not in the list. Add it and the new index.
                        vert = new Vertex();
                        vert.Position = pos;
                        vert.TexCoord = new Vector2(vface.uv1.U, 1.0f - vface.uv1.V);
                        vert.Normal = new Vector3(vface.n1.X, vface.n1.Y, vface.n1.Z);
                        oface.Vertices.add(vert);
                        indx = oface.Vertices.size() - 1;
                        vertexAccount.put(pos, indx);
                        oface.Indices.add(indx);
                    }

                    pos = new Vector3(vface.v2.X, vface.v2.Y, vface.v2.Z);
                    if (vertexAccount.containsKey(pos))
                    {
                        oface.Indices.add(vertexAccount.get(pos));
                    }
                    else
                    {
                        vert = new Vertex();
                        vert.Position = pos;
                        vert.TexCoord = new Vector2(vface.uv2.U, 1.0f - vface.uv2.V);
                        vert.Normal = new Vector3(vface.n2.X, vface.n2.Y, vface.n2.Z);
                        oface.Vertices.add(vert);
                        indx = oface.Vertices.size() - 1;
                        vertexAccount.put(pos, indx);
                        oface.Indices.add(indx);
                    }

                    pos = new Vector3(vface.v3.X, vface.v3.Y, vface.v3.Z);
                    if (vertexAccount.containsKey(pos))
                    {
                        oface.Indices.add(vertexAccount.get(pos));
                    }
                    else
                    {
                        vert = new Vertex();
                        vert.Position = pos;
                        vert.TexCoord = new Vector2(vface.uv3.U, 1.0f - vface.uv3.V);
                        vert.Normal = new Vector3(vface.n3.X, vface.n3.Y, vface.n3.Z);
                        oface.Vertices.add(vert);
                        indx = oface.Vertices.size() - 1;
                        vertexAccount.put(pos, indx);
                        oface.Indices.add(indx);
View Full Code Here

            for (int j = 0; j < faceVertices; j++)
            {
                vert = new Vertex();
                vert.Position = new Vector3(newMesh.coords.get(j).X, newMesh.coords.get(j).Y, newMesh.coords.get(j).Z);
                vert.Normal = new Vector3(newMesh.normals.get(j).X, newMesh.normals.get(j).Y, newMesh.normals.get(j).Z);
                vert.TexCoord = new Vector2(newMesh.uvs.get(j).U, newMesh.uvs.get(j).V);
                oface.Vertices.add(vert);
            }

            for (int j = 0; j < newMesh.faces.size(); j++)
            {
View Full Code Here

        for (int j = 0; j < faceVertices; j++)
        {
          Vertex vert = new Vertex();
            vert.Position = new Vector3(newMesh.coords.get(j).X, newMesh.coords.get(j).Y, newMesh.coords.get(j).Z);
            vert.Normal = new Vector3(newMesh.normals.get(j).X, newMesh.normals.get(j).Y, newMesh.normals.get(j).Z);
            vert.TexCoord = new Vector2(newMesh.uvs.get(j).U, newMesh.uvs.get(j).V);
            terrain.Vertices.add(vert);
        }

        for (int j = 0; j < newMesh.faces.size(); j++)
        {
View Full Code Here

                        {
                            norBytes = subMeshMap.get("Normal").asBinary();
                        }

                        // UV texture map
                        Vector2 texPosMax = Vector2.Zero;
                        Vector2 texPosMin = Vector2.Zero;
                        byte[] texBytes = null;
                        if (subMeshMap.containsKey("TexCoord0"))
                        {
                            texBytes = subMeshMap.get("TexCoord0").asBinary();
                            texPosMax = ((OSDMap)subMeshMap.get("TexCoord0Domain")).get("Max").asVector2();
                            texPosMin = ((OSDMap)subMeshMap.get("TexCoord0Domain")).get("Min").asVector2();
                        }

                        // Extract the vertex position data
                        // If present normals and texture coordinates too
                        for (int i = 0; i < posBytes.length; i += 6)
                        {
                            int uX = Utils.bytesToUInt16(posBytes, i);
                            int uY = Utils.bytesToUInt16(posBytes, i + 2);
                            int uZ = Utils.bytesToUInt16(posBytes, i + 4);

                            Vertex vx = new Vertex();

                            vx.Position = new Vector3(
                                Utils.uint16ToFloat(uX, posMin.X, posMax.X),
                                Utils.uint16ToFloat(uY, posMin.Y, posMax.Y),
                                Utils.uint16ToFloat(uZ, posMin.Z, posMax.Z));

                            if (norBytes != null && norBytes.length >= i + 4)
                            {
                                int nX = Utils.bytesToUInt16(norBytes, i);
                                int nY = Utils.bytesToUInt16(norBytes, i + 2);
                                int nZ = Utils.bytesToUInt16(norBytes, i + 4);

                                vx.Normal = new Vector3(
                                    Utils.uint16ToFloat(nX, posMin.X, posMax.X),
                                    Utils.uint16ToFloat(nY, posMin.Y, posMax.Y),
                                    Utils.uint16ToFloat(nZ, posMin.Z, posMax.Z));
                            }

                            int vertexIndexOffset = oface.Vertices.size() * 4;

                            if (texBytes != null && texBytes.length >= vertexIndexOffset + 4)
                            {
                                int tX = Utils.bytesToUInt16(texBytes, vertexIndexOffset);
                                int tY = Utils.bytesToUInt16(texBytes, vertexIndexOffset + 2);

                                vx.TexCoord = new Vector2(
                                    Utils.uint16ToFloat(tX, texPosMin.X, texPosMax.X),
                                    Utils.uint16ToFloat(tY, texPosMin.Y, texPosMax.Y));
                            }

                            oface.Vertices.add(vx);
View Full Code Here

          float[] yvalues = TerrainCompressor.DecompressPatch(patches, header, group);

          if (simulator.Client.settings.STORE_LAND_PATCHES)
          {
              for (int i = 0; i < 256; i++)
                  simulator.WindSpeeds[i] = new Vector2(xvalues[i], yvalues[i]);
          }
      }
View Full Code Here

        }
       
        /// <summary></summary>
        public Vector2 getPathBeginScale()
        {
                Vector2 begin = new Vector2(1f, 1f);
                if (PathScaleX > 1f)
                    begin.X = 2f - PathScaleX;
                if (PathScaleY > 1f)
                    begin.Y = 2f - PathScaleY;
                return begin;
View Full Code Here

        }

        /// <summary></summary>
        public Vector2 getPathEndScale()
        {
                Vector2 end = new Vector2(1f, 1f);
                if (PathScaleX < 1f)
                    end.X = PathScaleX;
                if (PathScaleY < 1f)
                    end.Y = PathScaleY;
                return end;
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.types.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.