Ejemplo n.º 1
0
        private void Update(ActorNode actorNode)
        {
            actorNode.TreeNode.OnNameChanged();
            actorNode.TreeNode.OnOrderInParentChanged();

            for (int i = 0; i < actorNode.ChildNodes.Count; i++)
            {
                if (actorNode.ChildNodes[i] is ActorNode child)
                {
                    Update(child);
                }
            }
        }
Ejemplo n.º 2
0
        private bool ValidateDragActor(ActorNode actorNode)
        {
            // Reject dragging actors not linked to scene (eg. from prefab) or in the opposite way
            var thisHasScene  = ActorNode.ParentScene != null;
            var otherHasScene = actorNode.ParentScene != null;

            if (thisHasScene != otherHasScene)
            {
                return(false);
            }

            // Reject dragging parents and itself
            return(actorNode.Actor != null && actorNode != ActorNode && actorNode.Find(Actor) == null);
        }
Ejemplo n.º 3
0
        private bool canReceiveSignal(ActorNode actor, ActorNode neighbor)
        {
            if (hasWiredConnection(actor, neighbor))
            {
                return(true);
            }

            float rx_tx_range_km   = actor.actorPos_km.distance(neighbor.actorPos_km);
            float rangeSquared_km2 = rx_tx_range_km * rx_tx_range_km;
            float commsRange_km    = actor.actor.getCommsRangeKM();
            float snr = (commsRange_km * commsRange_km) / (rangeSquared_km2 * (1 + actor.totalNoise));

            return(snr >= 1);
        }
