Package com.ngt.jopenmetaverse.shared.types

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


  }

  @Override
  public void calPrimPosAndRot(Vector3 cameraRenderPosition) {
    // TODO Auto-generated method stub
    RenderPosition = new Vector3(0, 0, 0);
    RenderRotation = InterpolatedRotation.Identity;
  }
View Full Code Here


            throw new IOException("Unrecognized mesh format");

        // Populate base mesh variables
        _hasWeights = (input.UnpackByte() != 0);
        _hasDetailTexCoords = (input.UnpackByte() != 0);
        _position = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
        _rotationAngles = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
        _rotationOrder = input.UnpackByte();
        _scale = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
        _numVertices = input.UnpackUShort();

        // Populate the vertex array
        _vertices = new Vertex[_numVertices];

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

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

        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);
View Full Code Here

                throw new IOException("Unrecognized mesh format");

            // Populate base mesh variables
            _hasWeights = (input.UnpackByte() != 0);
            _hasDetailTexCoords = (input.UnpackByte() != 0);
            _position = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationAngles = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationOrder = input.UnpackByte();
            _scale = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _numFaces = input.UnpackUShort();

            _faces = new Face[_numFaces];

            for (int i = 0; i < _numFaces; i++)
View Full Code Here

        mesh.Vertices = new ArrayList<Vertex>(newPrim.coords.size());
        for (int i = 0; i < newPrim.coords.size(); i++)
        {
            Coord c = newPrim.coords.get(i);
            Vertex vertex = new Vertex();
            vertex.Position = new Vector3(c.X, c.Y, c.Z);
           
            mesh.Vertices.add(vertex);
        }

        mesh.Indices = new ArrayList<Integer>(newPrim.faces.size() * 3);
 
View Full Code Here

            oface.Vertices = new ArrayList<Vertex>();
            oface.Indices = new ArrayList<Integer>();
            oface.TextureFace = prim.Textures.GetFace(ii);
            int faceVertices = 0;
            vertexAccount.clear();
            Vector3 pos;
            int indx;
            Vertex vert;
            for (ViewerFace vface : newPrim.viewerFaces)
            {
                if (vface.primFaceNumber == ii)
                {
//                  System.out.println(String.format("Face Number %d v1 %s v2 %s v3 %s uv1 %s uv2 %s uv3 %s",
//                      ii, vface.v1, vface.v2, vface.v3, vface.uv1, vface.uv2, vface.uv3));
                 
                    faceVertices++;
                    pos = new Vector3(vface.v1.X, vface.v1.Y, vface.v1.Z);
                    if (vertexAccount.containsKey(pos))
                    {
                        // we aleady have this vertex in the list. Just point the index at it
                        oface.Indices.add(vertexAccount.get(pos));
                    }
                    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

            Vertex vert;

            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

            //System.out.println("\nTexture " + vert.TexCoord);
           
            // aply planar tranforms to the UV first if applicable
            if (teFace.getTexMapType() == MappingType.Planar)
            {
                Vector3 binormal;
                float d = Vector3.dot(vert.Normal, Vector3.UnitX);
                if (d >= 0.5f || d <= -0.5f)
                {
                    binormal = Vector3.UnitY;
                    if (vert.Normal.X < 0f)
                      binormal = Vector3.multiply(binormal, -1);
                }
                else
                {
                    binormal = Vector3.UnitX;
                    if (vert.Normal.Y > 0f)
                      binormal = Vector3.multiply(binormal, -1);
                }
                Vector3 tangent = Vector3.modulus(vert.Normal, binormal);
                Vector3 scaledPos = Vector3.multiply(vert.Position,  primScale);
                vert.TexCoord.X = 1f + (Vector3.dot(binormal, scaledPos) * 2f - 0.5f);
                vert.TexCoord.Y = -(Vector3.dot(tangent, scaledPos) * 2f - 0.5f);
            }
           
            float repeatU = teFace.getRepeatU();
View Full Code Here

        terrain.Indices = new ArrayList<Integer>(newMesh.faces.size() * 3);

        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

        public void CalcScaled(Vector3 scale)
        {
            ScaledMin = Vector3.multiply(Min, scale);
            ScaledMax = Vector3.multiply(Max, scale);
            Vector3 dist = Vector3.subtract(ScaledMax, ScaledMin);
            ScaledR = dist.length();
        }
View Full Code Here

                if (mesh.Vertices.get(q).Position.X > Max.X) Max.X = mesh.Vertices.get(q).Position.X;
                if (mesh.Vertices.get(q).Position.Y > Max.Y) Max.Y = mesh.Vertices.get(q).Position.Y;
                if (mesh.Vertices.get(q).Position.Z > Max.Z) Max.Z = mesh.Vertices.get(q).Position.Z;
            }

            Vector3 dist = Vector3.subtract(Max, Min);
            R = dist.length();
            mesh.Center = Vector3.add(Min, Vector3.divide(dist, 2));
            CalcScaled(scale);
        }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.types.Vector3

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.