Exemplo n.º 1
0
        public void Update(UpdateCodes what)
        {
            m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage: Update");
            float priority   = m_renderer.CalculateInterestOrder(m_ent);
            bool  fullUpdate = false; // true if a full update was done on this entity

            if ((what & UpdateCodes.New) != 0)
            {
                // new entity. Gets the full treatment
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage.Update: New entity: {0}", m_ent.Name.Name);
                m_renderer.DoRenderQueued(m_ent);
                fullUpdate = true;
            }
            if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0)
            {
                // world position has changed. Tell Ogre they have changed
                string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage.Update: Updating position/rotation for {0}", entitySceneNodeName);
                Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
                                      ((what & UpdateCodes.Position) != 0),
                                      m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 0.25f,
                                      false, 1f, 1f, 1f, 1f, // don't pass scale yet
                                      ((what & UpdateCodes.Rotation) != 0),
                                      m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 0.25f);
            }
            return;
        }
 public override void Update(UpdateCodes what)
 {
     // if we are the agent in the world, also update the agent
     base.Update(what);
     if (World.Instance.Agent != null && this == World.Instance.Agent.AssociatedAvatar)
     {
         LogManager.Log.Log(LogLevel.DUPDATEDETAIL, "LLEntityAvatar: calling World.UpdateAgent: what={0}", what);
         World.Instance.UpdateAgent(what);
     }
     // do any rendering or whatever for this avatar
 }
Exemplo n.º 3
0
        private bool DoUpdateLater(DoLaterBase qInstance, object parm)
        {
            object[]             parms  = (object[])parm;
            IEntity              ent    = (IEntity)parms[0];
            UpdateCodes          detail = (UpdateCodes)parms[1];
            EntityUpdateCallback euc    = OnEntityUpdate;

            if (euc != null)
            {
                euc(ent, detail);
            }
            return(true);
        }
 // Tell the entity that something about it changed
 virtual public void Update(UpdateCodes what)
 {
     if (this.RegionContext != null)
     {
         LogManager.Log.Log(LogLevel.DUPDATEDETAIL, "EntityBase.Update calling RegionContext.UpdateEntity. w={0}", what);
         IEntityCollection coll;
         if (this.RegionContext.TryGet <IEntityCollection>(out coll))
         {
             coll.UpdateEntity(this, what);
         }
     }
     return;
 }
Exemplo n.º 5
0
 private void World_OnRegionUpdated(RegionContextBase rcontext, UpdateCodes what)
 {
     m_log.Log(LogLevel.DVIEWDETAIL, "OnRegionUpdated: ");
     if ((what & UpdateCodes.Terrain) != 0)
     {
         // This is first attempt at terrain. The description of the land comes in
         // as a heightmap defined by OMV. The renderer will have to deal with that.
         // How to generalize this so it works for any world representation?
         // What about a cylindrical spaceship world?
         Renderer.UpdateTerrain(rcontext);
     }
     // TODO: other things to test?
     return;
 }
Exemplo n.º 6
0
 public void UpdateEntity(IEntity entity, UpdateCodes detail)
 {
     m_log.Log(LogLevel.DUPDATEDETAIL, "UpdateEntity: " + entity.Name);
     if (m_shouldQueueEvent)
     {
         object[] parms = { entity, detail };
         m_workQueueEvent.DoLater(DoUpdateLater, parms);
     }
     else
     {
         if (OnEntityUpdate != null)
         {
             OnEntityUpdate(entity, detail);
         }
     }
 }
