Package com.ngt.jopenmetaverse.shared.structureddata

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDMap


    //region Public Methods

    public OSD GetOSD()
    {
        OSDMap path = new OSDMap(14);
        path.put("begin", OSD.FromReal(PrimData.PathBegin));
        path.put("curve", OSD.FromInteger((int)PrimData.PathCurve.getIndex()));
        path.put("end", OSD.FromReal(PrimData.PathEnd));
        path.put("radius_offset", OSD.FromReal(PrimData.PathRadiusOffset));
        path.put("revolutions", OSD.FromReal(PrimData.PathRevolutions));
        path.put("scale_x", OSD.FromReal(PrimData.PathScaleX));
        path.put("scale_y", OSD.FromReal(PrimData.PathScaleY));
        path.put("shear_x", OSD.FromReal(PrimData.PathShearX));
        path.put("shear_y", OSD.FromReal(PrimData.PathShearY));
        path.put("skew", OSD.FromReal(PrimData.PathSkew));
        path.put("taper_x", OSD.FromReal(PrimData.PathTaperX));
        path.put("taper_y", OSD.FromReal(PrimData.PathTaperY));
        path.put("twist", OSD.FromReal(PrimData.PathTwist));
        path.put("twist_begin", OSD.FromReal(PrimData.PathTwistBegin));

        OSDMap profile = new OSDMap(4);
        profile.put("begin", OSD.FromReal(PrimData.ProfileBegin));
        profile.put("curve", OSD.FromInteger((int)PrimData.profileCurve));
        profile.put("hole", OSD.FromInteger((int)PrimData.getProfileHole().getIndex()));
        profile.put("end", OSD.FromReal(PrimData.ProfileEnd));
        profile.put("hollow", OSD.FromReal(PrimData.ProfileHollow));

        OSDMap volume = new OSDMap(2);
        volume.put("path",  path);
        volume.put("profile",  profile);

        OSDMap prim = new OSDMap(20);
        if (Properties != null)
        {
            prim.put("name", OSD.FromString(Properties.Name));
            prim.put("description", OSD.FromString(Properties.Description));
        }
        else
        {
            prim.put("name", OSD.FromString("Object"));
            prim.put("description", OSD.FromString(""));
        }
       
        prim.put("phantom", OSD.FromBoolean(((Flags & PrimFlags.Phantom.getIndex()) != 0)));
        prim.put("physical", OSD.FromBoolean(((Flags & PrimFlags.Physics.getIndex()) != 0)));
        prim.put("position", OSD.FromVector3(Position));
        prim.put("rotation", OSD.FromQuaternion(Rotation));
        prim.put("scale", OSD.FromVector3(Scale));
        prim.put("pcode", OSD.FromInteger((int)PrimData.PCode.getIndex()));
        prim.put("material", OSD.FromInteger((int)PrimData.Material.getIndex()));
        prim.put("shadows", OSD.FromBoolean(((Flags & PrimFlags.CastShadows.getIndex()) != 0)));
        prim.put("state", OSD.FromInteger(PrimData.State));

        prim.put("id", OSD.FromUUID(ID));
        prim.put("localid", OSD.FromLong(LocalID));
        prim.put("parentid", OSD.FromLong(ParentID));

        prim.put("volume", volume);

        if (Textures != null)
            prim.put("textures", Textures.GetOSD());
       
        if (Light != null)
            prim.put("light", Light.GetOSD());

        if (Flexible != null)
            prim.put("flex", Flexible.GetOSD());

        if (Sculpt != null)
            prim.put("sculpt", Sculpt.GetOSD());

        return prim;
    }
