Beispiel #1
0
            public OSD GetOSD(int faceNumber)
            {
                OSDMap tex = new OSDMap(10);

                if (faceNumber >= 0)
                {
                    tex["face_number"] = OSD.FromInteger(faceNumber);
                }
                tex["colors"]      = OSD.FromColor4(RGBA);
                tex["scales"]      = OSD.FromReal(RepeatU);
                tex["scalet"]      = OSD.FromReal(RepeatV);
                tex["offsets"]     = OSD.FromReal(OffsetU);
                tex["offsett"]     = OSD.FromReal(OffsetV);
                tex["imagerot"]    = OSD.FromReal(Rotation);
                tex["bump"]        = OSD.FromInteger((int)Bump);
                tex["shiny"]       = OSD.FromInteger((int)Shiny);
                tex["fullbright"]  = OSD.FromBoolean(Fullbright);
                tex["media_flags"] = OSD.FromInteger(Convert.ToInt32(MediaFlags));
                tex["mapping"]     = OSD.FromInteger((int)TexMapType);
                tex["glow"]        = OSD.FromReal(Glow);

                if (TextureID != Primitive.TextureEntry.WHITE_TEXTURE)
                {
                    tex["imageid"] = OSD.FromUUID(TextureID);
                }
                else
                {
                    tex["imageid"] = OSD.FromUUID(UUID.Zero);
                }

                return(tex);
            }
Beispiel #2
0
            public OSD GetOSD()
            {
                OSDMap map = new OSDMap();

                map["color"]     = OSD.FromColor4(Color);
                map["intensity"] = OSD.FromReal(Intensity);
                map["radius"]    = OSD.FromReal(Radius);
                map["cutoff"]    = OSD.FromReal(Cutoff);
                map["falloff"]   = OSD.FromReal(Falloff);

                return(map);
            }
Beispiel #3
0
        private Color4 GetFaceColor(Primitive.TextureEntryFace face)
        {
            Color4 color;

            if (face.TextureID == UUID.Zero)
            {
                return(face.RGBA);
            }

            if (!m_colors.TryGetValue(face.TextureID, out color))
            {
                bool fetched = false;

                // Attempt to fetch the texture metadata
                UUID      metadataID = UUID.Combine(face.TextureID, TEXTURE_METADATA_MAGIC);
                AssetBase metadata   = m_scene.AssetService.GetCached(metadataID.ToString());
                if (metadata != null)
                {
                    OSDMap map = null;
                    try { map = OSDParser.Deserialize(metadata.Data) as OSDMap; } catch { }

                    if (map != null)
                    {
                        color   = map["X-JPEG2000-RGBA"].AsColor4();
                        fetched = true;
                    }
                }

                if (!fetched)
                {
                    // Fetch the texture, decode and get the average color,
                    // then save it to a temporary metadata asset
                    AssetBase textureAsset = m_scene.AssetService.Get(face.TextureID.ToString());
                    if (textureAsset != null)
                    {
                        int width, height;
                        color = GetAverageColor(textureAsset.FullID, textureAsset.Data, out width, out height);

                        OSDMap data = new OSDMap {
                            { "X-JPEG2000-RGBA", OSD.FromColor4(color) }
                        };
                        metadata = new AssetBase
                        {
                            Data        = System.Text.Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(data)),
                            Description = "Metadata for JPEG2000 texture " + face.TextureID.ToString(),
                            Flags       = AssetFlags.Collectable,
                            FullID      = metadataID,
                            ID          = metadataID.ToString(),
                            Local       = true,
                            Temporary   = true,
                            Name        = String.Empty,
                            Type        = (sbyte)AssetType.Unknown
                        };
                        m_scene.AssetService.Store(metadata);
                    }
                    else
                    {
                        color = new Color4(0.5f, 0.5f, 0.5f, 1.0f);
                    }
                }

                m_colors[face.TextureID] = color;
            }

            return(color * face.RGBA);
        }
