Beispiel #1
0
        // save movies, actors, producers
        public string saveActorDetails(ModelActor _model)
        {
            string result = string.Empty;

            try
            {
                conn = ConntectionOpen();
                SqlCommand cmd = new SqlCommand("Usp_Actors_AddEdit", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@pUID", _model.UID);
                cmd.Parameters.AddWithValue("@pName", _model.Name);
                cmd.Parameters.AddWithValue("@pSex", _model.Sex);
                cmd.Parameters.AddWithValue("@pDOB", _model.DOB);
                cmd.Parameters.AddWithValue("@pBio", _model.Bio);
                cmd.Parameters.AddWithValue("@pInsertedBy", "Admin");
                cmd.Parameters.AddWithValue("@pMode", _model.Mode);
                cmd.Parameters.Add("@pMsg", SqlDbType.NChar, 200);
                cmd.Parameters["@pMsg"].Direction = ParameterDirection.Output;
                result = cmd.ExecuteNonQuery().ToString();
                string returnedfromDB = cmd.Parameters["@pMsg"].Value.ToString();
                if (result != "1")
                {
                    result = returnedfromDB;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message.ToString();
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
Beispiel #2
0
        public List <ModelActor> BindDDLProducers()
        {
            List <ModelActor> list = new List <ModelActor>();

            try
            {
                using (cmd = new SqlCommand("Usp_Producers_AddEdit", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@pMode", "Select");
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                    if (ds != null)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DataRow    dr  = ds.Tables[0].Rows[i];
                                ModelActor obj = new ModelActor();
                                obj.UID  = Convert.ToInt64(dr["UID"]);
                                obj.Name = dr["Name"].ToString();
                                list.Add(obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { }
            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// Updates the collision data debug model.
        /// </summary>
        private void UpdateWiresModel()
        {
            // Don't update on a importer/worker thread
            if (!Application.IsInMainThread)
            {
                _updateWireMesh = true;
                return;
            }

            if (_collisionWiresModel == null)
            {
                _collisionWiresModel = FlaxEngine.Content.CreateVirtualAsset <Model>();
                _collisionWiresModel.SetupLODs(1);
            }
            Editor.Internal_GetCollisionWires(Asset.unmanagedPtr, out var triangles, out var indices);
            if (triangles != null && indices != null)
            {
                _collisionWiresModel.LODs[0].Meshes[0].UpdateMesh(triangles, indices);
            }
            if (_collisionWiresShowActor == null)
            {
                _collisionWiresShowActor = ModelActor.New();
                _preview.Task.CustomActors.Add(_collisionWiresShowActor);
            }
            _collisionWiresShowActor.Model = _collisionWiresModel;
            _collisionWiresShowActor.Entries[0].Material = FlaxEngine.Content.LoadAsyncInternal <MaterialBase>(EditorAssets.WiresDebugMaterial);
            _preview.Model = _asset.Model;
        }
 /// <summary>
 /// Highlights the model entry.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="entryIndex">Index of the entry to highlight.</param>
 public void HighlightModel(ModelActor model, int entryIndex)
 {
     _highlights.Add(new HighlightData
     {
         Target     = model,
         EntryIndex = entryIndex
     });
 }
        /// <summary>
        /// Highlights the model.
        /// </summary>
        /// <param name="model">The model.</param>
        public void HighlightModel(ModelActor model)
        {
            if (model.Model == null)
            {
                return;
            }

            ModelEntryInfo[] entries = model.Entries;
            for (var i = 0; i < entries.Length; i++)
            {
                HighlightModel(model, i);
            }
        }
        private void SetDragEffects(ref Vector2 location)
        {
            if (_dragAssets.HasValidDrag && _dragAssets.Objects[0].ItemDomain == ContentDomain.Material)
            {
                Vector3        hitLocation = ViewPosition;
                SceneGraphNode hit;
                GetHitLocation(ref location, out hit, out hitLocation);

                if (hit is ModelActorNode.EntryNode meshNode)
                {
                    _previewModelActor           = meshNode.ModelActor;
                    _previewModelActorEntryIndex = meshNode.Index;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Creates the new scene file. The default scene contains set of simple actors.
        /// </summary>
        /// <param name="path">The path.</param>
        public void CreateSceneFile(string path)
        {
            // Create a sample scene
            var scene = Scene.New();
            var sky   = Sky.New();
            var sun   = DirectionalLight.New();
            var floor = ModelActor.New();

            //
            scene.AddChild(sky);
            scene.AddChild(sun);
            scene.AddChild(floor);
            //
            sky.Name          = "Sky";
            sky.LocalPosition = new Vector3(40, 150, 0);
            sky.SunLight      = sun;
            sky.StaticFlags   = StaticFlags.FullyStatic;
            //
            sun.Name             = "Sun";
            sun.LocalPosition    = new Vector3(40, 160, 0);
            sun.LocalEulerAngles = new Vector3(45, 0, 0);
            sun.StaticFlags      = StaticFlags.FullyStatic;
            //
            floor.Name  = "Floor";
            floor.Scale = new Vector3(4, 0.5f, 4);
            floor.Model = FlaxEngine.Content.LoadAsync <Model>(StringUtils.CombinePaths(Globals.EditorFolder, "Primitives/Cube.flax"));
            if (floor.Model)
            {
                floor.Model.WaitForLoaded();
                floor.Entries[0].Material = FlaxEngine.Content.LoadAsync <MaterialBase>(StringUtils.CombinePaths(Globals.EngineFolder, "WhiteMaterial.flax"));
            }
            floor.StaticFlags = StaticFlags.FullyStatic;

            // Serialize
            var bytes = SceneManager.SaveSceneToBytes(scene);

            // Cleanup
            Object.Destroy(scene);

            if (bytes == null || bytes.Length == 0)
            {
                throw new Exception("Failed to serialize scene.");
            }

            // Write to file
            using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
                fileStream.Write(bytes, 0, bytes.Length);
        }
Beispiel #8
0
 /// <summary>
 /// Updates the collision data debug model.
 /// </summary>
 private void UpdateWiresModel()
 {
     if (_collisionWiresModel == null)
     {
         _collisionWiresModel = FlaxEngine.Content.CreateVirtualAsset <Model>();
     }
     Editor.Internal_GetCollisionWires(Asset.unmanagedPtr, out var triangles, out var indices);
     if (triangles != null && indices != null)
     {
         _collisionWiresModel.UpdateMesh(triangles, indices);
     }
     if (_collisionWiresShowActor == null)
     {
         _collisionWiresShowActor = ModelActor.New();
         _preview.Task.CustomActors.Add(_collisionWiresShowActor);
     }
     _collisionWiresShowActor.Model = _collisionWiresModel;
     _collisionWiresShowActor.Entries[0].Material = FlaxEngine.Content.LoadAsyncInternal <MaterialBase>(EditorAssets.WiresDebugMaterial);
     _preview.Model = _asset.Model;
 }
Beispiel #9
0
        void Update()
        {
            Screen.CursorVisible = false;
            Screen.CursorLock    = CursorLockMode.Locked;

            // Mouse
            Vector2 mouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

            pitch = Mathf.Clamp(pitch + mouseDelta.Y, -88, 88);
            yaw  += mouseDelta.X;

            // Jump
            if (CanJump && Input.GetAction("Jump"))
            {
                _jump = true;
            }

            // Shoot
            if (Input.GetAction("Fire"))
            {
                var ball         = RigidBody.New();
                var ballCollider = SphereCollider.New();
                var ballModel    = ModelActor.New();
                ball.Name           = "Bullet";
                ballModel.Model     = SphereModel;
                ballModel.Parent    = ball;
                ballCollider.Parent = ball;
                ball.UseCCD         = true;
                ball.Transform      = new Transform(
                    CameraTarget.Position + Horizontal(CameraTarget.Direction) * 70.0f,
                    Quaternion.Identity,
                    new Vector3(0.1f));
                SceneManager.SpawnActor(ball);
                ball.LinearVelocity = CameraTarget.Direction * 600.0f;
                Destroy(ball, 5.0f);
            }
        }
        private void Spawn(AssetItem item, SceneGraphNode hit, ref Vector3 hitLocation)
        {
            switch (item.ItemDomain)
            {
            case ContentDomain.Material:
            {
                if (hit is ModelActorNode.EntryNode meshNode)
                {
                    var material = FlaxEngine.Content.LoadAsync <MaterialBase>(item.ID);
                    using (new UndoBlock(Undo, meshNode.ModelActor, "Change material"))
                        meshNode.Entry.Material = material;
                }
                else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode)
                {
                    var material = FlaxEngine.Content.LoadAsync <MaterialBase>(item.ID);
                    using (new UndoBlock(Undo, brushSurfaceNode.Brush, "Change material"))
                        brushSurfaceNode.Surface.Material = material;
                }

                break;
            }

            case ContentDomain.Model:
            {
                if (item.TypeName == typeof(SkinnedModel).FullName)
                {
                    var model = FlaxEngine.Content.LoadAsync <SkinnedModel>(item.ID);
                    var actor = AnimatedModel.New();
                    actor.Name         = item.ShortName;
                    actor.SkinnedModel = model;
                    actor.Position     = PostProcessSpawnedActorLocation(actor, ref hitLocation);
                    Editor.Instance.SceneEditing.Spawn(actor);
                }
                else
                {
                    var model = FlaxEngine.Content.LoadAsync <Model>(item.ID);
                    var actor = ModelActor.New();
                    actor.Name     = item.ShortName;
                    actor.Model    = model;
                    actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
                    Editor.Instance.SceneEditing.Spawn(actor);
                }

                break;
            }

            case ContentDomain.Audio:
            {
                var clip  = FlaxEngine.Content.LoadAsync <AudioClip>(item.ID);
                var actor = AudioSource.New();
                actor.Name     = item.ShortName;
                actor.Clip     = clip;
                actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
                Editor.Instance.SceneEditing.Spawn(actor);

                break;
            }

            case ContentDomain.Prefab:
            {
                var prefab = FlaxEngine.Content.LoadAsync <Prefab>(item.ID);
                var actor  = PrefabManager.SpawnPrefab(prefab, null);
                actor.Name     = item.ShortName;
                actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
                Editor.Instance.SceneEditing.Spawn(actor);

                break;
            }

            case ContentDomain.Scene:
            {
                Editor.Instance.Scene.OpenScene(item.ID, true);
                break;
            }

            default: throw new ArgumentOutOfRangeException();
            }
        }
 private void ClearDragEffects()
 {
     _previewModelActor           = null;
     _previewModelActorEntryIndex = -1;
 }
Beispiel #12
0
        public JsonResult SaveActorDetails(ModelActor act)
        {
            CommonClass obj = new CommonClass();

            return(Json(obj.saveActorDetails(act), JsonRequestBehavior.AllowGet));
        }
        /// <inheritdoc />
        public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
        {
            var result = base.OnDragDrop(ref location, data);

            if (result != DragDropEffect.None)
            {
                return(result);
            }

            // Check if drag sth
            Vector3        hitLocation = ViewPosition;
            SceneGraphNode hit         = null;

            if (_dragAssets.HasValidDrag || _dragActorType.HasValidDrag)
            {
                // Get mouse ray and try to hit any object
                var   ray     = ConvertMouseToRay(ref location);
                float closest = float.MaxValue;
                hit = Editor.Instance.Scene.Root.RayCast(ref ray, ref closest);
                if (hit != null)
                {
                    // Use hit location
                    hitLocation = ray.Position + ray.Direction * closest;
                }
                else
                {
                    // Use area in front of the viewport
                    hitLocation = ViewPosition + ViewDirection * 10;
                }
            }

            // Drag assets
            if (_dragAssets.HasValidDrag)
            {
                result = _dragAssets.Effect;

                // Process items
                for (int i = 0; i < _dragAssets.Objects.Count; i++)
                {
                    var item = _dragAssets.Objects[i];

                    switch (item.ItemDomain)
                    {
                    case ContentDomain.Material:
                    {
                        if (hit is ModelActorNode.EntryNode meshNode)
                        {
                            var material = FlaxEngine.Content.LoadAsync <MaterialBase>(item.ID);
                            using (new UndoBlock(Undo, meshNode.ModelActor, "Change material"))
                                meshNode.Entry.Material = material;
                        }
                        else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode)
                        {
                            var material = FlaxEngine.Content.LoadAsync <MaterialBase>(item.ID);
                            using (new UndoBlock(Undo, brushSurfaceNode.Brush, "Change material"))
                                brushSurfaceNode.Surface.Material = material;
                        }

                        break;
                    }

                    case ContentDomain.Model:
                    {
                        // Create actor
                        var model = FlaxEngine.Content.LoadAsync <Model>(item.ID);
                        var actor = ModelActor.New();
                        actor.Name  = item.ShortName;
                        actor.Model = model;

                        // Place it
                        var box = actor.Box;
                        actor.Position = hitLocation - (box.Size.Length * 0.5f) * ViewDirection;

                        // Spawn
                        Editor.Instance.SceneEditing.Spawn(actor);

                        break;
                    }

                    case ContentDomain.Audio:
                    {
                        var clip  = FlaxEngine.Content.LoadAsync <AudioClip>(item.ID);
                        var actor = AudioSource.New();
                        actor.Name     = item.ShortName;
                        actor.Clip     = clip;
                        actor.Position = hitLocation;
                        Editor.Instance.SceneEditing.Spawn(actor);

                        break;
                    }

                    case ContentDomain.Prefab:
                    {
                        throw new NotImplementedException("Spawning prefabs");
                    }

                    case ContentDomain.Scene:
                    {
                        Editor.Instance.Scene.OpenScene(item.ID, true);
                        break;
                    }

                    default: throw new ArgumentOutOfRangeException();
                    }
                }
            }
            // Drag actor type
            else if (_dragActorType.HasValidDrag)
            {
                result = _dragActorType.Effect;

                // Process items
                for (int i = 0; i < _dragActorType.Objects.Count; i++)
                {
                    var item = _dragActorType.Objects[i];

                    // Create actor
                    var actor = FlaxEngine.Object.New(item) as Actor;
                    if (actor == null)
                    {
                        Editor.LogWarning("Failed to spawn actor of type " + item.FullName);
                        continue;
                    }
                    actor.Name = item.Name;

                    // Place it
                    var box = actor.Box;
                    actor.Position = hitLocation - (box.Size.Length * 0.5f) * ViewDirection;

                    // Spawn
                    Editor.Instance.SceneEditing.Spawn(actor);
                }
            }

            return(result);
        }
Beispiel #14
0
        /// <inheritdoc />
        protected override DragDropEffect OnDragDropHeader(DragData data)
        {
            var result = DragDropEffect.None;

            Actor myActor = Actor;
            Actor newParent;
            int   newOrder = -1;

            // Check if has no actor (only for Root Actor)
            if (myActor == null)
            {
                // Append to the last scene
                var scenes = SceneManager.Scenes;
                if (scenes == null || scenes.Length == 0)
                {
                    throw new InvalidOperationException("No scene loaded.");
                }
                newParent = scenes[scenes.Length - 1];
            }
            else
            {
                newParent = myActor;

                // Use drag positioning to change target parent and index
                if (_dragOverMode == DragItemPositioning.Above)
                {
                    if (myActor.HasParent)
                    {
                        newParent = myActor.Parent;
                        newOrder  = myActor.OrderInParent;
                    }
                }
                else if (_dragOverMode == DragItemPositioning.Below)
                {
                    if (myActor.HasParent)
                    {
                        newParent = myActor.Parent;
                        newOrder  = myActor.OrderInParent + 1;
                    }
                }
            }
            if (newParent == null)
            {
                throw new InvalidOperationException("Missing parent actor.");
            }

            // Drag actors
            if (_dragActors != null && _dragActors.HasValidDrag)
            {
                bool worldPositionLock = ParentWindow.GetKey(Keys.Control) == false;
                var  singleObject      = _dragActors.Objects.Count == 1;
                if (singleObject)
                {
                    var targetActor = _dragActors.Objects[0].Actor;
                    using (new UndoBlock(Editor.Instance.Undo, targetActor, "Change actor parent"))
                    {
                        targetActor.SetParent(newParent, worldPositionLock);
                        targetActor.OrderInParent = newOrder;
                    }
                }
                else
                {
                    var targetActors = _dragActors.Objects.ConvertAll(x => x.Actor);
                    using (new UndoMultiBlock(Editor.Instance.Undo, targetActors, "Change actors parent"))
                    {
                        for (int i = 0; i < targetActors.Count; i++)
                        {
                            var targetActor = targetActors[i];
                            targetActor.SetParent(newParent, worldPositionLock);
                            targetActor.OrderInParent = newOrder;
                        }
                    }
                }

                result = DragDropEffect.Move;
            }
            // Drag assets
            else if (_dragAssets != null && _dragAssets.HasValidDrag)
            {
                for (int i = 0; i < _dragAssets.Objects.Count; i++)
                {
                    var item = _dragAssets.Objects[i];

                    switch (item.ItemDomain)
                    {
                    case ContentDomain.Model:
                    {
                        // Create actor
                        var model = FlaxEngine.Content.LoadAsync <Model>(item.ID);
                        var actor = ModelActor.New();
                        actor.StaticFlags = Actor.StaticFlags;
                        actor.Name        = item.ShortName;
                        actor.Model       = model;
                        actor.Transform   = Actor.Transform;

                        // Spawn
                        Editor.Instance.SceneEditing.Spawn(actor, Actor);

                        break;
                    }

                    case ContentDomain.Other:
                    {
                        if (item.TypeName == typeof(CollisionData).FullName)
                        {
                            // Create actor
                            var actor = MeshCollider.New();
                            actor.StaticFlags   = Actor.StaticFlags;
                            actor.Name          = item.ShortName;
                            actor.CollisionData = FlaxEngine.Content.LoadAsync <CollisionData>(item.ID);
                            actor.Transform     = Actor.Transform;

                            // Spawn
                            Editor.Instance.SceneEditing.Spawn(actor, Actor);
                        }

                        break;
                    }

                    case ContentDomain.Audio:
                    {
                        var actor = AudioSource.New();
                        actor.StaticFlags = Actor.StaticFlags;
                        actor.Name        = item.ShortName;
                        actor.Clip        = FlaxEngine.Content.LoadAsync <AudioClip>(item.ID);
                        actor.Transform   = Actor.Transform;
                        Editor.Instance.SceneEditing.Spawn(actor, Actor);

                        break;
                    }

                    case ContentDomain.Prefab:
                    {
                        throw new NotImplementedException("Spawning prefabs");
                    }
                    }
                }

                result = DragDropEffect.Move;
            }
            // Drag actor type
            else if (_dragActorType != null && _dragActorType.HasValidDrag)
            {
                for (int i = 0; i < _dragActorType.Objects.Count; i++)
                {
                    var item = _dragActorType.Objects[i];

                    // Create actor
                    var actor = FlaxEngine.Object.New(item) as Actor;
                    if (actor == null)
                    {
                        Editor.LogWarning("Failed to spawn actor of type " + item.FullName);
                        continue;
                    }
                    actor.StaticFlags = Actor.StaticFlags;
                    actor.Name        = item.Name;
                    actor.Transform   = Actor.Transform;

                    // Spawn
                    Editor.Instance.SceneEditing.Spawn(actor, Actor);
                }

                result = DragDropEffect.Move;
            }

            // Clear cache
            _dragActors?.OnDragDrop();
            _dragAssets?.OnDragDrop();
            _dragActorType?.OnDragDrop();

            // Check if scene has been modified
            if (result != DragDropEffect.None)
            {
                var node = SceneGraphFactory.FindNode(newParent.ID) as ActorNode;
                node?.TreeNode.Expand();
            }

            return(result);
        }