Exemplo n.º 7
0
        void World_OnWorldEntityUpdate(IEntity ent, UpdateCodes what)
        {
            IEntityAvatar av;

            if (ent.TryGet <IEntityAvatar>(out av))
            {
                // this new entity is an avatar. If we don't know it already, remember same
                lock (m_avatars) {
                    if (!m_avatars.ContainsKey(av.Name.Name))
                    {
                        LogManager.Log.Log(LogLevel.DUPDATEDETAIL, "AvatarTracker. Update Tracking avatar {0}", av.Name.Name);
                        m_avatars.Add(av.Name.Name, av);
                    }
                }
            }
            return;
        }
        /// <summary>
        /// I am being updated.
        /// Make sure the parenting is correct before telling the world about any update.
        /// </summary>
        /// <param name="what"></param>
        public override void Update(UpdateCodes what)
        {
            // Make sure parenting is correct (we're in our parent's collection)
            try {
                if (this.Prim != null)      // if no prim, no parent possible
                {
                    uint parentID = this.Prim.ParentID;
                    if (parentID != 0 && this.ContainingEntity == null)
                    {
                        what |= UpdateCodes.ParentID;
                        IEntity         parentEntity = null;
                        LLRegionContext rcontext     = (LLRegionContext)this.RegionContext;
                        rcontext.TryGetEntityLocalID(parentID, out parentEntity);
                        if (parentEntity != null)
                        {
                            this.ContainingEntity = parentEntity;
                            parentEntity.AddEntityToContainer(this);
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "ProcessEntityContainer: adding entity {0} to container {1}",
                                               this.Name, parentEntity.Name);
                        }
                        else
                        {
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "Can't assign parent. Entity not found. ent={0}", this.Name);
                        }
                    }
                    if (parentID == 0 && this.ContainingEntity != null)
                    {
                        // the prim has been removed from it's parent
                        what |= UpdateCodes.ParentID;
                        this.DisconnectFromContainer();
                    }
                }
            }
            catch (Exception e) {
                LogManager.Log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityContainer: " + e);
            }

            // tell the world about our updating
            base.Update(what);
        }
Exemplo n.º 9
0
 private void World_OnAgentUpdate(IAgent agnt, UpdateCodes what)
 {
     // m_log.Log(LogLevel.DVIEWDETAIL, "OnAgentUpdate: p={0}, h={1}", agnt.GlobalPosition.ToString(), agnt.Heading.ToString());
     if ((what & (UpdateCodes.Rotation | UpdateCodes.Position)) != 0)
     {
         // if changing position, update the camera position
         if (m_cameraMode == CameraMode.TrackingAgent)
         {
             if ((agnt != null) && (m_mainCamera != null))
             {
                 // m_mainCamera.AssociatedAgent = agnt;
                 // vector for camera position behind the avatar
                 UpdateMainCameraToAgentTracking();
             }
         }
     }
     else
     {
         m_log.Log(LogLevel.DVIEWDETAIL, "OnAgentUpdate: update code not pos or rot: {0}", what);
     }
     return;
 }
Exemplo n.º 10
0
 public void Update(UpdateCodes what)
 {
     m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage: Update");
     float priority = m_renderer.CalculateInterestOrder(m_ent);
     bool fullUpdate = false;    // true if a full update was done on this entity
     if ((what & UpdateCodes.New) != 0) {
     // new entity. Gets the full treatment
     m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage.Update: New entity: {0}", m_ent.Name.Name);
     m_renderer.DoRenderQueued(m_ent);
     fullUpdate = true;
     }
     if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0) {
     // world position has changed. Tell Ogre they have changed
     string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
     m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderFoliage.Update: Updating position/rotation for {0}", entitySceneNodeName);
     Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
         ((what & UpdateCodes.Position) != 0),
         m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 0.25f,
         false, 1f, 1f, 1f, 1f,  // don't pass scale yet
         ((what & UpdateCodes.Rotation) != 0),
         m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 0.25f);
     }
     return;
 }
 public void RenderUpdate(IEntity ent, UpdateCodes what)
 {
     return;
 }
