コード例 #1
0
 /// <summary>
 /// The entity has classes hung off  it depending on its type. These classes
 /// will be used to differentiate and render the entity.
 /// Here we check to see if the decorating classes are on the entity and
 /// add them if they are not present.
 /// </summary>
 /// <param name="ent"></param>
 private void DecorateRenderEntity(IEntity ent)
 {
     // do we have a format converted for this entity?
     IWorldRenderConv conver;
     lock (ent) {
     if (!ent.TryGet<IWorldRenderConv>(out conver)) {
         // for the moment, we only know about LL stuff
         // TODO: Figure out how to make this dynamic, extendable and runtime
         ent.RegisterInterface<IWorldRenderConv>(RendererOgreLL.Instance);
     }
     // Depending on type, add a creation/management interface
     // If it doesn't have a rendering entity, see about adding one
     IRenderEntity re;
     if (!ent.TryGet<IRenderEntity>(out re)) {
         IEntityAvatar av;
         if (ent.TryGet<IEntityAvatar>(out av)) {
             // if it is an avatar, add the management routines
             ent.RegisterInterface<IRenderEntity>(new RenderAvatar(this, ent));
         }
         else {
             IAttachment atch;
             if (ent.TryGet<IAttachment>(out atch)) {
                 ent.RegisterInterface<IRenderEntity>(new RenderAttach(this, ent));
             }
             else {
                 ISpecialRender sprend;
                 if (ent.TryGet<ISpecialRender>(out sprend)) {
                     if (sprend.Type == SpecialRenderTypes.Foliage) {
                         ent.RegisterInterface<IRenderEntity>(new RenderFoliage(this, ent));
                     }
                     else {
                         // ent.RegisterInterface<IRenderEntity>(new RenderParticles(this, ent));
                     }
                 }
                 else {
                     // It's just a prim. Add it's management routines
                     RenderPrim rprim;
                     if (!ent.TryGet<RenderPrim>(out rprim)) {
                         ent.RegisterInterface<IRenderEntity>(new RenderPrim(this, ent));
                     }
                 }
             }
         }
     }
     }
 }
コード例 #2
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());
     }
 }