Esempio n. 1
0
 void AttachmentSeen(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation)
 {
     lock (Attachments)
     {
         Attachments.Add(prim.LocalID);
     }
 }
Esempio n. 2
0
        static void CollectTextures(PrimObject prim, Dictionary <UUID, UUID> textureList)
        {
            if (prim.Textures != null)
            {
                // Add all of the textures on this prim to the save list
                if (prim.Textures.DefaultTexture != null)
                {
                    textureList[prim.Textures.DefaultTexture.TextureID] = prim.Textures.DefaultTexture.TextureID;
                }

                if (prim.Textures.FaceTextures != null)
                {
                    foreach (var face in prim.Textures.FaceTextures)
                    {
                        if (face != null)
                        {
                            textureList[face.TextureID] = face.TextureID;
                        }
                    }
                }
                if (prim.Sculpt != null && prim.Sculpt.Texture != UUID.Zero)
                {
                    textureList[prim.Sculpt.Texture] = prim.Sculpt.Texture;
                }
            }
        }
Esempio n. 3
0
        public PrimVisualCylinder(PrimObject prim)
            : base(prim)
        {
            NumberFaces    = 1;
            FirstOuterFace = 0;
            LastOuterFace  = 0;

            OuterFaces    = new CrossSection[1];
            OuterFaces[0] = new CrossSection();

            if (prim.ProfileHollow != 0)
            {
                hollow        = true;
                InnerFaces    = new CrossSection[1];
                InnerFaces[0] = new CrossSection();

                //for (int i = 0; i < 4; i++)
                //{
                //    InnerFaces[i] = new CrossSection();
                //}
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut      = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
Esempio n. 4
0
        static void CollectTextures(PrimObject prim, Dictionary <UUID, UUID> textureList)
        {
            if (prim.Textures != null)
            {
                // Add all of the textures on this prim to the save list
                if (prim.Textures.DefaultTexture != null)
                {
                    textureList[prim.Textures.DefaultTexture.TextureID] = prim.Textures.DefaultTexture.TextureID;
                }

                if (prim.Textures.FaceTextures != null)
                {
                    for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
                    {
                        Primitive.TextureEntryFace face = prim.Textures.FaceTextures[i];
                        if (face != null)
                        {
                            textureList[face.TextureID] = face.TextureID;
                        }
                    }
                }
                if (prim.Sculpt != null && prim.Sculpt.Texture != UUID.Zero)
                {
                    textureList[prim.Sculpt.Texture] = prim.Sculpt.Texture;
                }
            }
        }
Esempio n. 5
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            PrimObject closest         = null;
            double     closestDistance = Double.MaxValue;

            lock (TestClient.SimPrims)
            {
                if (TestClient.SimPrims.ContainsKey(Client.Network.CurrentSim))
                {
                    foreach (PrimObject p in TestClient.SimPrims[Client.Network.CurrentSim].Values)
                    {
                        float distance = Helpers.VecDist(Client.Self.Position, p.Position);

                        if (closest == null || distance < closestDistance)
                        {
                            closest         = p;
                            closestDistance = distance;
                        }
                    }
                }
            }

            if (closest != null)
            {
                Client.Self.RequestSit(closest.ID, LLVector3.Zero);
                Client.Self.Sit();

                return("Sat on " + closest.ID + ". Distance: " + closestDistance);
            }
            else
            {
                return("Couldn't find a nearby prim to sit on");
            }
        }
Esempio n. 6
0
        public void PathShear()
        {
            for (byte i = 0; i < byte.MaxValue; i++)
            {
                float floatValue = PrimObject.PathShearFloat(i);
                byte  result     = PrimObject.PathShearByte(floatValue);

                Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue +
                              ", and ended up with " + result);
            }
        }
Esempio n. 7
0
        public void PathSkew()
        {
            for (sbyte i = sbyte.MinValue; i < sbyte.MaxValue; i++)
            {
                float floatValue = PrimObject.PathSkewFloat(i);
                sbyte result     = PrimObject.PathSkewByte(floatValue);

                Assert.IsTrue(result == i, "Started with " + i + ", float value was " + floatValue +
                              ", and ended up with " + result);
            }
        }
Esempio n. 8
0
        internal void FreeAll()
        {
            mMatLib.FreeAll();

            FreeVBs();

            if (mHits != null)
            {
                mHits.Free();
                mHits = null;
            }
        }
Esempio n. 9
0
        private void PrimSeen(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation)
        {
            lock (Prims)
            {
                if (Prims.ContainsKey(prim.LocalID))
                {
                    Prims.Remove(prim.LocalID);
                }

                Prims.Add(prim.LocalID, prim);
                Log("Saw prim " + prim.ID.ToString());
            }
        }