Exemplo n.º 12
0
 // The underlying data has been updated. Forget local things.
 public void DataUpdate(UpdateCodes what) {
     // Local values are set for dead-reconning but once we have official values, use  them
     // if ((what & UpdateCodes.Position) != 0) m_haveLocalPosition = false;
     if ((what & UpdateCodes.Rotation) != 0) m_haveLocalHeading = false;
 }
        /// <summary>
        /// Update the state of the prim.
        /// </summary>
        /// <param name="what">UpdateCodes for what is being updated</param>
        /// <param name="fullUpdate">'true' if a full update (rebuild) has already been done
        ///    (usually a new prim). This means this routine is just decorating the prim and doesn't
        ///    need to rebuild the whole prim if that is necessary.</param>
        public void Update(UpdateCodes what)
        {
            float priority   = m_renderer.CalculateInterestOrder(m_ent);
            bool  fullUpdate = false; // true if a full update was done on this entity

            lock (m_ent) {
                if ((what & UpdateCodes.New) != 0)
                {
                    // new entity. Gets the full treatment
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: New entity: {0}", m_ent.Name.Name);
                    m_renderer.DoRenderQueued(m_ent);
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.New) == 0)
                {
                    // if not a new update, see what in particular is changing for this prim
                    if ((what & UpdateCodes.ParentID) != 0)
                    {
                        // prim was detached or attached. Rerender if not the first update
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: parentID changed");
                        if (!fullUpdate)
                        {
                            m_renderer.DoRenderQueued(m_ent);
                        }
                        fullUpdate = true;
                    }
                    if ((what & UpdateCodes.Material) != 0)
                    {
                        // the materials have changed on this entity. Cause materials to be recalcuated
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: Material changed");
                    }
                    if ((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0)
                    {
                        // the prim parameters were changed. Re-render if this is not the new creation request
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: prim data changed");
                        if (!fullUpdate)
                        {
                            m_renderer.DoRenderQueued(m_ent);
                        }
                        fullUpdate = true;
                    }
                    if ((what & UpdateCodes.Textures) != 0)
                    {
                        // texure on the prim were updated. Refresh them if not the initial creation update
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: textures changed");
                        // to get the textures to refresh, we must force the situation
                        IWorldRenderConv conver;
                        if (m_ent.TryGet <IWorldRenderConv>(out conver))
                        {
                            conver.RebuildEntityMaterials(priority, m_ent);
                            Ogr.RefreshResourceBF(priority, Ogr.ResourceTypeMesh,
                                                  EntityNameOgre.ConvertToOgreMeshName(m_ent.Name).Name);
                        }
                    }
                }
                if ((what & UpdateCodes.Animation) != 0)
                {
                    // the prim has changed its rotation animation
                    IAnimation anim;
                    if (m_ent.TryGet <IAnimation>(out anim))
                    {
                        IWorldRenderConv conver;
                        // Hopefully the interface with the details is attached
                        if (m_ent.TryGet <IWorldRenderConv>(out conver))
                        {
                            m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: update animation");
                            // since the entity might not have been rendererd yet, we need to queue this operstion
                            Object[] parms = { 0f, m_ent, conver, anim };
                            m_renderer.m_workQueueRender.DoLater(priority, DoUpdateAnimationLater, parms);
                        }
                        else
                        {
                            m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: animation bit without animation details");
                        }
                    }
                }
                if ((what & UpdateCodes.Text) != 0)
                {
                    // text associated with the prim changed
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: text changed");
                }
                if ((what & UpdateCodes.Particles) != 0)
                {
                    // particles associated with the prim changed
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: particles changed");
                }
                if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0)
                {
                    // world position has changed. Tell Ogre they have changed
                    string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: Updating position/rotation for {0}", entitySceneNodeName);
                    Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
                                          ((what & UpdateCodes.Position) != 0),
                                          m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 2f,
                                          false, 1f, 1f, 1f, 2f, // don't pass scale yet
                                          ((what & UpdateCodes.Rotation) != 0),
                                          m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 2f);
                }
            }
        }
Exemplo n.º 14
0
 public void RenderUpdate(IEntity ent, UpdateCodes what)
 {
     return;
 }
