Package com.ngt.jopenmetaverse.shared.types

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


        public void FromScale(Vector3 scale)
        {
            ScaledMax = Vector3.divide(scale, 2f);
            ScaledMin = Vector3.negate(ScaledMax);
            Vector3 dist = Vector3.subtract(ScaledMax, ScaledMin);
            ScaledR = dist.length();
        }
View Full Code Here


            if (vol.Min.Z < this.Min.Z) this.Min.Z = vol.Min.Z;

            if (vol.Max.X > this.Max.X) this.Max.X = vol.Max.X;
            if (vol.Max.Y > this.Max.Y) this.Max.Y = vol.Max.Y;
            if (vol.Max.Z > this.Max.Z) this.Max.Z = vol.Max.Z;
            Vector3 dist = Vector3.subtract(Max, Min);
            R = dist.length();
            CalcScaled(scale);
        }
View Full Code Here

                        oface.Indices = new ArrayList<Integer>();
                        oface.TextureFace = prim.Textures.GetFace(faceNr);

                        OSDMap subMeshMap = (OSDMap)subMeshOsd;

                        Vector3 posMax;
                        Vector3 posMin;

                        // If PositionDomain is not specified, the default is from -0.5 to 0.5
                        if (subMeshMap.containsKey("PositionDomain"))
                        {
                            posMax = ((OSDMap)subMeshMap.get("PositionDomain")).get("Max").asVector3();
                            posMin = ((OSDMap)subMeshMap.get("PositionDomain")).get("Min").asVector3();
                        }
                        else
                        {
                            posMax = new Vector3(0.5f, 0.5f, 0.5f);
                            posMin = new Vector3(-0.5f, -0.5f, -0.5f);
                        }

                        // Vertex positions
                        byte[] posBytes = subMeshMap.get("Position").asBinary();

                        // Normals
                        byte[] norBytes = null;
                        if (subMeshMap.containsKey("Normal"))
                        {
                            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));
                            }
View Full Code Here

      // The calculation for the HeadSize scalar may be incorrect, but it seems to work
      double agentHeight = agentSizeBase + (agentSizeVPLegLength * .1918) + (agentSizeVPHipLength * .0375) +
          (agentSizeVPHeight * .12022) + (agentSizeVPHeadSize * .01117) + (agentSizeVPNeckLength * .038) +
          (agentSizeVPHeelHeight * .08) + (agentSizeVPPlatformHeight * .07);

      set.AgentData.Size = new Vector3(0.45f, 0.6f, (float)agentHeight);

      //endregion Agent Size

      if (Client.settings.AVATAR_TRACKING)
      {
View Full Code Here

    // populate a dictionary from the packet, for local use
    Map<UUID, Vector3> coarseEntries = new HashMap<UUID, Vector3>();
    for (int i = 0; i < coarse.AgentData.length; i++)
    {
      if(coarse.Location.length > 0)
        coarseEntries.put(coarse.AgentData[i].AgentID, new Vector3((int)coarse.Location[i].X, (int)coarse.Location[i].Y, (int)coarse.Location[i].Z * 4));

      // the friend we are tracking on radar
      if (i == coarse.Index.Prey)
        e.getSimulator().preyID = coarse.AgentData[i].AgentID;
    }
View Full Code Here

                Tension = (float)(data[pos++] & 0x7F) / 10.0f;
                Drag = (float)(data[pos++] & 0x7F) / 10.0f;
                Gravity = (float)(data[pos++] / 10.0f) - 10.0f;
                Wind = (float)data[pos++] / 10.0f;
                Force = new Vector3(data, pos);
            }
            else
            {
                Softness = 0;
View Full Code Here

                float[] xy = new float[2];
                UUID prey = reply.AgentBlock.Prey;
                BigInteger regionHandle = Helpers.GlobalPosToRegionHandle((float)reply.LocationBlock[0].GlobalX,
                    (float)reply.LocationBlock[0].GlobalY, xy);
                Vector3 xyz = new Vector3(xy[0], xy[0], 0f);

                onFriendFoundReply.raiseEvent(new FriendFoundReplyEventArgs(prey, regionHandle, xyz));
            }
        }