Esempio n. 10
0
        private void Objects_OnNewPrim(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation)
        {
            lock (SimPrims)
            {
                if (!SimPrims.ContainsKey(simulator))
                {
                    SimPrims[simulator] = new Dictionary <uint, PrimObject>(10000);
                }

                SimPrims[simulator][prim.LocalID] = prim;
            }

            if ((prim.Flags & ObjectFlags.CreateSelected) != 0 && OnPrimCreated != null)
            {
                OnPrimCreated(simulator, prim);
            }
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="simulator"></param>
        /// <param name="prim"></param>
        /// <param name="regionHandle"></param>
        /// <param name="timeDilation"></param>
        void OnNewPrim(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation)
        {
            PrimVisual primVisual = PrimVisual.BuildPrimVisual(prim);

            if (primVisual != null &&
                (primVisual.GetType() == typeof(PrimVisualBox) ||
                 primVisual.GetType() == typeof(PrimVisualCylinder)))
            {
                lock (Prims)
                {
                    if (Prims.ContainsKey(prim.LocalID))
                    {
                        Prims.Remove(prim.LocalID);
                    }

                    Prims.Add(prim.LocalID, primVisual);
                }
            }
        }
        private void Objects_OnNewPrim(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation)
        {
            if (imgManager == null)
            {
                Console.WriteLine("ImageManager not ready yet, queueing Prim textures.");
                TextureQueue.Enqueue(prim.Textures.DefaultTexture.TextureID);

                foreach (TextureEntryFace tef in prim.Textures.FaceTextures.Values)
                {
                    TextureQueue.Enqueue(tef.TextureID);
                }
            }
            else
            {
                if ((prim.Textures.DefaultTexture != null) && (prim.Textures.DefaultTexture.TextureID != null))
                {
                    if (imgManager.isCachedImage(prim.Textures.DefaultTexture.TextureID) == false)
                    {
                        imgManager.RequestImageAsync(prim.Textures.DefaultTexture.TextureID);
                    }
                    else
                    {
                        Console.WriteLine("Already cached: " + prim.Textures.DefaultTexture.TextureID);
                    }
                }

                if (prim.Textures.FaceTextures != null)
                {
                    foreach (TextureEntryFace tef in prim.Textures.FaceTextures.Values)
                    {
                        if (imgManager.isCachedImage(tef.TextureID) == false)
                        {
                            imgManager.RequestImageAsync(tef.TextureID);
                        }
                        else
                        {
                            Console.WriteLine("Already cached: " + tef.TextureID);
                        }
                    }
                }
            }
        }
Esempio n. 13
0
 public static PrimVisual BuildPrimVisual(PrimObject prim)
 {
     if (prim.ProfileCurve == 1 && prim.PathCurve == 16)
     {
         // PRIM_TYPE_BOX
         return(new PrimVisualBox(prim));
     }
     else if (prim.ProfileCurve == 0 && prim.PathCurve == 16)
     {
         // PRIM_TYPE_CYLINDER
         return(new PrimVisualCylinder(prim));
     }
     else if (prim.ProfileCurve == 3 && prim.PathCurve == 16)
     {
         // PRIM_TYPE_PRISM
         return(new PrimVisualPrism(prim));
     }
     else if (prim.ProfileCurve == 5 && prim.PathCurve == 32)
     {
         // PRIM_TYPE_SPHERE
         return(new PrimVisualSphere(prim));
     }
     else if (prim.ProfileCurve == 0 && prim.PathCurve == 32)
     {
         // PRIM_TYPE_TORUS
         return(new PrimVisualTorus(prim));
     }
     else if (prim.ProfileCurve == 1 && prim.PathCurve == 32)
     {
         // PRIM_TYPE_TUBE
         return(new PrimVisualTube(prim));
     }
     else if (prim.ProfileCurve == 3 && prim.PathCurve == 32)
     {
         // PRIM_TYPE_RING
         return(new PrimVisualRing(prim));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 14
0
        public PrimVisual(PrimObject prim)
        {
            Prim        = prim;
            Vertexes    = new List <VertexPositionColor>();
            VertexArray = Vertexes.ToArray();

            Acceleration     = Vector3.Zero;
            Velocity         = Vector3.Zero;
            RotationVelocity = Vector3.Zero;

            // TODO: This is temporary, for debugging and entertainment purposes
            Random rand = new Random((int)Prim.LocalID + Environment.TickCount);
            byte   r    = (byte)rand.Next(256);
            byte   g    = (byte)rand.Next(256);
            byte   b    = (byte)rand.Next(256);

            color = new Color(r, g, b);

            BuildMatrix();
        }
Esempio n. 15
0
        public PrimVisualRing(PrimObject prim)
            : base(prim)
        {
            NumberFaces    = 3;
            FirstOuterFace = 0;
            LastOuterFace  = 2;

            ReferenceVertices = new Vector3[3];

            ReferenceVertices[0] = new Vector3(0.5f, -0.5f, 0f);
            ReferenceVertices[1] = new Vector3(0f, 0.5f, 0f);
            ReferenceVertices[2] = new Vector3(-0.5f, -0.5f, 0f);

            OuterFaces = new CrossSection[4];
            for (int i = 0; i < 4; i++)
            {
                OuterFaces[i] = new CrossSection();
            }

            if (prim.ProfileHollow != 0)
            {
                hollow     = true;
                InnerFaces = new CrossSection[4];
                for (int i = 0; i < 4; i++)
                {
                    InnerFaces[i] = new CrossSection();
                }
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut      = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
Esempio n. 16
0
        void TestClient_OnPrimCreated(Simulator simulator, PrimObject prim)
        {
            if (rezzingRootPrim)
            {
                rootLocalID = prim.LocalID;
            }

            if (!linking)
            {
                Console.WriteLine("Setting properties for " + prim.LocalID);

                primsCreated.Add(prim);

                // FIXME: Replace these individual calls with a single ObjectUpdate that sets the
                // particle system and everything
                currentClient.Objects.SetPosition(simulator, prim.LocalID, currentPosition);
                currentClient.Objects.SetTextures(simulator, prim.LocalID, currentPrim.Textures);
                //currentClient.Objects.SetLight(simulator, prim.LocalID, currentPrim.Light);
                //currentClient.Objects.SetFlexible(simulator, prim.LocalID, currentPrim.Flexible);
            }

            primDone.Set();
        }
Esempio n. 17
0
        internal TerrainLoop(GraphicsDevice gd, StuffKeeper sk, string gameRootDir)
        {
            mGD   = gd;
            mSK   = sk;
            mResX = gd.RendForm.ClientRectangle.Width;
            mResY = gd.RendForm.ClientRectangle.Height;

            mFontMats = new MatLib(gd, sk);

            mFontMats.CreateMaterial("Text");
            mFontMats.SetMaterialEffect("Text", "2D.fx");
            mFontMats.SetMaterialTechnique("Text", "Text");

            mFonts = sk.GetFontList();

            mST = new ScreenText(gd.GD, mFontMats, mFonts[0], 1000);

            mTextProj = Matrix.OrthoOffCenterLH(0, mResX, mResY, 0, 0.1f, 5f);

            string path = gameRootDir + "\\Levels\\Testa.Terrain";

            mTerrain = new Terrain(path);

            //build model for raycasts/collisions
            mTModel = mTerrain.ConstructModel();
            mTModel.FixBoxHeights();

//			Vector4	color	=Vector4.UnitY + (Vector4.UnitW * 0.15f);
            Vector4 color = Vector4.UnitX * 0.25f +
                            Vector4.UnitZ * 0.25f + (Vector4.UnitW * 0.55f);

            //string indicators for various statusy things
            mST.AddString(mFonts[0], "Stuffs", "PosStatus",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 610f, Vector2.One);
            mST.AddString(mFonts[0], "Stuffs", "ColStatus",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 630f, Vector2.One);
            mST.AddString(mFonts[0], "Thread Status...", "ThreadStatus",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 650f, Vector2.One);

            mTerMats = new MatLib(mGD, sk);

            Vector3 lightDir = Mathery.RandomDirection(mRand);

            Vector4 lightColor2 = Vector4.One * 0.4f;
            Vector4 lightColor3 = Vector4.One * 0.1f;

            lightColor2.W = lightColor3.W = 1f;

            mTerMats.CreateMaterial("Terrain");
            mTerMats.SetMaterialEffect("Terrain", "Terrain.fx");
            mTerMats.SetMaterialTechnique("Terrain", "TriTerrain");
            mTerMats.SetMaterialParameter("Terrain", "mLightColor0", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mLightColor1", lightColor2);
            mTerMats.SetMaterialParameter("Terrain", "mLightColor2", lightColor3);
            mTerMats.SetMaterialParameter("Terrain", "mLightDirection", lightDir);
            mTerMats.SetMaterialParameter("Terrain", "mSolidColour", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mSpecPower", 1);
            mTerMats.SetMaterialParameter("Terrain", "mSpecColor", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mWorld", Matrix.Identity);

            mTerMats.CreateMaterial("Sky");
            mTerMats.SetMaterialEffect("Sky", "Terrain.fx");
            mTerMats.SetMaterialTechnique("Sky", "SkyGradient");

            LoadShading(path);

            mTerMats.InitCelShading(1);
            mTerMats.GenerateCelTexturePreset(mGD.GD, mGD.GD.FeatureLevel == FeatureLevel.Level_9_3, false, 0);
            mTerMats.SetCelTexture(0);

            mSkyCube = PrimFactory.CreateCube(gd.GD, -5f);

            LoadTerrainTextureStuff(path);

            //debug draw
            mDebugMats = new MatLib(gd, sk);

            Vector4 redColor   = Vector4.One;
            Vector4 greenColor = Vector4.One;
            Vector4 blueColor  = Vector4.One;

            redColor.Y = redColor.Z = greenColor.X = greenColor.Z = blueColor.X = blueColor.Y = 0f;

            mDebugMats.CreateMaterial("DebugBoxes");
            mDebugMats.SetMaterialEffect("DebugBoxes", "Static.fx");
            mDebugMats.SetMaterialTechnique("DebugBoxes", "TriSolidSpec");
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor0", Vector4.One);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor1", lightColor2);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor2", lightColor3);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSolidColour", blueColor);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSpecPower", 1);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSpecColor", Vector4.One);

            mNumStreamThreads = 2;
            mGroundPos.Y      = 3000f;                  //start above
            mCellGridMax      = mTerrain.GetCellGridMax();
            mBoundary         = mTerrain.GetBoundary();

            Viewport vp = mGD.GetScreenViewPort();

            mGD.GCam.Projection = Matrix.PerspectiveFovLH(
                MathUtil.DegreesToRadians(45f),
                vp.Width / (float)vp.Height, 0.1f, FogEnd);

            mGD.SetClip(0.1f, FogEnd);

            mDrawRays = new DrawRays(mGD, mSK);
            mOtherCam = new GameCamera(vp.Width, vp.Height, vp.Width / (float)vp.Height, 0.1f, FogEnd);
        }
Esempio n. 18
0
        static void SOPToXml(XmlTextWriter writer, PrimObject prim, PrimObject parent)
        {
            writer.WriteStartElement("SceneObjectPart");
            writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");

            WriteUUID(writer, "CreatorID", prim.CreatorID);
            WriteUUID(writer, "FolderID", prim.FolderID);
            writer.WriteElementString("InventorySerial", (prim.Inventory != null) ? prim.Inventory.Serial.ToString() : "0");

            // FIXME: Task inventory
            writer.WriteStartElement("TaskInventory");
            if (prim.Inventory != null)
            {
                foreach (PrimObject.InventoryBlock.ItemBlock item in prim.Inventory.Items)
                {
                    writer.WriteStartElement("", "TaskInventoryItem", "");

                    WriteUUID(writer, "AssetID", item.AssetID);
                    writer.WriteElementString("BasePermissions", item.PermsBase.ToString());
                    writer.WriteElementString("CreationDate", (item.CreationDate.ToUniversalTime() - Utils.Epoch).TotalSeconds.ToString());
                    WriteUUID(writer, "CreatorID", item.CreatorID);
                    writer.WriteElementString("Description", item.Description);
                    writer.WriteElementString("EveryonePermissions", item.PermsEveryone.ToString());
                    writer.WriteElementString("Flags", item.Flags.ToString());
                    WriteUUID(writer, "GroupID", item.GroupID);
                    writer.WriteElementString("GroupPermissions", item.PermsGroup.ToString());
                    writer.WriteElementString("InvType", ((int)item.InvType).ToString());
                    WriteUUID(writer, "ItemID", item.ID);
                    WriteUUID(writer, "OldItemID", UUID.Zero);
                    WriteUUID(writer, "LastOwnerID", item.LastOwnerID);
                    writer.WriteElementString("Name", item.Name);
                    writer.WriteElementString("NextPermissions", item.PermsNextOwner.ToString());
                    WriteUUID(writer, "OwnerID", item.OwnerID);
                    writer.WriteElementString("CurrentPermissions", item.PermsOwner.ToString());
                    WriteUUID(writer, "ParentID", prim.ID);
                    WriteUUID(writer, "ParentPartID", prim.ID);
                    WriteUUID(writer, "PermsGranter", item.PermsGranterID);
                    writer.WriteElementString("PermsMask", "0");
                    writer.WriteElementString("Type", ((int)item.Type).ToString());
                    writer.WriteElementString("OwnerChanged", "false");

                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();

            PrimFlags flags = PrimFlags.None;

            if (prim.UsePhysics)
            {
                flags |= PrimFlags.Physics;
            }
            if (prim.Phantom)
            {
                flags |= PrimFlags.Phantom;
            }
            if (prim.DieAtEdge)
            {
                flags |= PrimFlags.DieAtEdge;
            }
            if (prim.ReturnAtEdge)
            {
                flags |= PrimFlags.ReturnAtEdge;
            }
            if (prim.Temporary)
            {
                flags |= PrimFlags.Temporary;
            }
            if (prim.Sandbox)
            {
                flags |= PrimFlags.Sandbox;
            }
            writer.WriteElementString("ObjectFlags", ((int)flags).ToString());

            WriteUUID(writer, "UUID", prim.ID);
            writer.WriteElementString("LocalId", prim.LocalID.ToString());
            writer.WriteElementString("Name", prim.Name);
            writer.WriteElementString("Material", ((int)prim.Material).ToString());
            writer.WriteElementString("RegionHandle", prim.RegionHandle.ToString());
            writer.WriteElementString("ScriptAccessPin", prim.RemoteScriptAccessPIN.ToString());

            Vector3 groupPosition;

            if (parent == null)
            {
                groupPosition = prim.Position;
            }
            else
            {
                groupPosition = parent.Position;
            }

            WriteVector(writer, "GroupPosition", groupPosition);
            if (prim.ParentID == 0)
            {
                WriteVector(writer, "OffsetPosition", Vector3.Zero);
            }
            else
            {
                WriteVector(writer, "OffsetPosition", prim.Position);
            }
            WriteQuaternion(writer, "RotationOffset", prim.Rotation);
            WriteVector(writer, "Velocity", prim.Velocity);
            WriteVector(writer, "RotationalVelocity", Vector3.Zero);
            WriteVector(writer, "AngularVelocity", prim.AngularVelocity);
            WriteVector(writer, "Acceleration", prim.Acceleration);
            writer.WriteElementString("Description", prim.Description);
            writer.WriteStartElement("Color");
            writer.WriteElementString("R", prim.TextColor.R.ToString(Utils.EnUsCulture));
            writer.WriteElementString("G", prim.TextColor.G.ToString(Utils.EnUsCulture));
            writer.WriteElementString("B", prim.TextColor.B.ToString(Utils.EnUsCulture));
            writer.WriteElementString("A", prim.TextColor.G.ToString(Utils.EnUsCulture));
            writer.WriteEndElement();
            writer.WriteElementString("Text", prim.Text);
            writer.WriteElementString("SitName", prim.SitName);
            writer.WriteElementString("TouchName", prim.TouchName);

            writer.WriteElementString("LinkNum", prim.LinkNumber.ToString());
            writer.WriteElementString("ClickAction", prim.ClickAction.ToString());
            writer.WriteStartElement("Shape");

            writer.WriteElementString("PathBegin", Primitive.PackBeginCut(prim.Shape.PathBegin).ToString());
            writer.WriteElementString("PathCurve", prim.Shape.PathCurve.ToString());
            writer.WriteElementString("PathEnd", Primitive.PackEndCut(prim.Shape.PathEnd).ToString());
            writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(prim.Shape.PathRadiusOffset).ToString());
            writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(prim.Shape.PathRevolutions).ToString());
            writer.WriteElementString("PathScaleX", Primitive.PackPathScale(prim.Shape.PathScaleX).ToString());
            writer.WriteElementString("PathScaleY", Primitive.PackPathScale(prim.Shape.PathScaleY).ToString());
            writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(prim.Shape.PathShearX)).ToString());
            writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(prim.Shape.PathShearY)).ToString());
            writer.WriteElementString("PathSkew", Primitive.PackPathTwist(prim.Shape.PathSkew).ToString());
            writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(prim.Shape.PathTaperX).ToString());
            writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(prim.Shape.PathTaperY).ToString());
            writer.WriteElementString("PathTwist", Primitive.PackPathTwist(prim.Shape.PathTwist).ToString());
            writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(prim.Shape.PathTwistBegin).ToString());
            writer.WriteElementString("PCode", prim.PCode.ToString());
            writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(prim.Shape.ProfileBegin).ToString());
            writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(prim.Shape.ProfileEnd).ToString());
            writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(prim.Shape.ProfileHollow).ToString());
            WriteVector(writer, "Scale", prim.Scale);
            writer.WriteElementString("State", prim.State.ToString());

            AssetPrim.ProfileShape shape = (AssetPrim.ProfileShape)(prim.Shape.ProfileCurve & 0x0F);
            HoleType hole = (HoleType)(prim.Shape.ProfileCurve & 0xF0);

            writer.WriteElementString("ProfileShape", shape.ToString());
            writer.WriteElementString("HollowShape", hole.ToString());
            writer.WriteElementString("ProfileCurve", prim.Shape.ProfileCurve.ToString());

            writer.WriteStartElement("TextureEntry");

            byte[] te;
            if (prim.Textures != null)
            {
                te = prim.Textures.GetBytes();
            }
            else
            {
                te = Utils.EmptyBytes;
            }

            writer.WriteBase64(te, 0, te.Length);
            writer.WriteEndElement();

            // FIXME: ExtraParams
            writer.WriteStartElement("ExtraParams"); writer.WriteEndElement();

            writer.WriteEndElement();

            WriteVector(writer, "Scale", prim.Scale);
            writer.WriteElementString("UpdateFlag", "0");
            WriteVector(writer, "SitTargetOrientation", Vector3.UnitZ); // TODO: Is this really a vector and not a quaternion?
            WriteVector(writer, "SitTargetPosition", prim.SitOffset);
            WriteVector(writer, "SitTargetPositionLL", prim.SitOffset);
            WriteQuaternion(writer, "SitTargetOrientationLL", prim.SitRotation);
            writer.WriteElementString("ParentID", prim.ParentID.ToString());
            writer.WriteElementString("CreationDate", ((int)Utils.DateTimeToUnixTime(prim.CreationDate)).ToString());
            writer.WriteElementString("Category", "0");
            writer.WriteElementString("SalePrice", prim.SalePrice.ToString());
            writer.WriteElementString("ObjectSaleType", ((int)prim.SaleType).ToString());
            writer.WriteElementString("OwnershipCost", "0");
            WriteUUID(writer, "GroupID", prim.GroupID);
            WriteUUID(writer, "OwnerID", prim.OwnerID);
            WriteUUID(writer, "LastOwnerID", prim.LastOwnerID);
            writer.WriteElementString("BaseMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("OwnerMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("GroupMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("EveryoneMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("NextOwnerMask", ((uint)PermissionMask.All).ToString());
            writer.WriteElementString("Flags", "None");
            WriteUUID(writer, "SitTargetAvatar", UUID.Zero);

            writer.WriteEndElement();
        }
Esempio n. 19
0
 public PrimVisualTube(PrimObject prim)
     : base(prim)
 {
     ;
 }
Esempio n. 20
0
 public LinearPrimVisual(PrimObject prim)
     : base(prim)
 {
 }
Esempio n. 21
0
 public PrimVisualSphere(PrimObject prim)
     : base(prim)
 {
     ;
 }
Esempio n. 22
0
        private void cmdImport_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Title       = "Open Prim.Blender File";
            openDialog.Filter      = "All files (*.*)|*.*|Prim files (*.prims)|*.prims";
            openDialog.FilterIndex = 2;

            if (openDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            XmlDocument xml  = new XmlDocument();
            XmlNodeList list = null;

            try
            {
                // Try to load the xml file
                xml.Load(openDialog.FileName);

                //If there is a document and it has children,
                if (xml != null && xml.HasChildNodes)
                {
                    //Get the children into the temp list
                    list = xml.GetElementsByTagName("primitive");
                }
                else
                {
                    txtLog.AppendText("ERROR: Failed to parse " + openDialog.FileName + "\n");
                    return;
                }
            }
            catch (Exception err)
            {
                txtLog.AppendText("ERROR: " + err.ToString() + "\n");
                return;
            }

            foreach (XmlNode node in list)
            {
                txtLog.AppendText("Parsing primitive " + node.Attributes["key"].Value + "\n");

                XmlNode properties = node["properties"];

                PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f"));

                prim.Material = Convert.ToUInt16(properties["material"].Attributes["val"].Value);
                prim.Name     = node.Attributes["key"].Value;
                // Either PathBegin/End or ProfileBegin/End should be dimple
                prim.PathBegin        = PrimObject.PathBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value));
                prim.PathEnd          = PrimObject.PathEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value));
                prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(Convert.ToSingle(properties["radiusoffset"].Attributes["val"].Value));
                prim.PathRevolutions  = PrimObject.PathRevolutionsByte(Convert.ToSingle(properties["revolutions"].Attributes["val"].Value));
                prim.PathScaleX       = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["x"].Value));
                prim.PathScaleY       = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["y"].Value));
                prim.PathShearX       = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["x"].Value));
                prim.PathShearY       = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["y"].Value));
                prim.PathSkew         = PrimObject.PathSkewByte(Convert.ToSingle(properties["skew"].Attributes["val"].Value));
                prim.PathTaperX       = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["x"].Value));
                prim.PathTaperY       = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["y"].Value));
                prim.PathTwist        = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["y"].Value));
                prim.PathTwistBegin   = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["x"].Value));
                prim.ProfileBegin     = PrimObject.ProfileBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value));
                prim.ProfileEnd       = PrimObject.ProfileEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value));
                ushort curve = Convert.ToUInt16(properties["type"].Attributes["val"].Value);
                switch (curve)
                {
                case 0:
                    // Box
                    prim.ProfileCurve = 1;
                    prim.PathCurve    = 16;
                    break;

                case 1:
                    // Cylinder
                    prim.ProfileCurve = 0;
                    prim.PathCurve    = 16;
                    break;

                case 2:
                    // Prism
                    prim.ProfileCurve = 3;
                    prim.PathCurve    = 16;
                    break;

                case 3:
                    // Sphere
                    prim.ProfileCurve = 5;
                    prim.PathCurve    = 32;
                    break;

                case 4:
                    // Torus
                    prim.ProfileCurve = 0;
                    prim.PathCurve    = 32;
                    break;

                case 5:
                    // Tube
                    prim.ProfileCurve = 1;
                    prim.PathCurve    = 32;
                    break;

                case 6:
                    // Ring
                    prim.ProfileCurve = 3;
                    prim.PathCurve    = 16;
                    break;
                }
                prim.ProfileHollow = Convert.ToUInt32(properties["hollow"].Attributes["val"].Value);
                prim.Rotation      = new LLQuaternion(
                    Convert.ToSingle(properties["rotation"].Attributes["x"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["y"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["z"].Value),
                    Convert.ToSingle(properties["rotation"].Attributes["s"].Value));
                prim.Scale = new LLVector3(
                    Convert.ToSingle(properties["size"].Attributes["x"].Value),
                    Convert.ToSingle(properties["size"].Attributes["y"].Value),
                    Convert.ToSingle(properties["size"].Attributes["z"].Value));

                LLVector3 position = new LLVector3(
                    Convert.ToSingle(properties["position"].Attributes["x"].Value) + (float)Client.Avatar.Position.X,
                    Convert.ToSingle(properties["position"].Attributes["y"].Value) + (float)Client.Avatar.Position.Y,
                    Convert.ToSingle(properties["position"].Attributes["z"].Value) + (float)Client.Avatar.Position.Z + 50.0F);
                prim.Position = position;

                CurrentPrim     = prim;
                WaitingOnUpdate = true;

                Client.CurrentRegion.RezObject(prim, position, new LLVector3(Client.Avatar.Position));

                while (WaitingOnUpdate)
                {
                    System.Threading.Thread.Sleep(100);
                    Application.DoEvents();
                }

                txtLog.AppendText("Rezzed primitive with UUID " + CurrentPrim.UUID + " and ID " + CurrentPrim.ID + " \n");

                Hashtable blocks = new Hashtable();
                Hashtable fields = new Hashtable();

                /*fields["ObjectLocalID"] = CurrentPrim.ID;
                 * blocks[fields] = "ObjectData";
                 *
                 * fields = new Hashtable();
                 *
                 * fields["AgentID"] = Client.Network.AgentID;
                 * blocks[fields] = "AgentData";
                 *
                 * Packet packet = PacketBuilder.BuildPacket("ObjectSelect", Client.Protocol, blocks, Helpers.MSG_RELIABLE);
                 * Client.Network.SendPacket(packet);
                 *
                 * System.Threading.Thread.Sleep(100);*/
                Packet packet;

                byte[] byteArray = new byte[12];
                Array.Copy(position.GetBytes(), byteArray, 12);

                fields["Data"]          = byteArray;
                fields["Type"]          = (byte)9;
                fields["ObjectLocalID"] = CurrentPrim.ID;
                blocks[fields]          = "ObjectData";

                fields = new Hashtable();

                fields["AgentID"] = Client.Network.AgentID;
                blocks[fields]    = "AgentData";

                packet = PacketBuilder.BuildPacket("MultipleObjectUpdate", Client.Protocol, blocks, Helpers.MSG_RELIABLE);
                Client.Network.SendPacket(packet);
                Client.Network.SendPacket(packet);
                Client.Network.SendPacket(packet);

                System.Threading.Thread.Sleep(500);
            }
        }