Exemplo n.º 15
0
        public void RenderUpdate(IEntity ent, UpdateCodes what)
        {
            m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: {0} for {1}", ent.Name.Name, what);
            bool fullUpdate = false;

            lock (ent) {
                if (ent is LLEntityBase && ((what & UpdateCodes.New) != 0))
                {
                    CreateNewPrim((LLEntityBase)ent);
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.Animation) != 0)
                {
                    // the prim has changed its rotation animation
                    IAnimation anim;
                    if (ent.TryGet <IAnimation>(out anim))
                    {
                        m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: animation ");
                        RegionRenderInfo rri;
                        if (ent.RegionContext.TryGet <RegionRenderInfo>(out rri))
                        {
                            lock (rri) {
                                rri.animations.Add(AnimatBase.CreateAnimation(anim, ((LLEntityBase)ent).Prim.LocalID));
                            }
                        }
                    }
                }
                if ((what & UpdateCodes.Text) != 0)
                {
                    // text associated with the prim changed
                    m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: text changed");
                }
                if ((what & UpdateCodes.Particles) != 0)
                {
                    // particles associated with the prim changed
                    m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: particles changed");
                }
                if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0)
                {
                    // world position has changed. Tell Ogre they have changed
                    try {
                        m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: Updating position/rotation for {0}", ent.Name.Name);
                        RegionRenderInfo rri;
                        if (ent.RegionContext.TryGet <RegionRenderInfo>(out rri))
                        {
                            lock (rri.renderPrimList) {
                                // exception if the casting does not work
                                if (((LLEntityBase)ent).Prim != null)
                                {
                                    uint localID = ((LLEntityBase)ent).Prim.LocalID;
                                    if (rri.renderPrimList.ContainsKey(localID))
                                    {
                                        RenderablePrim rp = rri.renderPrimList[localID];
                                        rp.Position = new OMV.Vector3(ent.RegionPosition.X, ent.RegionPosition.Y, ent.RegionPosition.Z);
                                        rp.Rotation = new OMV.Quaternion(ent.Heading.X, ent.Heading.Y, ent.Heading.Z, ent.Heading.W);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e) {
                        m_log.Log(LogLevel.DBADERROR, "RenderUpdate: FAIL updating pos/rot: {0}", e);
                    }
                }
            }
            return;
        }
 public void UpdateEntity(IEntity entity, UpdateCodes detail)
 {
     m_log.Log(LogLevel.DUPDATEDETAIL, "UpdateEntity: " + entity.Name);
     if (m_shouldQueueEvent) {
     object[] parms = { entity, detail };
     m_workQueueEvent.DoLater(DoUpdateLater, parms);
     }
     else {
     if (OnEntityUpdate != null) OnEntityUpdate(entity, detail);
     }
 }
 public override void Update(UpdateCodes what) {
     base.Update(what);      // this sends an EntityUpdate for the region
     if (OnRegionUpdated != null) OnRegionUpdated(this, what);
 }
Exemplo n.º 18
0
 // ==========================================================================
 /// <summary>
 /// An entity has been updated. Make the call into the renderer to move or rotate the entity.
 /// </summary>
 /// <param name="ent"></param>
 /// <param name="what"></param>
 public void RenderUpdate(IEntity ent, UpdateCodes what)
 {
     // make sure entity has all the rendering information attached to it
     DecorateRenderEntity(ent);
     IRenderEntity rent;
     // if the entity has a type specific renderer, pass the update there
     // (note: terrain comes through here but there is no IRenderEntity for terrain)
     if (ent.TryGet<IRenderEntity>(out rent)) {
     rent.Update(what);
     }
     return;
 }
Exemplo n.º 19
0
 private void World_OnRegionUpdated(RegionContextBase rcontext, UpdateCodes what)
 {
     m_log.Log(LogLevel.DVIEWDETAIL, "OnRegionUpdated: ");
     if ((what & UpdateCodes.Terrain) != 0) {
     // This is first attempt at terrain. The description of the land comes in
     // as a heightmap defined by OMV. The renderer will have to deal with that.
     // How to generalize this so it works for any world representation?
     // What about a cylindrical spaceship world?
     Renderer.UpdateTerrain(rcontext);
     }
     // TODO: other things to test?
     return;
 }
Exemplo n.º 20
0
 // ===============================================================
 public virtual void Comm_OnAgentUpdated(IAgent agnt, UpdateCodes what)
 {
     m_log.Log(LogLevel.DWORLDDETAIL, "Comm_OnAgentUpdated:");
 }
Exemplo n.º 21
0
 // For the moment, create only one animation for an entity and that is the angular rotation.
 private void ProcessEntityAnimation(IEntity ent, ref UpdateCodes updateFlags, OMV.Vector3 angularVelocity)
 {
     try {
     // if  there is an angular velocity and this is not an avatar, pass the information
     // along as an animation (llTargetOmega)
     // we convert the information into a standard form
     IEntityAvatar av;
     if (angularVelocity != OMV.Vector3.Zero) {
         if (!ent.TryGet<IEntityAvatar>(out av)) {
             float rotPerSec = angularVelocity.Length() / Constants.TWOPI;
             OMV.Vector3 axis = angularVelocity;
             axis.Normalize();
             IAnimation anim;
             if (!ent.TryGet<IAnimation>(out anim)) {
                 anim = new LLAnimation();
                 ent.RegisterInterface<IAnimation>(anim);
                 m_log.Log(LogLevel.DUPDATEDETAIL, "Created prim animation on {0}", ent.Name);
             }
             if (rotPerSec != anim.StaticRotationRotPerSec || axis != anim.StaticRotationAxis) {
                 anim.AngularVelocity = angularVelocity;   // legacy. Remove when other part plumbed
                 anim.StaticRotationAxis = axis;
                 anim.StaticRotationRotPerSec = rotPerSec;
                 anim.DoStaticRotation = true;
                 updateFlags |= UpdateCodes.Animation;
                 m_log.Log(LogLevel.DUPDATEDETAIL, "Updating prim animation on {0}", ent.Name);
             }
         }
     }
     }
     catch (Exception e) {
     m_log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityAnimation: " + e.ToString());
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Update the state of the prim.
        /// </summary>
        /// <param name="what">UpdateCodes for what is being updated</param>
        /// <param name="fullUpdate">'true' if a full update (rebuild) has already been done
        ///    (usually a new prim). This means this routine is just decorating the prim and doesn't
        ///    need to rebuild the whole prim if that is necessary.</param>
        public void Update(UpdateCodes what)
        {
            float priority = m_renderer.CalculateInterestOrder(m_ent);
            bool fullUpdate = false;    // true if a full update was done on this entity
            lock (m_ent) {
            if ((what & UpdateCodes.New) != 0) {
                // new entity. Gets the full treatment
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: New entity: {0}", m_ent.Name.Name);
                m_renderer.DoRenderQueued(m_ent);
                fullUpdate = true;
            }
            if ((what & UpdateCodes.New) == 0) {
                // if not a new update, see what in particular is changing for this prim
                if ((what & UpdateCodes.ParentID) != 0) {
                    // prim was detached or attached. Rerender if not the first update
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: parentID changed");
                    if (!fullUpdate) m_renderer.DoRenderQueued(m_ent);
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.Material) != 0) {
                    // the materials have changed on this entity. Cause materials to be recalcuated
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: Material changed");
                }
                if ((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0) {
                    // the prim parameters were changed. Re-render if this is not the new creation request
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: prim data changed");
                    if (!fullUpdate) m_renderer.DoRenderQueued(m_ent);
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.Textures) != 0) {
                    // texure on the prim were updated. Refresh them if not the initial creation update
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: textures changed");
                    // to get the textures to refresh, we must force the situation
                    IWorldRenderConv conver;
                    if (m_ent.TryGet<IWorldRenderConv>(out conver)) {
                        conver.RebuildEntityMaterials(priority, m_ent);
                        Ogr.RefreshResourceBF(priority, Ogr.ResourceTypeMesh,
                                    EntityNameOgre.ConvertToOgreMeshName(m_ent.Name).Name);
                    }
                }
            }
            if ((what & UpdateCodes.Animation) != 0) {
                // the prim has changed its rotation animation
                IAnimation anim;
                if (m_ent.TryGet<IAnimation>(out anim)) {
                    IWorldRenderConv conver;
                    // Hopefully the interface with the details is attached
                    if (m_ent.TryGet<IWorldRenderConv>(out conver)) {
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: update animation");
                        // since the entity might not have been rendererd yet, we need to queue this operstion
                        Object[] parms = { 0f, m_ent, conver, anim };
                        m_renderer.m_workQueueRender.DoLater(priority, DoUpdateAnimationLater, parms);

                    }
                    else {
                        m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: animation bit without animation details");
                    }
                }
            }
            if ((what & UpdateCodes.Text) != 0) {
                // text associated with the prim changed
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: text changed");
            }
            if ((what & UpdateCodes.Particles) != 0) {
                // particles associated with the prim changed
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: particles changed");
            }
            if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0) {
                // world position has changed. Tell Ogre they have changed
                string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderPrim.Update: Updating position/rotation for {0}", entitySceneNodeName);
                Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
                    ((what & UpdateCodes.Position) != 0),
                    m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 2f,
                    false, 1f, 1f, 1f, 2f, // don't pass scale yet
                    ((what & UpdateCodes.Rotation) != 0),
                    m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 2f);
            }
            }
        }
Exemplo n.º 23
0
 public void RenderUpdate(IEntity ent, UpdateCodes what)
 {
     m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: {0} for {1}", ent.Name.Name, what);
     bool fullUpdate = false;
     lock (ent) {
     if (ent is LLEntityBase && ((what & UpdateCodes.New) != 0)) {
         CreateNewPrim((LLEntityBase)ent);
         fullUpdate = true;
     }
     if ((what & UpdateCodes.Animation) != 0) {
         // the prim has changed its rotation animation
         IAnimation anim;
         if (ent.TryGet<IAnimation>(out anim)) {
             m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: animation ");
             RegionRenderInfo rri;
             if (ent.RegionContext.TryGet<RegionRenderInfo>(out rri)) {
                 lock (rri) {
                     rri.animations.Add(AnimatBase.CreateAnimation(anim, ((LLEntityBase)ent).Prim.LocalID));
                 }
             }
         }
     }
     if ((what & UpdateCodes.Text) != 0) {
         // text associated with the prim changed
         m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: text changed");
     }
     if ((what & UpdateCodes.Particles) != 0) {
         // particles associated with the prim changed
         m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: particles changed");
     }
     if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0) {
         // world position has changed. Tell Ogre they have changed
         try {
             m_log.Log(LogLevel.DRENDERDETAIL, "RenderUpdate: Updating position/rotation for {0}", ent.Name.Name);
             RegionRenderInfo rri;
             if (ent.RegionContext.TryGet<RegionRenderInfo>(out rri)) {
                 lock (rri.renderPrimList) {
                     // exception if the casting does not work
                     if (((LLEntityBase)ent).Prim != null) {
                         uint localID = ((LLEntityBase)ent).Prim.LocalID;
                         if (rri.renderPrimList.ContainsKey(localID)) {
                             RenderablePrim rp = rri.renderPrimList[localID];
                             rp.Position = new OMV.Vector3(ent.RegionPosition.X, ent.RegionPosition.Y, ent.RegionPosition.Z);
                             rp.Rotation = new OMV.Quaternion(ent.Heading.X, ent.Heading.Y, ent.Heading.Z, ent.Heading.W);
                         }
                     }
                 }
             }
         }
         catch (Exception e) {
             m_log.Log(LogLevel.DBADERROR, "RenderUpdate: FAIL updating pos/rot: {0}", e);
         }
     }
     }
     return;
 }