Beispiel #4
0
        private int GetFaceColor(Primitive.TextureEntryFace face)
        {
            int    color;
            Color4 ctmp = Color4.White;

            if (face.TextureID == UUID.Zero)
            {
                return(warp_Color.White);
            }

            if (!m_colors.TryGetValue(face.TextureID, out color))
            {
                bool fetched = false;

                // Attempt to fetch the texture metadata
                string    cacheName = "MAPCLR" + face.TextureID.ToString();
                AssetBase metadata  = m_scene.AssetService.GetCached(cacheName);
                if (metadata != null)
                {
                    OSDMap map = null;
                    try { map = OSDParser.Deserialize(metadata.Data) as OSDMap; } catch { }

                    if (map != null)
                    {
                        ctmp    = map["X-RGBA"].AsColor4();
                        fetched = true;
                    }
                }

                if (!fetched)
                {
                    // Fetch the texture, decode and get the average color,
                    // then save it to a temporary metadata asset
                    AssetBase textureAsset = m_scene.AssetService.Get(face.TextureID.ToString());
                    if (textureAsset != null)
                    {
                        int width, height;
                        ctmp = GetAverageColor(textureAsset.FullID, textureAsset.Data, out width, out height);

                        OSDMap data = new OSDMap {
                            { "X-RGBA", OSD.FromColor4(ctmp) }
                        };
                        metadata = new AssetBase
                        {
                            Data        = System.Text.Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(data)),
                            Description = "Metadata for texture color" + face.TextureID.ToString(),
                            Flags       = AssetFlags.Collectable,
                            FullID      = UUID.Zero,
                            ID          = cacheName,
                            Local       = true,
                            Temporary   = true,
                            Name        = String.Empty,
                            Type        = (sbyte)AssetType.Unknown
                        };
                        m_scene.AssetService.Store(metadata);
                    }
                    else
                    {
                        ctmp = new Color4(0.5f, 0.5f, 0.5f, 1.0f);
                    }
                }
                color = ConvertColor(ctmp);
                m_colors[face.TextureID] = color;
            }

            return(color);
        }