Esempio n. 23
0
 public PrimVisualTorus(PrimObject prim)
     : base(prim)
 {
     ;
 }
Esempio n. 24
0
        internal GameLoop(GraphicsDevice gd, StuffKeeper sk, string gameRootDir)
        {
            mGD   = gd;
            mSK   = sk;
            mResX = gd.RendForm.ClientRectangle.Width;
            mResY = gd.RendForm.ClientRectangle.Height;

            mFontMats = new MatLib(gd, sk);

            mFontMats.CreateMaterial("Text");
            mFontMats.SetMaterialEffect("Text", "2D.fx");
            mFontMats.SetMaterialTechnique("Text", "Text");

            mFonts = sk.GetFontList();

            mST = new ScreenText(gd.GD, mFontMats, mFonts[0], 1000);

            mTextProj = Matrix.OrthoOffCenterLH(0, mResX, mResY, 0, 0.1f, 5f);

            Vector4 color = Vector4.UnitY + (Vector4.UnitW * 0.15f);

            //string indicators for various statusy things
            mST.AddString(mFonts[0], "Stuffs", "PosStatus",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 580f, Vector2.One);
            mST.AddString(mFonts[0], "Thread Status...", "ThreadStatus",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 560f, Vector2.One);

            mTerMats = new MatLib(mGD, sk);

            Vector3 lightDir = Mathery.RandomDirection(mRand);

            Vector4 lightColor2 = Vector4.One * 0.4f;
            Vector4 lightColor3 = Vector4.One * 0.1f;

            lightColor2.W = lightColor3.W = 1f;

            mTerMats.CreateMaterial("Terrain");
            mTerMats.SetMaterialEffect("Terrain", "Terrain.fx");
            mTerMats.SetMaterialTechnique("Terrain", "TriTerrain");
            mTerMats.SetMaterialParameter("Terrain", "mLightColor0", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mLightColor1", lightColor2);
            mTerMats.SetMaterialParameter("Terrain", "mLightColor2", lightColor3);
            mTerMats.SetMaterialParameter("Terrain", "mLightDirection", lightDir);
            mTerMats.SetMaterialParameter("Terrain", "mSolidColour", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mSpecPower", 1);
            mTerMats.SetMaterialParameter("Terrain", "mSpecColor", Vector4.One);
            mTerMats.SetMaterialParameter("Terrain", "mWorld", Matrix.Identity);

            mTerMats.CreateMaterial("Sky");
            mTerMats.SetMaterialEffect("Sky", "Terrain.fx");
            mTerMats.SetMaterialTechnique("Sky", "SkyGradient");

            mTerMats.InitCelShading(1);
            mTerMats.GenerateCelTexturePreset(mGD.GD, mGD.GD.FeatureLevel == FeatureLevel.Level_9_3, false, 0);
            mTerMats.SetCelTexture(0);

            mSkyCube = PrimFactory.CreateCube(gd.GD, -5f);

            //debug draw
            mDebugMats = new MatLib(gd, sk);

            Vector4 redColor   = Vector4.One;
            Vector4 greenColor = Vector4.One;
            Vector4 blueColor  = Vector4.One;

            redColor.Y = redColor.Z = greenColor.X = greenColor.Z = blueColor.X = blueColor.Y = 0f;

            mDebugMats.CreateMaterial("DebugBoxes");
            mDebugMats.SetMaterialEffect("DebugBoxes", "Static.fx");
            mDebugMats.SetMaterialTechnique("DebugBoxes", "TriSolidSpec");
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor0", Vector4.One);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor1", lightColor2);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mLightColor2", lightColor3);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSolidColour", blueColor);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSpecPower", 1);
            mDebugMats.SetMaterialParameter("DebugBoxes", "mSpecColor", Vector4.One);
        }