Exemplo n.º 24
0
 // Entity has been updated. Tell the world about the updates.
 private void ProcessEntityUpdates(IEntity ent, UpdateCodes updateFlags)
 {
     try {
     if (ent != null) {
         // special update for the agent so it knows there is new info from the network
         // The real logic to push the update through happens in the IEntityAvatar.Update()
         if (ent == this.MainAgent.AssociatedAvatar) {
             this.MainAgent.DataUpdate(updateFlags);
         }
         // Tell the world the entity is updated
         ent.Update(updateFlags);
     }
     }
     catch (Exception e) {
     m_log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityUpdates: " + e.ToString());
     }
 }
 void World_OnWorldRegionUpdated(RegionContextBase rcontext, UpdateCodes what)
 {
 }
Exemplo n.º 26
0
        /// <summary>
        /// I am being updated. 
        /// Make sure the parenting is correct before telling the world about any update.
        /// </summary>
        /// <param name="what"></param>
        public override void Update(UpdateCodes what)
        {
            // Make sure parenting is correct (we're in our parent's collection)
            try {
                if (this.Prim != null) {    // if no prim, no parent possible
                    uint parentID = this.Prim.ParentID;
                    if (parentID != 0 && this.ContainingEntity == null) {
                        what |= UpdateCodes.ParentID;
                        IEntity parentEntity = null;
                        LLRegionContext rcontext = (LLRegionContext)this.RegionContext;
                        rcontext.TryGetEntityLocalID(parentID, out parentEntity);
                        if (parentEntity != null) {
                            this.ContainingEntity = parentEntity;
                            parentEntity.AddEntityToContainer(this);
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "ProcessEntityContainer: adding entity {0} to container {1}",
                                             this.Name, parentEntity.Name);
                        }
                        else {
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "Can't assign parent. Entity not found. ent={0}", this.Name);
                        }
                    }
                    if (parentID == 0 && this.ContainingEntity != null) {
                        // the prim has been removed from it's parent
                        what |= UpdateCodes.ParentID;
                        this.DisconnectFromContainer();
                    }
                }
            }
            catch (Exception e) {
                LogManager.Log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityContainer: " + e);
            }

            // tell the world about our updating
            base.Update(what);
        }