View Full Code Here


    public static Primitive FromOSD(OSD osd)
    {
        Primitive prim = new Primitive();
        ConstructionData data = new ConstructionData();

        OSDMap map = (OSDMap)osd;
        OSDMap volume = (OSDMap)map.get("volume");
        OSDMap path = (OSDMap)volume.get("path");
        OSDMap profile = (OSDMap)volume.get("profile");

        //region Path/Profile

        data.profileCurve = (byte)0;
        data.Material = Material.get((byte)map.get("material").asInteger());
        data.PCode = PCode.get((byte)map.get("pcode").asInteger());
        data.State = (byte)map.get("state").asInteger();

        data.PathBegin = (float)path.get("begin").asReal();
        data.PathCurve = PathCurve.get((byte)path.get("curve").asInteger());
        data.PathEnd = (float)path.get("end").asReal();
        data.PathRadiusOffset = (float)path.get("radius_offset").asReal();
        data.PathRevolutions = (float)path.get("revolutions").asReal();
        data.PathScaleX = (float)path.get("scale_x").asReal();
        data.PathScaleY = (float)path.get("scale_y").asReal();
        data.PathShearX = (float)path.get("shear_x").asReal();
        data.PathShearY = (float)path.get("shear_y").asReal();
        data.PathSkew = (float)path.get("skew").asReal();
        data.PathTaperX = (float)path.get("taper_x").asReal();
        data.PathTaperY = (float)path.get("taper_y").asReal();
        data.PathTwist = (float)path.get("twist").asReal();
        data.PathTwistBegin = (float)path.get("twist_begin").asReal();

        data.ProfileBegin = (float)profile.get("begin").asReal();
        data.ProfileEnd = (float)profile.get("end").asReal();
        data.ProfileHollow = (float)profile.get("hollow").asReal();
        data.profileCurve = (byte)profile.get("curve").asInteger();
        data.setProfileHole(HoleType.get((byte)profile.get("hole").asInteger()));

        //endregion Path/Profile

        prim.PrimData = data;
View Full Code Here

        ///
        /// </summary>
        /// <returns></returns>
        public OSD GetOSD()
        {
            OSDMap map = new OSDMap();

            map.put("simulate_lod", OSD.FromInteger(Softness));
            map.put("gravity", OSD.FromReal(Gravity));
            map.put("air_friction", OSD.FromReal(Drag));
            map.put("wind_sensitivity", OSD.FromReal(Wind));
            map.put("tension", OSD.FromReal(Tension));
            map.put("user_force", OSD.FromVector3(Force));

            return map;
        }
View Full Code Here

        {
            FlexibleData flex = new FlexibleData();

            if (osd.getType() == OSDType.Map)
            {
                OSDMap map = (OSDMap)osd;

                flex.Softness = map.get("simulate_lod").asInteger();
                flex.Gravity = (float)map.get("gravity").asReal();
                flex.Drag = (float)map.get("air_friction").asReal();
                flex.Wind = (float)map.get("wind_sensitivity").asReal();
                flex.Tension = (float)map.get("tension").asReal();
                flex.Force = ((OSDArray)map.get("user_force")).asVector3();
            }
            return flex;
        }
View Full Code Here

  /// Serialize to OSD
  /// </summary>
  /// <returns>OSDMap with the serialized data</returns>
  public OSDMap GetOSD()
  {
    OSDMap map = new OSDMap();

    map.put("alt_image_enable", OSD.FromBoolean(EnableAlterntiveImage));
    map.put("auto_loop", OSD.FromBoolean(AutoLoop));
    map.put("auto_play", OSD.FromBoolean(AutoPlay));
    map.put("auto_scale", OSD.FromBoolean(AutoScale));
    map.put("auto_zoom", OSD.FromBoolean(AutoZoom));
    map.put("controls", OSD.FromInteger(Controls.getIndex()));
    map.put("current_url",  OSD.FromString(CurrentURL));
    map.put("first_click_interact", OSD.FromBoolean(InteractOnFirstClick));
    map.put("height_pixels", OSD.FromInteger(Height));
    map.put("home_url", OSD.FromString(HomeURL));
    map.put("perms_control", OSD.FromInteger((int)MediaPermission.getIndex(ControlPermissions)));
    map.put("perms_interact", OSD.FromInteger((int)MediaPermission.getIndex(InteractPermissions)));

    List<OSD> wl = new ArrayList<OSD>();
    if (WhiteList != null && WhiteList.length > 0)
    {
      for (int i = 0; i < WhiteList.length; i++)
        wl.add(OSD.FromString(WhiteList[i]));
    }

    map.put("whitelist", new OSDArray(wl));
    map.put("whitelist_enable", OSD.FromBoolean(EnableWhiteList));
    map.put("width_pixels", OSD.FromInteger(Width));

    return map;
  }
View Full Code Here

  /// <param name="osd">Serialized OSD data</param>
  /// <returns>Deserialized object</returns>
  public static MediaEntry FromOSD(OSD osd)
  {
    MediaEntry m = new MediaEntry();
    OSDMap map = (OSDMap)osd;

    m.EnableAlterntiveImage = map.get("alt_image_enable").asBoolean();
    m.AutoLoop = map.get("auto_loop").asBoolean();
    m.AutoPlay = map.get("auto_play").asBoolean();
    m.AutoScale = map.get("auto_scale").asBoolean();
    m.AutoZoom = map.get("auto_zoom").asBoolean();
    m.Controls = MediaControls.create((byte)map.get("controls").asInteger());
    m.CurrentURL = map.get("current_url").asString();
    m.InteractOnFirstClick = map.get("first_click_interact").asBoolean();
    m.Height = map.get("height_pixels").asInteger();
    m.HomeURL = map.get("home_url").asString();
    m.ControlPermissions = MediaPermission.get((byte)(map.get("perms_control").asInteger()));
    m.InteractPermissions = MediaPermission.get((byte)map.get("perms_interact").asInteger());

    if (map.get("whitelist").getType() == OSDType.Array)
    {
      OSDArray wl = (OSDArray)map.get("whitelist");
      if (wl.count() > 0)
      {
        m.WhiteList = new String[wl.count()];
        for (int i = 0; i < wl.count(); i++)
        {
          m.WhiteList[i] = wl.get(i).asString();
        }
      }
    }

    m.EnableWhiteList = map.get("whitelist_enable").asBoolean();
    m.Width = map.get("width_pixels").asInteger();

    return m;
  }
View Full Code Here

                      newChild.appendChild(doc.createTextNode(data.asString()));
                      rootElement.appendChild(newChild);
                     
                      break;
                  case Map:
                      OSDMap map = (OSDMap)data;
//                      writer.WriteStartElement("", "map", "");
//                      foreach (KeyValuePair<String, OSD> kvp in map)
//                      {
//                          writer.WriteStartElement("", "key", "");
//                          writer.WriteString(kvp.Key);
//                          writer.WriteEndElement();
// 
//                          SerializeLLSDXmlElement(writer, kvp.Value);
//                      }
//                      writer.WriteEndElement();
                     
                      newChild = doc.createElement("map");
                     
                      for(Map.Entry<String, OSD> entry: map.entrySet())
                      {
                        Node keyNode = doc.createElement("key");
                        keyNode.appendChild(doc.createTextNode(entry.getKey()));
                        newChild.appendChild(keyNode);
                        SerializeLLSDXmlElement(doc, newChild, entry.getValue());
View Full Code Here

    if (reader.getNodeType() != Node.ELEMENT_NODE|| !reader.getNodeName().equals("map"))
      throw new OSDException("Expected <map>");

    ////System.out.println("Parsing Map...");
   
    OSDMap map = new OSDMap();

    if (!reader.hasChildNodes())
    {
      return map;
    }

    NodeList nodeList = reader.getChildNodes();
   
    List<Node> nl = new ArrayList<Node>();
   
    //Remove the Non Element Nodes
    for(int i = 0; i < nodeList.getLength(); i+=1)
    {
      if(nodeList.item(i).getNodeType() == Node.ELEMENT_NODE)
      {
        nl.add(nodeList.item(i));
      }
    }
   
    for(int i = 0; i < nl.size(); i+=2)
    {
      //System.out.println(i);
        Node keyNode = nl.get(i);
        Node valueNode = nl.get(i+1);
     
        if (keyNode == null || !keyNode.getNodeName().equals("key"))
          throw new OSDException("Expected <key>");
     
        if (valueNode == null)
          throw new OSDException("Expected value for a key");       
        //System.out.println(keyNode.getFirstChild().getNodeValue());
        String key = keyNode.getFirstChild().getNodeValue().trim();
        map.put(key, ParseLLSDXmlElement(valueNode));
    }
   
    return map;
  }
View Full Code Here

        public byte[] SerializeAttachment() throws Exception
        {
            if (OwnerID == UUID.Zero || AttachmentID == UUID.Zero)
                return Utils.EmptyBytes;

            OSDMap att = new OSDMap();
            att.put("item_id", OSD.FromUUID(AttachmentID));
            att.put("owner_id", OSD.FromUUID(OwnerID));

            return XmlLLSDOSDParser.SerializeLLSDXmlBytes(att);

            /*
            //I guess this is how this works, no gaurentees
View Full Code Here

        private static OSD ParseLLSDBinaryMap(InputStream stream) throws IOException, OSDException
        {
            int numElements = NetworkToHostInt(ConsumeBytes(stream, int32Length));
            int crrElement = 0;
            OSDMap osdMap = new OSDMap();
            while (crrElement < numElements)
            {
                if (!FindByte(stream, keyBinaryMarker))
                    throw new OSDException("Binary LLSD parsing: Missing key marker in map.");
                int keyLength = NetworkToHostInt(ConsumeBytes(stream, int32Length));
                String key = new String(ConsumeBytes(stream, keyLength), "UTF-8");
                osdMap.put(key, ParseLLSDBinaryElement(stream));
                crrElement++;
            }

            if (!FindByte(stream, mapEndBinaryMarker))
                throw new OSDException("Binary LLSD parsing: Missing end marker in map.");
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.structureddata.OSDMap

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.