Esempio n. 25
0
        public static LLPrimitive PrimObjectToLLPrim(PrimObject obj, IScene scene, IPrimMesher mesher)
        {
            Primitive prim = new Primitive();

            prim.Properties = new Primitive.ObjectProperties();

            LLPrimitive llprim = new LLPrimitive(prim, scene, mesher);

            prim.Acceleration = obj.Acceleration;
            if (obj.AllowedDrop)
            {
                prim.Flags |= PrimFlags.AllowInventoryDrop;
            }
            prim.AngularVelocity            = obj.AngularVelocity;
            llprim.AttachmentPosition       = obj.AttachmentPosition;
            llprim.AttachmentRotation       = obj.AttachmentRotation;
            llprim.BeforeAttachmentRotation = obj.BeforeAttachmentRotation;
            //obj.CameraAtOffset;
            //obj.CameraEyeOffset;
            prim.ClickAction = (ClickAction)obj.ClickAction;
            //obj.CollisionSound;
            //obj.CollisionSoundVolume;
            prim.Properties.CreationDate = obj.CreationDate;
            prim.Properties.CreatorID    = obj.CreatorID;
            prim.Properties.Description  = obj.Description;
            if (obj.DieAtEdge)
            {
                prim.Flags |= PrimFlags.DieAtEdge;
            }
            prim.Flexible            = FromPrimObjectFlexible(obj.Flexible);
            prim.Properties.FolderID = obj.FolderID;
            prim.Properties.GroupID  = obj.GroupID;
            prim.ID                     = obj.ID;
            llprim.Inventory            = FromPrimObjectInventory(llprim, obj.Inventory);
            llprim.LastAttachmentPoint  = (AttachmentPoint)obj.LastAttachmentPoint;
            prim.Properties.LastOwnerID = obj.LastOwnerID;
            prim.Light                  = FromPrimObjectLight(obj.Light);
            //obj.LinkNumber;
            prim.LocalID         = obj.LocalID;
            prim.Properties.Name = obj.Name;
            prim.OwnerID         = obj.OwnerID;
            //obj.ParentID;
            prim.ParticleSys            = FromPrimObjectParticles(obj.Particles);
            prim.Properties.Permissions = new Permissions(obj.PermsBase, obj.PermsEveryone, obj.PermsGroup, obj.PermsNextOwner, obj.PermsOwner);
            if (obj.Phantom)
            {
                prim.Flags |= PrimFlags.Phantom;
            }
            prim.Position                = obj.Position;
            prim.RegionHandle            = Util.PositionToRegionHandle(scene.MinPosition);
            llprim.RemoteScriptAccessPIN = obj.RemoteScriptAccessPIN;
            if (obj.ReturnAtEdge)
            {
                prim.Flags |= PrimFlags.ReturnAtEdge;
            }
            //obj.RezDate;
            prim.Rotation             = obj.Rotation;
            prim.Properties.SalePrice = obj.SalePrice;
            prim.Properties.SalePrice = obj.SaleType;
            if (obj.Sandbox)
            {
                prim.Flags |= PrimFlags.Sandbox;
            }
            prim.Scale = obj.Scale;
            //obj.ScriptState;
            prim.Sculpt = FromPrimObjectSculpt(obj.Sculpt);
            //obj.Selected;
            //obj.SelectorID;
            prim.PrimData           = FromPrimObjectShape(obj.Shape, obj.PCode, obj.Material);
            prim.Properties.SitName = obj.SitName;
            llprim.SitPosition      = obj.SitOffset;
            llprim.SitRotation      = obj.SitRotation;
            prim.SoundFlags         = (SoundFlags)obj.SoundFlags;
            prim.SoundGain          = obj.SoundGain;
            prim.Sound       = obj.SoundID;
            prim.SoundRadius = obj.SoundRadius;
            //obj.State;
            if (obj.Temporary)
            {
                prim.Flags |= PrimFlags.Temporary;
            }
            prim.Text                 = obj.Text;
            prim.TextColor            = obj.TextColor;
            prim.Textures             = obj.Textures;
            prim.Properties.TouchName = obj.TouchName;
            if (obj.UsePhysics)
            {
                prim.Flags |= PrimFlags.Physics;
            }
            prim.Velocity = obj.Velocity;
            //obj.VolumeDetect

            return(llprim);
        }