Exemplo n.º 27
0
 void World_OnWorldEntityUpdate(IEntity ent, UpdateCodes what)
 {
     IEntityAvatar av;
     if (ent.TryGet<IEntityAvatar>(out av)) {
     // this new entity is an avatar. If we don't know it already, remember same
     lock (m_avatars) {
         if (!m_avatars.ContainsKey(av.Name.Name)) {
             LogManager.Log.Log(LogLevel.DUPDATEDETAIL, "AvatarTracker. Update Tracking avatar {0}", av.Name.Name );
             m_avatars.Add(av.Name.Name, av);
         }
     }
     }
     return;
 }
Exemplo n.º 28
0
 private void World_OnAgentUpdate(IAgent agnt, UpdateCodes what)
 {
     // m_log.Log(LogLevel.DVIEWDETAIL, "OnAgentUpdate: p={0}, h={1}", agnt.GlobalPosition.ToString(), agnt.Heading.ToString());
     if ((what & (UpdateCodes.Rotation | UpdateCodes.Position)) != 0) {
     // if changing position, update the camera position
     if (m_cameraMode == CameraMode.TrackingAgent) {
         if ((agnt != null) && (m_mainCamera != null)) {
             // m_mainCamera.AssociatedAgent = agnt;
             // vector for camera position behind the avatar
             UpdateMainCameraToAgentTracking();
         }
     }
     }
     else {
     m_log.Log(LogLevel.DVIEWDETAIL, "OnAgentUpdate: update code not pos or rot: {0}", what);
     }
     return;
 }
