Example #1
0
        private HeaderCommands.IPickableObject TryPickObject(int x, int y, bool moveable)
        {
            if (currentScene == null) return null;

            HeaderCommands.IPickableObject picked = null;
            List<HeaderCommands.IPickableObject> pickobjs = new List<HeaderCommands.IPickableObject>();

            /* Room model triangle vertices */
            if (!Configuration.RenderCollision && currentRoomTriangle != null)
                pickobjs.AddRange(currentRoomTriangle.Vertices);

            /* Room model triangles */
            if (currentRoom != null && currentRoom.ActiveMeshHeader != null && !Configuration.RenderCollision &&
                currentRoom.ActiveMeshHeader.DLs.Count > 0 && currentRoom.ActiveMeshHeader.DLs[0].Triangles.Count > 0)
            {
                if (currentRoom.ActiveMeshHeader.DLs[0].Triangles[0].IsMoveable == moveable)
                {
                    foreach (DisplayListEx dlex in currentRoom.ActiveMeshHeader.DLs)
                        pickobjs.AddRange(dlex.Triangles);
                }
            }

            /* Rooms */
            if (allMeshHeaders != null && currentRoom == null && !Configuration.RenderCollision && allMeshHeaders.Count > 0 && allMeshHeaders[0].IsMoveable == moveable)
                pickobjs.AddRange(allMeshHeaders);

            /* Room actors */
            if (currentRoom != null && currentRoom.ActiveRoomActorData != null && Configuration.RenderRoomActors && currentRoom.ActiveRoomActorData.ActorList.Count > 0 &&
                currentRoom.ActiveRoomActorData.ActorList[0].IsMoveable == moveable)
                pickobjs.AddRange(currentRoom.ActiveRoomActorData.ActorList);

            /* Spawn points */
            if (currentScene.GetActiveSpawnPointData() != null && Configuration.RenderSpawnPoints && currentScene.GetActiveSpawnPointData().ActorList.Count > 0 &&
                currentScene.GetActiveSpawnPointData().ActorList[0].IsMoveable == moveable)
                pickobjs.AddRange(currentScene.GetActiveSpawnPointData().ActorList);

            /* Transition actors */
            if (currentScene.GetActiveTransitionData() != null && Configuration.RenderTransitions && currentScene.GetActiveTransitionData().ActorList.Count > 0 &&
                currentScene.GetActiveTransitionData().ActorList[0].IsMoveable == moveable)
                pickobjs.AddRange(currentScene.GetActiveTransitionData().ActorList);

            /* Waypoints */
            if (activePathHeader != null && activePathHeader.Points != null && Configuration.RenderPathWaypoints && activePathHeader.Points.Count > 0 &&
                activePathHeader.Points[0].IsMoveable == moveable)
                pickobjs.AddRange(activePathHeader.Points);

            /* Waterboxes */
            if (currentScene.GetActiveCollision() != null && Configuration.RenderWaterboxes && currentScene.GetActiveCollision().Waterboxes.Count > 0 &&
                currentScene.GetActiveCollision().Waterboxes[0].IsMoveable == moveable)
                pickobjs.AddRange(currentScene.GetActiveCollision().Waterboxes);

            /* Collision polygons */
            if (currentScene.GetActiveCollision() != null && Configuration.RenderCollision && currentScene.GetActiveCollision().Polygons.Count > 0 &&
                currentScene.GetActiveCollision().Polygons[0].IsMoveable == moveable)
                pickobjs.AddRange(currentScene.GetActiveCollision().Polygons);

            if ((picked = DoPicking(x, y, pickobjs)) != null)
            {
                /* Wrong mode? */
                if (picked.IsMoveable != moveable) return null;

                /* What's been picked...? */
                if (picked is HeaderCommands.Waypoints.Waypoint)
                {
                    dgvPathWaypoints.ClearSelection();
                    DataGridViewRow row = dgvPathWaypoints.Rows.OfType<DataGridViewRow>().FirstOrDefault(xx => xx.DataBoundItem == picked as HeaderCommands.Waypoints.Waypoint);
                    if (row == null) return null;
                    row.Cells["X"].Selected = true;
                    tabControl1.SelectTab(tpWaypoints);
                }
                else if (picked is HeaderCommands.Actors.Entry)
                {
                    HeaderCommands.Actors.Entry actor = (picked as HeaderCommands.Actors.Entry);

                    if (actor.IsSpawnPoint)
                    {
                        cbSpawnPoints.SelectedItem = actor;
                        tabControl1.SelectTab(tpSpawnPoints);
                    }
                    else if (actor.IsTransitionActor)
                    {
                        cbTransitions.SelectedItem = actor;
                        tabControl1.SelectTab(tpTransitions);
                    }
                    else
                    {
                        cbActors.SelectedItem = actor;
                        tabControl1.SelectTab(tpRoomActors);
                    }
                }
                else if (picked is HeaderCommands.Collision.Polygon)
                {
                    currentCollisionPolygon = (picked as HeaderCommands.Collision.Polygon);

                    cbCollisionPolys.SelectedItem = currentCollisionPolygon;
                    tabControl1.SelectTab(tpCollision);
                }
                else if (picked is HeaderCommands.Collision.Waterbox)
                {
                    currentWaterbox = (picked as HeaderCommands.Collision.Waterbox);

                    cbWaterboxes.SelectedItem = currentWaterbox;
                    tabControl1.SelectTab(tpWaterboxes);
                }
                else if (picked is HeaderCommands.MeshHeader)
                {
                    tvScenes.SelectedNode = tvScenes.FlattenTree().FirstOrDefault(xx =>
                        xx.Tag == ((picked as HeaderCommands.MeshHeader).Parent as HeaderCommands.Rooms.RoomInfoClass) &&
                        (xx.Parent.Tag as HeaderLoader.HeaderPair).SceneHeader.Number == currentScene.GetCurrentSceneHeader().Number);
                }
                else if (picked is OpenGLHelpers.DisplayListEx.Triangle)
                {
                    if (currentRoomTriangle != picked)
                    {
                        if (currentRoomTriangle != null) currentRoomTriangle.SelectedVertex = null;

                        currentRoomTriangle = (picked as OpenGLHelpers.DisplayListEx.Triangle);
                        currentRoomVertex = null;
                    }
                }
                else if (picked is SimpleF3DEX2.Vertex)
                {
                    currentRoomTriangle.SelectedVertex = currentRoomVertex = (picked as SimpleF3DEX2.Vertex);
                }
            }

            return picked;
        }
Example #2
0
        private void cbCollisionPolys_SelectedIndexChanged(object sender, EventArgs e)
        {
            currentCollisionPolygon = (((ComboBox)sender).SelectedItem as HeaderCommands.Collision.Polygon);
            if (currentCollisionPolygon == null) return;

            pickedObject = (currentCollisionPolygon as HeaderCommands.IPickableObject);
            collisionDirty = true;

            lblColPolyType.Visible = nudColPolyType.Visible = btnJumpToPolyType.Visible = !currentCollisionPolygon.IsDummy;
            if (!currentCollisionPolygon.IsDummy)
            {
                nudColPolyType.Value = currentCollisionPolygon.PolygonType;
                //TODO more here
            }
        }