View Full Code Here

        return vector;
    }

    public  Vector3 asVector3()
    {
        Vector3 vector = Vector3.Zero;

        if (this.count()== 3)
        {
            vector.X = (float)this.get(0).asReal();
            vector.Y = (float)this.get(1).asReal();
View Full Code Here

        obj.Shape = new PrimObject.ShapeBlock();
        obj.Inventory = new PrimObject.InventoryBlock();
        obj.AllowedDrop = true;
        obj.PassTouches = false;
       
     Vector3 offsetPosition = new Vector3();
     Vector3 groupPosition = new Vector3();
       
        NodeList nodeList = root.getChildNodes();
      for(int i = 0; i < nodeList.getLength(); i++)
      {
        Node node = nodeList.item(i);
        String nodeName = node.getNodeName();
        if(node.getNodeType() == Node.ELEMENT_NODE)
        {
           if(nodeName.equals("AllowedDrop"))
           {
               obj.AllowedDrop = Boolean.parseBoolean(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equals("CreatorID"))
           {
             obj.CreatorID = ReadUUID(node);
           }
           else if(nodeName.equalsIgnoreCase("FolderID"))
           {
                  obj.FolderID = ReadUUID(root);
           }
           else if(nodeName.equalsIgnoreCase("InventorySerial"))
           {
             String s = node.getFirstChild().getNodeValue().trim();
             obj.Inventory.Serial = Integer.parseInt(s);
           }     
           else if(nodeName.equalsIgnoreCase("TaskInventory"))
           {
             obj.Inventory.Items = ReadTaskInventoryItems(node);
           }           
           else if(nodeName.equalsIgnoreCase("ObjectFlags"))
           {
             EnumSet<PrimFlags> flags = PrimFlags.get((long)Long.parseLong(node.getFirstChild().getNodeValue().trim()));
             obj.UsePhysics = PrimFlags.and(flags , PrimFlags.Physics) != 0;
             obj.Phantom = PrimFlags.and(flags , PrimFlags.Phantom) != 0;
             obj.DieAtEdge = PrimFlags.and(flags , PrimFlags.DieAtEdge) != 0;
             obj.ReturnAtEdge = PrimFlags.and(flags , PrimFlags.ReturnAtEdge) != 0;
             obj.Temporary = PrimFlags.and(flags , PrimFlags.Temporary) != 0;
             obj.Sandbox = PrimFlags.and(flags , PrimFlags.Sandbox) != 0;
           }      
           else if(nodeName.equalsIgnoreCase("UUID"))
           {
                  obj.ID = ReadUUID(node);
           }
           else if(nodeName.equalsIgnoreCase("LocalId"))
           {
                  obj.LocalID = Long.parseLong(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equalsIgnoreCase("Name"))
           {
                  obj.Name = node.getFirstChild().getNodeValue().trim();
           }
           else if(nodeName.equalsIgnoreCase("Material"))
           {
                  obj.Material = Integer.parseInt(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equalsIgnoreCase("PassTouches"))
           {
                  obj.PassTouches = Boolean.parseBoolean(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equalsIgnoreCase("RegionHandle"))
           {
                  obj.RegionHandle = new BigInteger(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equalsIgnoreCase("ScriptAccessPin"))
           {
                  obj.RemoteScriptAccessPIN = Integer.parseInt(node.getFirstChild().getNodeValue().trim());
           }
           else if(nodeName.equalsIgnoreCase("PlaySoundSlavePrims"))
           {
             //Discard
           }         
           else if(nodeName.equalsIgnoreCase("LoopSoundSlavePrims"))
           {
             //Discard
           }  
           else if(nodeName.equalsIgnoreCase("GroupPosition"))
           {
             groupPosition = ReadVector(node);
           }           
           else if(nodeName.equalsIgnoreCase("OffsetPosition"))
           {
             offsetPosition = ReadVector(node);
           }
           else if(nodeName.equalsIgnoreCase("RotationOffset"))
           {
             obj.Rotation = ReadQuaternion(node);
           }
           else if(nodeName.equalsIgnoreCase("Velocity"))
           {
             obj.Velocity  = ReadVector(node);
           }
           else if(nodeName.equalsIgnoreCase("RotationalVelocity"))
           {
             Vector3 rotationalVelocity = ReadVector(node);
           }
           else if(nodeName.equalsIgnoreCase("AngularVelocity"))
           {
             Vector3 AngularVelocity = ReadVector(node);
           }
           else if(nodeName.equalsIgnoreCase("Acceleration"))
           {
             Vector3 Acceleration = ReadVector(node);
           }
           else if(nodeName.equalsIgnoreCase("Description"))
           {
                  obj.Description = node.getFirstChild().getNodeValue().trim();
           }
View Full Code Here

        return color;
    }
   
    static Vector3 ReadVector(Node root)
    {
        Vector3 vec = new Vector3();

      NodeList nodeList = root.getChildNodes();   
      for(int i = 0; i < nodeList.getLength(); i++)
      {
        Node node = nodeList.item(i);
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.