Beispiel #5
0
        public OSDMap GetOSD()
        {
            Primitive.ConstructionData primData = Prim.PrimData;
            Primitive.ObjectProperties properties = Prim.Properties;

            OSDMap pathMap = new OSDMap();
            pathMap["begin"] = OSD.FromReal(primData.PathBegin);
            pathMap["curve"] = OSD.FromInteger((int)primData.PathCurve);
            pathMap["end"] = OSD.FromReal(primData.PathEnd);
            pathMap["radius_offset"] = OSD.FromReal(primData.PathRadiusOffset);
            pathMap["revolutions"] = OSD.FromReal(primData.PathRevolutions);
            pathMap["scale_x"] = OSD.FromReal(primData.PathScaleX);
            pathMap["scale_y"] = OSD.FromReal(primData.PathScaleY);
            pathMap["shear_x"] = OSD.FromReal(primData.PathShearX);
            pathMap["shear_y"] = OSD.FromReal(primData.PathShearY);
            pathMap["skew"] = OSD.FromReal(primData.PathSkew);
            pathMap["taper_x"] = OSD.FromReal(primData.PathTaperX);
            pathMap["taper_y"] = OSD.FromReal(primData.PathTaperY);
            pathMap["twist"] = OSD.FromReal(primData.PathTwist);
            pathMap["twist_begin"] = OSD.FromReal(primData.PathTwistBegin);

            OSDMap profileMap = new OSDMap();
            profileMap["begin"] = OSD.FromReal(primData.ProfileBegin);
            profileMap["curve"] = OSD.FromInteger((int)primData.ProfileCurve);
            profileMap["hole"] = OSD.FromInteger((int)primData.ProfileHole);
            profileMap["end"] = OSD.FromReal(primData.ProfileEnd);
            profileMap["hollow"] = OSD.FromReal(primData.ProfileHollow);

            OSDMap propertiesMap = new OSDMap();

            if (properties != null)
            {
                propertiesMap["aggregate_perms"] = OSD.FromInteger(properties.AggregatePerms);
                propertiesMap["aggregate_perms_textures"] = OSD.FromInteger(properties.AggregatePermTextures);
                propertiesMap["aggregate_perms_textures_owner"] = OSD.FromInteger(properties.AggregatePermTexturesOwner);
                propertiesMap["category"] = OSD.FromInteger((int)properties.Category);
                propertiesMap["creation_date"] = OSD.FromDate(properties.CreationDate);
                propertiesMap["creator_id"] = OSD.FromUUID(properties.CreatorID);
                propertiesMap["description"] = OSD.FromString(properties.Description);
                propertiesMap["folder_id"] = OSD.FromUUID(properties.FolderID);
                propertiesMap["from_task_id"] = OSD.FromUUID(properties.FromTaskID);
                // properties.GroupID is redundant
                propertiesMap["inventory_serial"] = OSD.FromInteger(properties.InventorySerial);
                propertiesMap["item_id"] = OSD.FromUUID(properties.ItemID);
                propertiesMap["last_owner_id"] = OSD.FromUUID(properties.LastOwnerID);
                propertiesMap["name"] = OSD.FromString(properties.Name);
                // properties.ObjectID is redundant
                // properties.OwnerID is redundant
                propertiesMap["ownership_cost"] = OSD.FromInteger(properties.OwnershipCost);
                propertiesMap["permissions"] = properties.Permissions.GetOSD();
                propertiesMap["sale_price"] = OSD.FromInteger(properties.SalePrice);
                propertiesMap["sale_type"] = OSD.FromInteger((int)properties.SaleType);
                propertiesMap["sit_name"] = OSD.FromString(properties.SitName);
                propertiesMap["touch_name"] = OSD.FromString(properties.TouchName);
            }

            OSDMap primMap = new OSDMap();
            primMap["path"] = pathMap;
            primMap["profile"] = profileMap;
            primMap["properties"] = propertiesMap;

            primMap["acceleration"] = OSD.FromVector3(Prim.Acceleration);
            primMap["ang_velocity"] = OSD.FromVector3(Prim.AngularVelocity);
            primMap["click_action"] = OSD.FromInteger((int)Prim.ClickAction);
            primMap["flags"] = OSD.FromInteger((uint)Prim.Flags);
            primMap["group_id"] = OSD.FromUUID(Prim.GroupID);
            primMap["id"] = OSD.FromUUID(Prim.ID);
            primMap["local_id"] = OSD.FromInteger(Prim.LocalID);
            primMap["media_url"] = OSD.FromString(Prim.MediaURL);
            primMap["owner_id"] = OSD.FromUUID(Prim.OwnerID);
            primMap["parent_id"] = OSD.FromInteger(Prim.ParentID);
            primMap["particles"] = Prim.ParticleSys.GetOSD();
            primMap["position"] = OSD.FromVector3(Prim.Position);
            primMap["rotation"] = OSD.FromQuaternion(Prim.Rotation);
            primMap["scale"] = OSD.FromVector3(Prim.Scale);
            primMap["scratch_pad"] = OSD.FromBinary(Prim.ScratchPad);
            primMap["sound"] = OSD.FromUUID(Prim.Sound);
            primMap["sound_flags"] = OSD.FromInteger((int)Prim.SoundFlags);
            primMap["sound_gain"] = OSD.FromReal(Prim.SoundGain);
            primMap["sound_radius"] = OSD.FromReal(Prim.SoundRadius);
            primMap["text"] = OSD.FromString(Prim.Text);
            primMap["text_color"] = OSD.FromColor4(Prim.TextColor);
            primMap["texture_anim"] = Prim.TextureAnim.GetOSD();
            primMap["tree_species"] = OSD.FromInteger((int)Prim.TreeSpecies);
            primMap["velocity"] = OSD.FromVector3(Prim.Velocity);

            primMap["material"] = OSD.FromInteger((int)primData.Material);
            primMap["state"] = OSD.FromInteger(primData.State);
            primMap["pcode"] = OSD.FromInteger((int)primData.PCode);

            if (Prim.NameValues != null)
                primMap["name_values"] = OSD.FromString(NameValue.NameValuesToString(Prim.NameValues));
            if (Prim.Textures != null)
                primMap["textures"] = Prim.Textures.GetOSD();
            if (Prim.Light != null)
                primMap["light"] = Prim.Light.GetOSD();
            if (Prim.Flexible != null)
                primMap["flex"] = Prim.Flexible.GetOSD();
            if (Prim.Sculpt != null)
                primMap["sculpt"] = Prim.Sculpt.GetOSD();

            OSDMap map = new OSDMap();
            map["prim"] = primMap;
            map["sit_position"] = OSD.FromVector3(SitPosition);
            map["sit_rotation"] = OSD.FromQuaternion(SitRotation);
            map["attachment_position"] = OSD.FromVector3(AttachmentPosition);
            map["attachment_rotation"] = OSD.FromQuaternion(AttachmentRotation);
            map["last_attachment_point"] = OSD.FromInteger((int)LastAttachmentPoint);
            map["before_attachment_rotation"] = OSD.FromQuaternion(BeforeAttachmentRotation);
            map["rotation_axis"] = OSD.FromVector3(m_rotationAxis);
            map["link_number"] = OSD.FromInteger(m_linkNumber);
            map["remote_script_access_pin"] = OSD.FromInteger(RemoteScriptAccessPIN);
            map["inventory"] = OSD.FromString(Inventory.GetTaskInventoryAsset());

            OSDArray buttons = new OSDArray { 
                OSD.FromInteger(PayPriceButtons[0]),
                OSD.FromInteger(PayPriceButtons[1]),
                OSD.FromInteger(PayPriceButtons[2]),
                OSD.FromInteger(PayPriceButtons[3])
            };

            map["pay_price_buttons"] = buttons;
            map["pay_price"] = OSD.FromInteger(PayPrice);

            if (Prim.FaceMedia != null)
            {
                OSDArray faceMedia = new OSDArray(Prim.FaceMedia.Length);
                for (int i = 0; i < Prim.FaceMedia.Length; i++)
                {
                    MediaEntry entry = Prim.FaceMedia[i];
                    if (entry != null)
                        faceMedia.Add(entry.GetOSD());
                    else
                        faceMedia.Add(new OSD());
                }
                map["face_media"] = faceMedia;
            }
            map["media_version"] = OSD.FromString(Prim.MediaVersion);

            map["last_updated"] = OSD.FromDate(m_lastUpdated);

            return map;
        }
        private Color4 GetFaceColor(Primitive.TextureEntryFace face)
        {
            Color4 color;

            if (face.TextureID == UUID.Zero)
            {
                return(face.RGBA);
            }

            if (!m_colors.TryGetValue(face.TextureID, out color))
            {
                bool fetched = false;

                // Attempt to fetch the texture metadata
                UUID      metadataID = UUID.Combine(face.TextureID, TEXTURE_METADATA_MAGIC);
                AssetBase metadata   = m_scene.AssetService.GetCached(metadataID.ToString());
                if (metadata != null)
                {
                    OSDMap map = null;
                    try
                    {
                        map = OSDParser.Deserialize(metadata.Data) as OSDMap;
                    }
                    catch
                    {
                    }

                    if (map != null)
                    {
                        color = map["X-JPEG2000-RGBA"].AsColor4();
                        if (!(color.R == 0.5f && color.G == 0.5f && color.B == 0.5f && color.A == 1.0f))
                        {
                            //If we failed, don't save it
                            fetched = true;
                        }
                    }
                    map      = null;
                    metadata = null;
                }

                if (!fetched)
                {
                    // Fetch the texture, decode and get the average color,
                    // then save it to a temporary metadata asset
                    AssetBase textureAsset = m_scene.AssetService.Get(face.TextureID.ToString());
                    if (textureAsset != null)
                    {
                        int width, height;
                        color = GetAverageColor(textureAsset.ID, textureAsset.Data, m_scene, out width, out height);
                        if (!(color.R == 0.5f && color.G == 0.5f && color.B == 0.5f && color.A == 1.0f))
                        //If we failed, don't save it
                        {
                            OSDMap data = new OSDMap {
                                { "X-JPEG2000-RGBA", OSD.FromColor4(color) }
                            };
                            metadata = new AssetBase
                            {
                                Data        = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(data)),
                                Description = "Avg Color-JPEG2000 texture " + face.TextureID.ToString(),
                                Flags       = AssetFlags.Collectable | AssetFlags.Temperary | AssetFlags.Local,
                                ID          = metadataID,
                                Name        = String.Empty,
                                TypeAsset   = AssetType.Simstate
                                              // Make something up to get around OpenSim's myopic treatment of assets
                            };
                            metadata.ID = m_scene.AssetService.Store(metadata);
                        }
                        textureAsset = null;
                    }
                    else
                    {
                        color = new Color4(0.5f, 0.5f, 0.5f, 1.0f);
                    }
                }

                m_colors[face.TextureID] = color;
            }

            return(color * face.RGBA);
        }