Ejemplo n.º 4
0
        private void OnActorChildNodesDispose(ActorNode node)
        {
            // TODO: cache if selection contains any actor child node and skip this loop if no need to iterate

            // Deselect child nodes
            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (Selection.Contains(node.ChildNodes[i]))
                {
                    Deselect();
                    return;
                }
            }
        }
        private void Instance_ActorModified(Proteus.Framework.Parts.IActor actor)
        {
            ActorNode newActorNode = BuildStep(actor);

            // Find the actor node that corresponds to the old actor.
            ActorNode oldNode = FindNode(actor);

            if (oldNode != null)
            {
                ActorNode parentNode = (ActorNode)oldNode.Parent;
                parentNode.Nodes.Remove(oldNode);
                parentNode.Nodes.Add(newActorNode);
            }
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public override void PostConvert(ActorNode source)
        {
            base.PostConvert(source);

            if (source.Actor is Joint other)
            {
                // Preserve basic properties when changing joint type
                var joint = (Joint)Actor;
                joint.Target               = other.Target;
                joint.TargetAnchor         = other.TargetAnchor;
                joint.TargetAnchorRotation = other.TargetAnchorRotation;
                joint.EnableCollision      = other.EnableCollision;
            }
        }
Ejemplo n.º 7
0
        public ActorInit(uint id, TextNode textNode)
        {
            ID = id;

            Position = textNode.Convert <CPos>();

            var node = new ActorNode(id, Position, textNode.Children);

            Type = node.Type;

            Team     = node.Team;
            IsPlayer = node.IsPlayer;
            IsBot    = node.IsBot;

            var list  = new List <TextNode>();
            var order = (short)(textNode.Order + 1);

            list.Add(new TextNode("ActorInit", order, "Team", node.Team));
            list.Add(new TextNode("ActorInit", order, "Type", ActorCache.Types[node.Type]));
            if (node.IsBot)
            {
                var parent = new TextNode("ActorInit", order, "BotPart", string.Empty);
                list.Add(parent);
                parent.Children.Add(new TextNode("ActorInit", (short)(order + 1), "TargetPosition", node.BotTarget));
            }
            if (node.IsPlayer)
            {
                list.Add(new TextNode("ActorInit", order, "PlayerPart", string.Empty));
            }
            if (node.Health != 1f)
            {
                if (Type.PartInfos.FirstOrDefault(p => p is Parts.HealthPartInfo) is Parts.HealthPartInfo health)
                {
                    var parent = new TextNode("ActorInit", order, "HealthPart", string.Empty);
                    list.Add(parent);
                    parent.Children.Add(new TextNode("ActorInit", (short)(order + 1), "Health", node.Health * health.MaxHealth));
                }
            }
            if (node.IsPlayerSwitch)
            {
                var parent = new TextNode("ActorInit", order, "PlayerSwitchPart", string.Empty);
                list.Add(parent);
                parent.Children.Add(new TextNode("ActorInit", (short)(order + 1), "RelativeHP", node.RelativeHP));
                parent.Children.Add(new TextNode("ActorInit", (short)(order + 1), "ActorType", ActorCache.Types[node.ToActor]));
                parent.Children.Add(new TextNode("ActorInit", (short)(order + 1), "CurrentTick", node.Duration));
            }

            Nodes = list;
        }
Ejemplo n.º 8
0
 internal virtual void LinkNode(ActorNode node)
 {
     _actorNode = node;
     if (node.Actor != null)
     {
         _isActive      = node.Actor.IsActive;
         _orderInParent = node.Actor.OrderInParent;
     }
     else
     {
         _isActive      = true;
         _orderInParent = 0;
     }
     UpdateText();
 }
Ejemplo n.º 9
0
        private void BuildClique(HashSet <ISoaActor> clique, ActorNode node, int depth)
        {
            if (depth > MAX_HOPS)
            {
                return;
            }

            foreach (ActorNode neighbor in node.neighbors)
            {
                if (clique.Add(neighbor.actor))
                {
                    BuildClique(clique, neighbor, depth + 1);
                }
            }
        }
Ejemplo n.º 10
0
        private void OnActorParentChanged(Actor actor, Actor prevParent)
        {
            ActorNode node       = null;
            var       parentNode = GetActorNode(actor.Parent);

            // Try use previous parent actor to find actor node
            var prevParentNode = GetActorNode(prevParent);

            if (prevParentNode != null)
            {
                // If should be one of the children
                node = prevParentNode.FindChildActor(actor);

                // Search whole tree if node was not found
                if (node == null)
                {
                    node = GetActorNode(actor);
                }
            }
            else if (parentNode != null)
            {
                // Create new node for that actor (user may unlink it from the scene before and now link it)
                node = SceneGraphFactory.BuildActorNode(actor);
            }
            if (node == null)
            {
                return;
            }

            // Get the new parent node (may be missing)
            if (parentNode != null)
            {
                // Change parent
                node.TreeNode.UnlockChildrenRecursive();
                node.ParentNode = parentNode;
            }
            else
            {
                // Check if actor is selected in editor
                if (Editor.SceneEditing.Selection.Contains(node))
                {
                    Editor.SceneEditing.Deselect();
                }

                // Remove node (user may unlink actor from the scene but not destroy the actor)
                node.Dispose();
            }
        }
Ejemplo n.º 11
0
        private void OnActorDeleted(ActorNode node)
        {
            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (node.ChildNodes[i] is ActorNode child)
                {
                    i--;
                    OnActorDeleted(child);
                }
            }

            ActorRemoved?.Invoke(node);

            // Cleanup part of the graph
            node.Dispose();
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Helper function, recursively finds the Prefab Root of node or null.
 /// </summary>
 /// <param name="node">The node from which to start.</param>
 /// <returns>The prefab root or null.</returns>
 public ActorNode GetPrefabRootInParent(ActorNode node)
 {
     if (!node.HasPrefabLink)
     {
         return(null);
     }
     if (node.Actor.IsPrefabRoot)
     {
         return(node);
     }
     if (node.ParentNode is ActorNode parAct)
     {
         return(GetPrefabRootInParent(parAct));
     }
     return(null);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Recursively walks up from the node up to ceiling node(inclusive) or selection(exclusive).
 /// </summary>
 /// <param name="node">The node from which to start</param>
 /// <param name="ceiling">The ceiling(inclusive)</param>
 /// <returns>The node to select.</returns>
 public ActorNode WalkUpAndFindActorNodeBeforeSelection(ActorNode node, ActorNode ceiling)
 {
     if (node == ceiling || _selection.Contains(node))
     {
         return(node);
     }
     if (node.ParentNode is ActorNode parentNode)
     {
         if (_selection.Contains(node.ParentNode))
         {
             return(node);
         }
         return(WalkUpAndFindActorNodeBeforeSelection(parentNode, ceiling));
     }
     return(node);
 }
        private ActorNode FindStep(TreeNodeCollection nodes, Framework.Parts.IActor actor)
        {
            foreach (ActorNode n in nodes)
            {
                if (n.Actor == actor)
                {
                    return(n);
                }

                ActorNode subNode = FindStep(n.Nodes, actor);

                if (subNode != null)
                {
                    return(subNode);
                }
            }

            return(null);
        }
Ejemplo n.º 15
0
 public void Start()
 {
     if (m_ActorGameObject != null)
     {
         m_ActorBase = m_ActorGameObject.GetComponent <ActorBaseComponent>();
         if (m_ActorBase != null)
         {
             m_MountNode = m_ActorBase.GetActorNode(m_NodeName);
             if (m_MountNode != null)
             {
                 m_ActorBase.AddFinalFormDependent(this);
             }
             //if(go != null)
             //{
             //gameObject.transform.SetParent(go.transform, false);
             //}
         }
     }
 }
Ejemplo n.º 16
0
        private void OnActorParentChanged(Actor actor, Actor prevParent)
        {
            ActorNode node = null;

            // Try use previous parent actor to find actor node
            var prevParentNode = GetActorNode(prevParent);

            if (prevParentNode != null)
            {
                // If should be one of the children
                node = prevParentNode.FindChildActor(actor);

                // Search whole tree if node was not found
                if (node == null)
                {
                    node = GetActorNode(actor);
                }
            }
            else
            {
                // Create new node for that actor (user may unlink it from the scene before and now link it)
                node = SceneGraphFactory.BuildActorNode(actor);
            }
            if (node == null)
            {
                return;
            }

            // Get the new parent node (may be missing)
            var parentNode = GetActorNode(actor.Parent);

            if (parentNode != null)
            {
                // Change parent
                node.ParentNode = parentNode;
            }
            else
            {
                // Remove node (user may unlink actor from the scene but not destroy the actor)
                node.Dispose();
            }
        }
Ejemplo n.º 17
0
        internal virtual void LinkNode(ActorNode node)
        {
            _actorNode = node;
            if (node.Actor != null)
            {
                _orderInParent = node.Actor.OrderInParent;

                var id = node.Actor.ID;
                if (Editor.Instance.ProjectCache.IsExpandedActor(ref id))
                {
                    Expand(true);
                }
            }
            else
            {
                _orderInParent = 0;
            }

            UpdateText();
        }
Ejemplo n.º 18
0
        private void OnDirty(ActorNode node)
        {
            var options = Editor.Options.Options;
            var isPlayMode = Editor.StateMachine.IsPlayMode;
            var actor = node.Actor;

            // Auto CSG mesh rebuild
            if (!isPlayMode && options.General.AutoRebuildCSG)
            {
                if (actor is BoxBrush && actor.Scene)
                    actor.Scene.BuildCSG(options.General.AutoRebuildCSGTimeoutMs);
            }

            // Auto NavMesh rebuild
            if (!isPlayMode && options.General.AutoRebuildNavMesh && actor.Scene && node.AffectsNavigationWithChildren)
            {
                var bounds = actor.BoxWithChildren;
                Navigation.BuildNavMesh(actor.Scene, bounds, options.General.AutoRebuildNavMeshTimeoutMs);
            }
        }
Ejemplo n.º 19
0
        private void computeNeighbors(IEnumerable <ISoaActor> team)
        {
            foreach (ISoaActor soaActor in team)
            {
                ActorNode node = nodes[soaActor.getID()];

                foreach (ISoaActor neighborActor in team)
                {
                    if (soaActor == neighborActor)
                    {
                        continue;
                    }

                    ActorNode neighborNode = nodes[neighborActor.getID()];

                    if (canReceiveSignal(node, neighborNode))
                    {
                        neighborNode.canSendTo(node);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        internal virtual void LinkNode(ActorNode node)
        {
            _actorNode = node;
            var actor = node.Actor;

            if (actor != null)
            {
                _orderInParent = actor.OrderInParent;
                Visible        = (actor.HideFlags & HideFlags.HideInHierarchy) == 0;

                var id = actor.ID;
                if (Editor.Instance.ProjectCache.IsExpandedActor(ref id))
                {
                    Expand(true);
                }
            }
            else
            {
                _orderInParent = 0;
            }

            UpdateText();
        }
        private ActorNode BuildStep(Framework.Parts.IActor actor)
        {
            if (actor != null)
            {
                ActorNode newNode = new ActorNode();

                newNode.Text        = actor.Name;
                newNode.ToolTipText = actor.TypeName;
                newNode.Actor       = actor;

                Framework.Parts.IActorCollection collection = actor.QueryInterface <Framework.Parts.IActorCollection>();

                if (collection != null)
                {
                    foreach (Framework.Parts.IActor a in collection)
                    {
                        newNode.Nodes.Add(BuildStep(a));
                    }
                }

                return(newNode);
            }
            return(null);
        }
        private ActorNode BuildStep( Framework.Parts.IActor actor )
        {
            if (actor != null)
            {
                ActorNode newNode = new ActorNode();

                newNode.Text        = actor.Name;
                newNode.ToolTipText = actor.TypeName;
                newNode.Actor       = actor;

                Framework.Parts.IActorCollection collection = actor.QueryInterface<Framework.Parts.IActorCollection>();

                if (collection != null)
                {
                    foreach (Framework.Parts.IActor a in collection)
                    {
                        newNode.Nodes.Add(BuildStep(a));
                    }
                }

                return newNode;
            }
            return null;
        }
Ejemplo n.º 23
0
        public void Start()
        {
            m_Actor = gameObject.GetComponent <ActorBaseComponent>();
            if (m_Actor != null)
            {
                // Get a game object from the actor, use this to mount items or query for other components.
                // GameObject headColliderGameObject = m_Actor.GetActorGameObject("HeadCollider");
                // if(headColliderGameObject != null)
                // {
                //  Collider2D collider = headColliderGameObject.GetComponent<Collider2D>();
                //  if(collider != null)
                //  {
                //      // Set it to a trigger, or do something else with it...
                //      // collider.isTrigger = true;
                //  }
                // }
                if (m_Actor.ActorInstance != null)
                {
                    m_Idle       = m_Actor.ActorInstance.GetAnimation("Idle");
                    m_Aim        = m_Actor.ActorInstance.GetAnimation("Aim2");
                    m_Walk       = m_Actor.ActorInstance.GetAnimationInstance("Walk");
                    m_Run        = m_Actor.ActorInstance.GetAnimation("Run");
                    m_WalkToIdle = m_Actor.ActorInstance.GetAnimation("WalkToIdle");

                    // We made walk an animation instance so it has it's own sense of time which lets it do things like track events.
                    m_Walk.AnimationEvent += delegate(object animationInstance, Nima.Animation.AnimationEventArgs args)
                    {
                        // Event triggered from animation.
                    };
                    ActorNode characterNode = m_Actor.ActorInstance.GetNode("Character");
                    if (characterNode != null)
                    {
                        m_GroundSpeedProperty = characterNode.GetCustomFloatProperty("GroundSpeed");
                        m_IsRunningProperty   = characterNode.GetCustomBooleanProperty("IsRunning");
                    }
                    // Calculate aim slices.
                    if (m_Aim != null)
                    {
                        ActorNode muzzle = m_Actor.ActorInstance.GetNode("Muzzle");
                        if (muzzle != null)
                        {
                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                m_Actor.ActorInstance.Advance(0.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point    = new Vec2D(worldTransform[4] * ActorAsset.NimaToUnityScale, worldTransform[5] * ActorAsset.NimaToUnityScale);
                                m_AimLookup[i] = slice;
                            }
                        }
                        if (m_Walk != null)
                        {
                            m_Walk.Time = 0.0f;
                            m_Walk.Apply(1.0f);

                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                m_Actor.ActorInstance.Advance(0.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimWalkingLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point           = new Vec2D(worldTransform[4] * ActorAsset.NimaToUnityScale, worldTransform[5] * ActorAsset.NimaToUnityScale);
                                m_AimWalkingLookup[i] = slice;
                            }
                        }
                    }
                }
            }
            m_IdleTime = 0.0f;
        }
Ejemplo n.º 24
0
        public override void Spawn(Vector3 position, Quaternion orientation)
        {
            // create scene node
            SceneNode sceneNode = this.CreateSceneNode(position, orientation);
            Entity entity = sceneNode.GetAttachedObject(0) as Entity;

            // physics
            BodyDesc bodyDesc = new BodyDesc();
            bodyDesc.LinearVelocity = this.Velocity;

            ActorDesc actorDesc = Engine.Physics.CreateActorDesc(this, entity, position, orientation, this.Scale);
            actorDesc.Density = this.Density;
            actorDesc.Body = bodyDesc;
            actorDesc.GlobalPosition = position;
            actorDesc.GlobalOrientation = orientation.ToRotationMatrix();

            if (this.EnableCCD)
            {
                foreach (ShapeDesc shapeDesc in actorDesc.Shapes)
                    shapeDesc.ShapeFlags = ShapeFlags.DynamicDynamicCCD;
            }

            Actor actor = Engine.Physics.Scene.CreateActor(actorDesc);
            actor.UserData = this;

            ActorNode actorNode = new ActorNode(sceneNode, actor);
            Engine.World.ActorNodes.Add(actorNode);
        }
Ejemplo n.º 25
0
        public void InitializeFromAsset(ActorAsset actorAsset)
        {
            HideFlags hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild | HideFlags.DontUnloadUnusedAsset | HideFlags.HideInHierarchy | HideFlags.HideInInspector;

            m_ActorAsset = actorAsset;

            if (!actorAsset.Loaded && !actorAsset.Load())
            {
#if UNITY_EDITOR
                Debug.Log("Bad actorAsset referenced by Actor2D.");
#endif
                return;
            }

            RemoveNodes();

            m_ActorInstance = new Actor();
            m_ActorInstance.Copy(m_ActorAsset.Actor);
            OnActorInstanced();

            // Instance actor bones first as our image nodes need to know about them if they are skinned.
            {
                //ActorNode[] allNodes = m_ActorInstance.AllNodes;
                IList <Nima.ActorComponent> actorComponents = m_ActorInstance.Components;
                m_Nodes = new ActorNodeComponent[actorComponents.Count];

                int imgNodeIdx = 0;
                for (int i = 0; i < actorComponents.Count; i++)
                {
                    Nima.ActorComponent ac = actorComponents[i];
                    ActorNode           an = ac as ActorNode;
                    if (an == null)
                    {
                        continue;
                    }
                    GameObject go = null;
                    ActorImage ai = an as ActorImage;
                    if (ai != null)
                    {
                        ActorNodeComponent nodeComponent = MakeImageNodeComponent(imgNodeIdx, ai);
                        nodeComponent.Node = ai;
                        go         = nodeComponent.gameObject;
                        m_Nodes[i] = nodeComponent;
                        imgNodeIdx++;
                    }
                    else
                    {
                        ActorCollider actorCollider = an as ActorCollider;
                        if (actorCollider != null && InstanceColliders)
                        {
                            go = new GameObject(an.Name, typeof(ActorColliderComponent));
                            ActorColliderComponent colliderComponent = go.GetComponent <ActorColliderComponent>();
                            colliderComponent.Node = actorCollider;
                            m_Nodes[i]             = colliderComponent;
                        }
                        // else
                        // {
                        //  go = new GameObject(an.Name, typeof(ActorNodeComponent));

                        //  ActorNodeComponent nodeComponent = go.GetComponent<ActorNodeComponent>();
                        //  nodeComponent.Node = an;
                        //  m_Nodes[i] = nodeComponent;
                        // }
                    }

                    if (go != null)
                    {
                        go.hideFlags = hideFlags;
                    }
                }
                // After they are all created, initialize them.
                for (int i = 0; i < m_Nodes.Length; i++)
                {
                    ActorNodeComponent nodeComponent = m_Nodes[i];
                    if (nodeComponent != null)
                    {
                        nodeComponent.Initialize(this);
                    }
                }
            }

            OnActorInitialized();

#if UNITY_EDITOR
            LateUpdate();
            UpdateEditorBounds();
#endif
        }
Ejemplo n.º 26
0
        /// <inheritdoc />
        public override void Pick()
        {
            // Ensure player is not moving objects
            if (ActiveAxis != Axis.None)
            {
                return;
            }

            // Get mouse ray and try to hit any object
            var  ray             = Owner.MouseRay;
            var  view            = new Ray(Owner.ViewPosition, Owner.ViewDirection);
            var  renderView      = Owner.RenderTask.View;
            bool selectColliders = (renderView.Flags & ViewFlags.PhysicsDebug) == ViewFlags.PhysicsDebug || renderView.Mode == ViewMode.PhysicsColliders;

            SceneGraphNode.RayCastData.FlagTypes rayCastFlags = SceneGraphNode.RayCastData.FlagTypes.None;
            if (!selectColliders)
            {
                rayCastFlags |= SceneGraphNode.RayCastData.FlagTypes.SkipColliders;
            }
            var hit = Editor.Instance.Scene.Root.RayCast(ref ray, ref view, out _, rayCastFlags);

            // Update selection
            var sceneEditing = Editor.Instance.SceneEditing;

            if (hit != null)
            {
                // For child actor nodes (mesh, link or sth) we need to select it's owning actor node first or any other child node (but not a child actor)
                if (hit is ActorChildNode actorChildNode && !actorChildNode.CanBeSelectedDirectly)
                {
                    var  parentNode         = actorChildNode.ParentNode;
                    bool canChildBeSelected = sceneEditing.Selection.Contains(parentNode);
                    if (!canChildBeSelected)
                    {
                        for (int i = 0; i < parentNode.ChildNodes.Count; i++)
                        {
                            if (sceneEditing.Selection.Contains(parentNode.ChildNodes[i]))
                            {
                                canChildBeSelected = true;
                                break;
                            }
                        }
                    }

                    if (canChildBeSelected && sceneEditing.Selection.Count > 1)
                    {
                        // Don't select child node if multiple nodes are selected
                        canChildBeSelected = false;
                    }

                    if (!canChildBeSelected)
                    {
                        // Select parent
                        hit = parentNode;
                    }
                }

                // Select prefab root and then go down until you find the actual item in which case select the prefab root again
                if (hit is ActorNode actorNode)
                {
                    ActorNode prefabRoot = GetPrefabRootInParent(actorNode);
                    if (prefabRoot != null && actorNode != prefabRoot)
                    {
                        hit = WalkUpAndFindActorNodeBeforeSelection(actorNode, prefabRoot);
                    }
                }

                bool addRemove  = Owner.IsControlDown;
                bool isSelected = sceneEditing.Selection.Contains(hit);

                if (addRemove)
                {
                    if (isSelected)
                    {
                        sceneEditing.Deselect(hit);
                    }
                    else
                    {
                        sceneEditing.Select(hit, true);
                    }
                }
                else
                {
                    sceneEditing.Select(hit);
                }
            }
            else
            {
                sceneEditing.Deselect();
            }
        }
Ejemplo n.º 27
0
 private bool hasWiredConnection(ActorNode actor, ActorNode neighbor)
 {
     return((actor.isBalloon() && neighbor.isBaseStation()) ||
            (actor.isBaseStation() && neighbor.isBalloon()));
 }
Ejemplo n.º 28
0
        public override void init()
        {
            #region ground
            MeshManager.Singleton.CreatePlane("ground",
                                              ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                                              new Plane(Mogre.Vector3.UNIT_Y, 0),
                                              1500, 1500, 20, 20, true, 1, 5, 5, Mogre.Vector3.UNIT_Z);
            // Create a ground plane
            entities.Add(OgreWindow.Instance.mSceneMgr.CreateEntity("GroundEntity", "ground"));
            entities["GroundEntity"].CastShadows = false;
            entities["GroundEntity"].SetMaterialName("dirt");
            nodes.Add(OgreWindow.Instance.mSceneMgr.RootSceneNode.CreateChildSceneNode("ground"));
            nodes["ground"].AttachObject(entities["GroundEntity"]);
            nodes["ground"].Position = new Mogre.Vector3(0f, 0f, 0f) + Location().toMogre;

            // the actor properties control the mass, position and orientation
            // if you leave the body set to null it will become a static actor and wont move
            ActorDesc actorDesc2 = new ActorDesc();
            actorDesc2.Density           = 4;
            actorDesc2.Body              = null;
            actorDesc2.GlobalPosition    = nodes["ground"].Position;
            actorDesc2.GlobalOrientation = nodes["ground"].Orientation.ToRotationMatrix();


            PhysXHelpers.StaticMeshData meshdata = new PhysXHelpers.StaticMeshData(entities["GroundEntity"].GetMesh());
            actorDesc2.Shapes.Add(PhysXHelpers.CreateTriangleMesh(meshdata));
            Actor actor2 = null;
            try { actor2 = OgreWindow.Instance.scene.CreateActor(actorDesc2); }
            catch (System.AccessViolationException ex) { log(ex.ToString()); }
            if (actor2 != null)
            {
                // create our special actor node to tie together the scene node and actor that we can update its position later
                ActorNode actorNode2 = new ActorNode(nodes["ground"], actor2);
                actors.Add(actorNode2);
            }
            #endregion



            lights.Add(OgreWindow.Instance.mSceneMgr.CreateLight("playerLight"));
            lights["playerLight"].Type           = Light.LightTypes.LT_POINT;
            lights["playerLight"].Position       = Location().toMogre;
            lights["playerLight"].DiffuseColour  = ColourValue.White;
            lights["playerLight"].SpecularColour = ColourValue.White;

            #region drone

            OgreWindow.Instance.skeletons["\\Drone.skeleton"].Load();
            OgreWindow.Instance.meshes["\\Drone.mesh"].Load();
            OgreWindow.Instance.meshes["\\Drone.mesh"].SkeletonName = "\\Drone.skeleton";

            entities.Add(OgreWindow.Instance.mSceneMgr.CreateEntity("drone", "\\Drone.mesh"));

            entities["drone"].CastShadows = true;
            walkState         = entities["drone"].GetAnimationState("walk");
            walkState.Enabled = true;
            walkState.Loop    = true;
            entities["drone"].SetMaterialName("metal");
            nodes.Add(OgreWindow.Instance.mSceneMgr.RootSceneNode.CreateChildSceneNode("drone"));
            nodes["drone"].AttachObject(entities["drone"]);
            nodes["drone"].Position = new Mogre.Vector3(0f, 40f, 0f) + Location().toMogre;
            nodes["drone"].Scale(new Mogre.Vector3(.3f));

            nodes.Add(nodes["drone"].CreateChildSceneNode("orbit0"));
            nodes.Add(nodes["orbit0"].CreateChildSceneNode("orbit"));
            nodes["orbit"].Position = Location().toMogre;
            nodes["orbit"].AttachObject(OgreWindow.Instance.mCamera);
            nodes["drone"].SetFixedYawAxis(true);



            #endregion


            //#region baseball
            //entities.Add(OgreWindow.Instance.mSceneMgr.CreateEntity("baseball", "\\baseball.mesh"));
            //entities["baseball"].SetMaterialName("baseball");
            ////nodes.Add(OgreWindow.Instance.mSceneMgr.RootSceneNode.CreateChildSceneNode("baseball"));
            //nodes.Add(nodes["drone"].CreateChildSceneNode("baseball"));
            //nodes["baseball"].AttachObject(entities["baseball"]);
            //nodes["baseball"].SetScale(.5f, .5f, .5f);
            //nodes["baseball"].SetPosition(-3f, 7f, 3f);
            //// nodes["baseball"].SetScale(5f, 5f, 5f);
            //#endregion

            #region player physics
            bcd     = new BoxControllerDesc();
            control = OgreWindow.Instance.physics.ControllerManager.CreateController(OgreWindow.Instance.scene, bcd); //System.NullReferenceException
            #endregion

            nodes.Add(OgreWindow.Instance.mSceneMgr.RootSceneNode.CreateChildSceneNode("suspensionY"));

            OgreWindow.g_m.MouseMoved += new MouseListener.MouseMovedHandler(mouseMoved);
            middlemousetimer.reset();
            middlemousetimer.start();

            this.btnLimiter_F.reset();
            this.btnLimiter_F.start();

            ready = true;
            new Thread(new ThreadStart(controlThread)).Start();
            new Thread(new ThreadStart(statusUpdaterThread)).Start();

            localY = nodes["drone"]._getDerivedOrientation() * Mogre.Vector3.UNIT_Y;
            localZ = nodes["drone"]._getDerivedOrientation() * Mogre.Vector3.UNIT_Z;
            localX = nodes["drone"]._getDerivedOrientation() * Mogre.Vector3.UNIT_X;

            OgreWindow.Instance.tbTextToSend.GotFocus  += new EventHandler(tbTextToSend_GotFocus);
            OgreWindow.Instance.tbTextToSend.LostFocus += new EventHandler(tbTextToSend_LostFocus);
            OgreWindow.Instance.tbConsole.GotFocus     += new EventHandler(tbConsole_GotFocus);
            OgreWindow.Instance.tbConsole.LostFocus    += new EventHandler(tbConsole_LostFocus);
        }
Ejemplo n.º 29
0
        private void OnActorNameChanged(Actor actor)
        {
            ActorNode node = GetActorNode(actor);

            node?.TreeNode.OnNameChanged();
        }
Ejemplo n.º 30
0
 private bool ValidateDragActor(ActorNode actor)
 {
     return(true);
 }
Ejemplo n.º 31
0
 private bool ValidateDragActors(ActorNode actor)
 {
     return(actor.CanCreatePrefab && Editor.Instance.Windows.ContentWin.CurrentViewFolder.CanHaveAssets);
 }
Ejemplo n.º 32
0
        private void OnActorOrderInParentChanged(Actor actor)
        {
            ActorNode node = GetActorNode(actor);

            node?.TreeNode.OnOrderInParentChanged();
        }