Exemplo n.º 29
0
 private void Region_OnUpdateEntity(IEntity ent, UpdateCodes what) {
     if (OnWorldEntityUpdate != null) OnWorldEntityUpdate(ent, what);
     return;
 }
 public override void Update(UpdateCodes what)
 {
     // if we are the agent in the world, also update the agent
     base.Update(what);
     if (World.Instance.Agent != null && this == World.Instance.Agent.AssociatedAvatar) {
         LogManager.Log.Log(LogLevel.DUPDATEDETAIL, "LLEntityAvatar: calling World.UpdateAgent: what={0}", what);
         World.Instance.UpdateAgent(what);
     }
     // do any rendering or whatever for this avatar
 }
Exemplo n.º 31
0
 private void Region_OnRegionUpdated(RegionContextBase rcontext, UpdateCodes what) {
     if (OnWorldRegionUpdated != null) OnWorldRegionUpdated(rcontext, what);
     return;
 }
Exemplo n.º 32
0
 public void Update(UpdateCodes what)
 {
     float priority = m_renderer.CalculateInterestOrder(m_ent);
     bool fullUpdate = false;    // true if a full update was done on this entity
     if ((what & UpdateCodes.New) != 0) {
     // new entity. Gets the full treatment
     m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: New entity: {0}", m_ent.Name.Name);
     m_renderer.DoRenderQueued(m_ent);
     fullUpdate = true;
     }
     if ((what & UpdateCodes.New) == 0) {
     // if not a new update, see what in particular is changing for this prim
     if ((what & UpdateCodes.ParentID) != 0) {
         // prim was detached or attached. Rerender if not the first update
         m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: parentID changed");
         if (!fullUpdate) m_renderer.DoRenderQueued(m_ent);
         fullUpdate = true;
     }
     if ((what & UpdateCodes.Material) != 0) {
         // the materials have changed on this entity. Cause materials to be recalcuated
         m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: Material changed");
     }
     // if (((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0))) {
     if ((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0) {
         // the prim parameters were changed. Re-render if this is not the new creation request
         m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: prim data changed");
         if (!fullUpdate) m_renderer.DoRenderQueued(m_ent);
         fullUpdate = true;
     }
     if ((what & UpdateCodes.Textures) != 0) {
         // texure on the prim were updated. Refresh them if not the initial creation update
         m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: textures changed");
         // to get the textures to refresh, we must force the situation
         IWorldRenderConv conver;
         if (m_ent.TryGet<IWorldRenderConv>(out conver)) {
             conver.RebuildEntityMaterials(priority, m_ent);
             Ogr.RefreshResourceBF(priority, Ogr.ResourceTypeMesh,
                         EntityNameOgre.ConvertToOgreMeshName(m_ent.Name).Name);
         }
     }
     }
     if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0) {
     // world position has changed. Tell Ogre they have changed
     string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
     m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAttach.Update: Updating position/rotation for {0}", entitySceneNodeName);
     Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
         ((what & UpdateCodes.Position) != 0),
         m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 0.25f,
         false, 1f, 1f, 1f, 1f,  // don't pass scale yet
         ((what & UpdateCodes.Rotation) != 0),
         m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 0.25f);
     }
 }