Esempio n. 26
0
 public Linkset()
 {
     RootPrim = new PrimObject();
     Children = new List <PrimObject>();
 }
Esempio n. 27
0
 public Linkset(PrimObject rootPrim)
 {
     RootPrim = rootPrim;
     Children = new List <PrimObject>();
 }
Esempio n. 28
0
 public RotationalPrimVisual(PrimObject prim)
     : base(prim)
 {
 }
Esempio n. 29
0
 public PrimVisualPrism(PrimObject prim)
     : base(prim)
 {
     ;
 }
Esempio n. 30
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: import inputfile.xml");
            }

            string name = args[0];
            Dictionary <uint, PrimObject> prims;

            currentClient = Client;

            try
            {
                XmlReader         reader    = XmlReader.Create(name);
                List <PrimObject> listprims = Helpers.PrimListFromXml(reader);
                reader.Close();

                // Create a dictionary indexed by the old local ID of the prims
                prims = new Dictionary <uint, PrimObject>();
                foreach (PrimObject prim in listprims)
                {
                    prims.Add(prim.LocalID, prim);
                }
            }
            catch (Exception)
            {
                return("Failed to import the object XML file, maybe it doesn't exist or is in the wrong format?");
            }

            if (!registeredCreateEvent)
            {
                TestClient.OnPrimCreated += new TestClient.PrimCreatedCallback(TestClient_OnPrimCreated);
                registeredCreateEvent     = true;
            }

            // Build an organized structure from the imported prims
            Dictionary <uint, Linkset> linksets = new Dictionary <uint, Linkset>();

            foreach (PrimObject prim in prims.Values)
            {
                if (prim.ParentID == 0)
                {
                    if (linksets.ContainsKey(prim.LocalID))
                    {
                        linksets[prim.LocalID].RootPrim = prim;
                    }
                    else
                    {
                        linksets[prim.LocalID] = new Linkset(prim);
                    }
                }
                else
                {
                    if (!linksets.ContainsKey(prim.ParentID))
                    {
                        linksets[prim.ParentID] = new Linkset();
                    }

                    linksets[prim.ParentID].Children.Add(prim);
                }
            }

            primsCreated = new List <PrimObject>();
            linking      = false;
            Console.WriteLine("Importing " + linksets.Count + " structures.");

            foreach (Linkset linkset in linksets.Values)
            {
                if (linkset.RootPrim.LocalID != 0)
                {
                    // HACK: Offset the root prim position so it's not lying on top of the original
                    // We need a more elaborate solution for importing with relative or absolute offsets
                    linkset.RootPrim.Position.Z += 3.0f;
                    currentPosition              = linkset.RootPrim.Position;

                    // Rez the root prim with no rotation
                    LLQuaternion rootRotation = linkset.RootPrim.Rotation;
                    linkset.RootPrim.Rotation = LLQuaternion.Identity;

                    rezzingRootPrim = true;
                    currentPrim     = linkset.RootPrim;

                    Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim, linkset.RootPrim.Position);

                    if (!primDone.WaitOne(10000, false))
                    {
                        return("Rez failed, timed out while creating a prim.");
                    }
                    primDone.Reset();

                    rezzingRootPrim = false;

                    // Rez the child prims
                    foreach (PrimObject prim in linkset.Children)
                    {
                        currentPrim     = prim;
                        currentPosition = prim.Position + linkset.RootPrim.Position;

                        Client.Objects.AddPrim(Client.Network.CurrentSim, prim, currentPosition);

                        if (!primDone.WaitOne(10000, false))
                        {
                            return("Rez failed, timed out while creating a prim.");
                        }
                        primDone.Reset();
                    }

                    // Create a list of the local IDs of the newly created prims
                    List <uint> primIDs = new List <uint>();
                    foreach (PrimObject prim in primsCreated)
                    {
                        if (prim.LocalID != rootLocalID)
                        {
                            primIDs.Add(prim.LocalID);
                        }
                    }
                    // Make sure the root object is the last in our list so it becomes the new root
                    primIDs.Add(rootLocalID);

                    // Link and set the permissions + rotation
                    linking = true;

                    Client.Objects.LinkPrims(Client.Network.CurrentSim, primIDs);

                    Client.Objects.SetPermissions(Client.Network.CurrentSim, primIDs,
                                                  Helpers.PermissionWho.Everyone | Helpers.PermissionWho.Group | Helpers.PermissionWho.NextOwner,
                                                  Helpers.PermissionType.Copy | Helpers.PermissionType.Modify | Helpers.PermissionType.Move |
                                                  Helpers.PermissionType.Transfer, true);

                    Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation);

                    for (int i = 0; i < linkset.Children.Count + 1; i++)
                    {
                        primDone.WaitOne(10000, false);
                        primDone.Reset();
                    }

                    linking = false;
                }
                else
                {
                    // Skip linksets with a missing root prim
                    Console.WriteLine("WARNING: Skipping a linkset with a missing root prim");
                }

                // Reset everything for the next linkset
                primsCreated.Clear();
            }

            return("Import complete.");
        }