Exemplo n.º 33
0
 public void UpdateAgent(UpdateCodes what) {
     m_log.Log(LogLevel.DWORLDDETAIL, "UpdateAgent: ");
     if (OnAgentUpdate != null) OnAgentUpdate(m_agent, what);
 }
        public void Update(UpdateCodes what)
        {
            float priority   = m_renderer.CalculateInterestOrder(m_ent);
            bool  fullUpdate = false; // true if a full update was done on this entity

            if ((what & UpdateCodes.New) != 0)
            {
                // new entity. Gets the full treatment
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: New entity: {0}", m_ent.Name.Name);
                m_renderer.DoRenderQueued(m_ent);
                fullUpdate = true;
            }
            if ((what & UpdateCodes.New) == 0)
            {
                // if not a new update, see what in particular is changing for this prim
                if ((what & UpdateCodes.ParentID) != 0)
                {
                    // prim was detached or attached. Rerender if not the first update
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: parentID changed");
                    if (!fullUpdate)
                    {
                        m_renderer.DoRenderQueued(m_ent);
                    }
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.Material) != 0)
                {
                    // the materials have changed on this entity. Cause materials to be recalcuated
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: Material changed");
                }
                // if (((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0))) {
                if ((what & (UpdateCodes.PrimFlags | UpdateCodes.PrimData)) != 0)
                {
                    // the prim parameters were changed. Re-render if this is not the new creation request
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: prim data changed");
                    if (!fullUpdate)
                    {
                        m_renderer.DoRenderQueued(m_ent);
                    }
                    fullUpdate = true;
                }
                if ((what & UpdateCodes.Textures) != 0)
                {
                    // texure on the prim were updated. Refresh them if not the initial creation update
                    m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: textures changed");
                    // to get the textures to refresh, we must force the situation
                    IWorldRenderConv conver;
                    if (m_ent.TryGet <IWorldRenderConv>(out conver))
                    {
                        conver.RebuildEntityMaterials(priority, m_ent);
                        Ogr.RefreshResourceBF(priority, Ogr.ResourceTypeMesh,
                                              EntityNameOgre.ConvertToOgreMeshName(m_ent.Name).Name);
                    }
                }
            }
            if (!fullUpdate && (what & (UpdateCodes.Scale | UpdateCodes.Position | UpdateCodes.Rotation)) != 0)
            {
                // world position has changed. Tell Ogre they have changed
                string entitySceneNodeName = EntityNameOgre.ConvertToOgreSceneNodeName(m_ent.Name);
                m_renderer.m_log.Log(LogLevel.DRENDERDETAIL, "RenderAvatar.Update: Updating position/rotation for {0}", entitySceneNodeName);
                Ogr.UpdateSceneNodeBF(priority, entitySceneNodeName,
                                      ((what & UpdateCodes.Position) != 0),
                                      m_ent.RegionPosition.X, m_ent.RegionPosition.Y, m_ent.RegionPosition.Z, 0.25f,
                                      false, 1f, 1f, 1f, 1f, // don't pass scale yet
                                      ((what & UpdateCodes.Rotation) != 0),
                                      m_ent.Heading.W, m_ent.Heading.X, m_ent.Heading.Y, m_ent.Heading.Z, 0.25f);
            }
        }
Exemplo n.º 35
0
 void World_OnWorldRegionUpdated(RegionContextBase rcontext, UpdateCodes what)
 {
 }