Esempio n. 1
0
 public WDOMLayeredGroupNode(FourCC fourCC, MapLayer layer, WWorld world) : base(world)
 {
     FourCC     = fourCC;
     Layer      = layer;
     IsVisible  = true;
     IsRendered = true;
 }
Esempio n. 2
0
        public EventMode(WWorld world)
        {
            World = world;
            EventDetailsViewModel = new WDetailsViewViewModel();
            ActorDetailsViewModel = new WDetailsViewViewModel();
            m_StaffNodeViews      = new List <NetworkView>();

            TransformGizmo = new WTransformGizmo(world);

            ModeControlsDock = CreateUI();

            m_NodeWindow = new EventNodeWindow();
            m_NodeWindow.ActorPropertiesView.DataContext   = ActorDetailsViewModel;
            m_NodeWindow.ActorTabControl.SelectionChanged += OnSelectedActorChanged;
            m_NodeWindow.Closing += M_NodeWindow_Closing;
            m_NodeWindow.EditMenu.Items.Add(new MenuItem()
            {
                Header = "Add Actor", Command = AddStaffCommand
            });

            EditorSelection = new Selection <BindingVector3>(this);
            EditorSelection.OnSelectionChanged += OnSelectionChanged;

            m_SceneCameraOverride = new WCamera();
            m_SceneCameraOverride.bEnableUpdates = false;
            m_SceneCameraOverride.AspectRatio    = 1.28f;
        }
Esempio n. 3
0
 public WCollisionMesh(WWorld world) : base(world)
 {
     m_primitiveShader = new Shader("UnselectedCollision");
     m_primitiveShader.CompileSource(File.ReadAllText("resources/shaders/UnselectedCollision.vert"), ShaderType.VertexShader);
     m_primitiveShader.CompileSource(File.ReadAllText("resources/shaders/UnselectedCollision.frag"), ShaderType.FragmentShader);
     m_primitiveShader.LinkShader();
 }
Esempio n. 4
0
        public WDOMNode(WWorld world)
        {
            World      = world;
            m_Children = new ObservableCollection <WDOMNode>();

            IsVisible     = true;
            m_IsDestroyed = false;
        }
Esempio n. 5
0
 public void FilterSceneForRenderer(WSceneView view, WWorld world)
 {
     foreach (WScene scene in world.Map.SceneList)
     {
         foreach (var renderable in scene.GetChildrenOfType <IRenderable>())
         {
             renderable.AddToRenderer(view);
         }
     }
 }
Esempio n. 6
0
        public CollisionMode(WWorld world)
        {
            World = world;

            EditorSelection = new Selection <CollisionTriangle>(this);
            EditorSelection.OnSelectionChanged += OnSelectionChanged;

            DetailsViewModel = new WDetailsViewViewModel();

            ModeControlsDock = CreateUI();
        }
Esempio n. 7
0
        /// <summary>
        /// Creates an event list from the given file.
        /// </summary>
        /// <param name="world">World containing the collision mesh</param>
        /// <param name="file_name">File to load the model from</param>
        public WEventList(WWorld world, string file_name) : base(world)
        {
            Events       = new BindingList <Event>();
            m_Staffs     = new List <Staff>();
            m_Cuts       = new List <Cut>();
            m_Substances = new List <Substance>();

            using (EndianBinaryReader reader = new EndianBinaryReader(File.ReadAllBytes(file_name), Endian.Big))
            {
                LoadEventList(reader);
            }
        }
Esempio n. 8
0
        public ActorMode(WWorld world)
        {
            World          = world;
            TransformGizmo = new WTransformGizmo(world);

            EditorSelection = new Selection <WDOMNode>(this);
            EditorSelection.OnSelectionChanged += OnSelectionChanged;

            DetailsViewModel = new WDetailsViewViewModel();

            ModeControlsDock = CreateUI();
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a collision mesh from the given file, handling COLLADA DAE files only.
        /// </summary>
        /// <param name="world">World containing the collision mesh</param>
        /// <param name="file_name">File to load the model from</param>
        /// <param name="roomIndex">The room number to give to the new collision mesh</param>
        /// <param name="roomTableIndex">The room table index to give to all collision groups in the new collision mesh (hack)</param>
        public WCollisionMesh(WWorld world, string file_name, int roomIndex, int roomTableIndex) : base(world)
        {
            Init();
            FileName = Path.GetFileNameWithoutExtension(file_name);

            if (file_name.EndsWith(".dae"))
            {
                COLLADA dae = COLLADA.Load(file_name);
                LoadFromCollada(dae, roomIndex, roomTableIndex);
            }
            else
            {
                throw new Exception($"File is not a DAE: {file_name}");
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Creates a collision mesh from the given file, handling COLLADA DAE files only.
        /// </summary>
        /// <param name="world">World containing the collision mesh</param>
        /// <param name="file_name">File to load the model from</param>
        /// <param name="roomIndex">The room number to give to the new collision mesh</param>
        /// <param name="roomTableIndex">The room table index to give to all collision groups in the new collision mesh (hack)</param>
        public WCollisionMesh(WWorld world, string file_name, int roomIndex, int roomTableIndex) : base(world)
        {
            Init();
            FileName = Path.GetFileNameWithoutExtension(file_name);

            if (file_name.EndsWith(".dae"))
            {
                COLLADA dae = COLLADA.Load(file_name);
                LoadFromCollada(dae, roomIndex, roomTableIndex);
            }
            else
            {
                LoadFromObj(File.ReadAllLines(file_name), roomIndex, roomTableIndex);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a collision mesh from the given file, handling DZB files only.
        /// </summary>
        /// <param name="world">World containing the collision mesh</param>
        /// <param name="file_name">File to load the model from</param>
        public WCollisionMesh(WWorld world, string file_name) : base(world)
        {
            Init();
            FileName = Path.GetFileNameWithoutExtension(file_name);

            if (file_name.EndsWith(".dzb"))
            {
                using (EndianBinaryReader reader = new EndianBinaryReader(File.ReadAllBytes(file_name), Endian.Big))
                {
                    LoadFromDZB(reader);
                }
            }
            else
            {
                throw new Exception($"File is not a DZB: {file_name}");
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Creates a collision mesh from the given file, handling both COLLADA DAE and DZB files.
        /// </summary>
        /// <param name="world">World containing the collision mesh</param>
        /// <param name="file_name">File to load the model from</param>
        public WCollisionMesh(WWorld world, string file_name) : base(world)
        {
            Init();
            FileName = Path.GetFileNameWithoutExtension(file_name);

            if (file_name.EndsWith(".dae"))
            {
                COLLADA dae = COLLADA.Load(file_name);
                LoadFromCollada(dae);
            }
            else if (file_name.EndsWith(".dzb"))
            {
                using (EndianBinaryReader reader = new EndianBinaryReader(File.ReadAllBytes(file_name), Endian.Big))
                {
                    LoadFromDZB(reader);
                }
            }
        }
Esempio n. 13
0
 public WDOMNodeJsonConverter(WWorld world, WDOMNode parent)
 {
     m_world  = world;
     m_parent = parent;
 }
Esempio n. 14
0
        private void LoadEntities(Map newMap, EditorCore core, Dictionary <Scene, VirtualFilesystemDirectory> archiveMap, WWorld world)
        {
            MapEntityLoader entityLoader = new MapEntityLoader(core, newMap);

            // For each room/scene, find the associated dzr/dzs file and load its
            // contents into the entityLoader.
            foreach (var kvp in archiveMap)
            {
                // Check to see if this Archive has stage/room entity data.
                var roomEntData  = kvp.Value.FindByExtension(".dzr");
                var stageEntData = kvp.Value.FindByExtension(".dzs");

                VirtualFilesystemFile vfsFile = null;
                if (roomEntData.Count > 0)
                {
                    vfsFile = roomEntData[0];
                }
                else if (stageEntData.Count > 0)
                {
                    vfsFile = stageEntData[0];
                }
                else
                {
                    continue;
                }

                using (EndianBinaryReader reader = new EndianBinaryReader(new System.IO.MemoryStream(vfsFile.File.GetData()), Endian.Big))
                {
                    WLog.Info(LogCategory.EntityLoading, null, "Loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}...", vfsFile.Name, vfsFile.Extension);
                    entityLoader.LoadFromStream(kvp.Key, reader);
                    WLog.Info(LogCategory.EntityLoading, null, "Finished loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}.", vfsFile.Name, vfsFile.Extension);
                }
            }

            // Once we've loaded all of the entities from the stream, we're going to
            // post-process them to resolve object references.
            entityLoader.PostProcessEntities();

            // Finally, we can actually convert these into map objects
            foreach (var roomOrStageData in entityLoader.GetData())
            {
                Stage stage = roomOrStageData.Key as Stage;
                Room  room  = roomOrStageData.Key as Room;

                if (stage != null)
                {
                    PostProcessStage(stage, roomOrStageData.Value);
                    foreach (var entity in stage.Entities)
                    {
                        entity.World = world;
                    }
                }
                if (room != null)
                {
                    PostProcessRoom(room, roomOrStageData.Value);
                    foreach (var entity in room.Entities)
                    {
                        entity.World = world;
                    }
                }
            }
        }
Esempio n. 15
0
        public Map CreateFromDirectory(WWorld world, EditorCore editorCore, string folderPath)
        {
            if (world == null)
            {
                throw new ArgumentNullException("world", "No world to load map into specified.");
            }

            if (string.IsNullOrEmpty(folderPath))
            {
                throw new ArgumentException("folderPath is null or empty!");
            }

            if (!System.IO.Directory.Exists(folderPath))
            {
                throw new System.IO.DirectoryNotFoundException("folderPath not found, ensure the directory exists first!");
            }

            // Calculate the Map Name from the folderPath - it should be the last segment of the folder path.s
            System.IO.DirectoryInfo rootFolderInfo = new System.IO.DirectoryInfo(folderPath);
            string mapName = rootFolderInfo.Name;


            // Sort the directories in rootFolderInfo into natural order, instead of alphabetical order which solves issues
            // where room indexes were getting remapped to the wrong one.
            IEnumerable <System.IO.DirectoryInfo> subFolders = rootFolderInfo.GetDirectories().OrderByNatural(x => x.Name);
            IEnumerable <System.IO.FileInfo>      subFiles   = rootFolderInfo.GetFiles().OrderByNatural(x => x.Name);

            // Maps are stored in two distinct parts. A Stage which encompasses global data for all rooms, and then
            // one or more rooms. We're going to load both the room and stage into ZArchives and then load the data
            // stored in them into different data.
            var archiveFolderMap = new Dictionary <string, VirtualFilesystemDirectory>();

            foreach (var dirInfo in subFolders)
            {
                VirtualFilesystemDirectory archive = null;

                string folderName = dirInfo.Name;
                if (folderName.ToLower().StartsWith("stage"))
                {
                    archive = new VirtualFilesystemDirectory(folderName);

                    if (archiveFolderMap.ContainsKey("stage"))
                    {
                        WLog.Warning(LogCategory.EditorCore, null, "{0} contains more than one stage archive, ignoring second...", folderPath);
                        continue;
                    }
                }
                else if (folderName.ToLower().StartsWith("room"))
                {
                    archive = new VirtualFilesystemDirectory(folderName);
                }

                // sea has LOD folders which don't have the right sub-folder setup, boo. This skips them for now,
                // maybe later we can add an ArchiveType.LOD.
                if (archive == null)
                {
                    continue;
                }

                // Fill the archives with their contents.
                archive.ImportFromDisk(dirInfo.FullName);
                archiveFolderMap[folderName.ToLower()] = archive;
            }

            // We're also going to try and process the files inside the folder to see if they're archives.
            foreach (var fileInfo in subFiles)
            {
                VirtualFilesystemDirectory archive = WArchiveTools.ArcUtilities.LoadArchive(fileInfo.FullName);

                // File wasn't a valid RARC archive.
                if (archive == null)
                {
                    continue;
                }

                if (archive.Name.ToLower().StartsWith("stage"))
                {
                    if (archiveFolderMap.ContainsKey("stage"))
                    {
                        WLog.Warning(LogCategory.EditorCore, null, "{0} contains more than one stage archive, ignoring second...", folderPath);
                        continue;
                    }
                }

                string arcName = System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName).ToLower();
                archiveFolderMap[arcName] = archive;
            }

            Map newMap = new Map();

            newMap.Name            = mapName;
            newMap.ProjectFilePath = System.IO.Path.GetDirectoryName(folderPath);

            var sceneMap = CreateScenesFromArchives(newMap, archiveFolderMap);

            LoadEntities(newMap, editorCore, sceneMap, world);
            LoadModels(sceneMap);

            return(newMap);
        }
Esempio n. 16
0
 /// <summary>
 /// Reads actor data from the given stream and grabs actions from the given list.
 /// </summary>
 /// <param name="world">World containing the event actor</param>
 /// <param name="reader">Stream to load actor data from</param>
 /// <param name="actors">List of actions to assign to this event</param>
 public WEventActor(WWorld world, EndianBinaryReader reader /*, List<EventActor> actors*/) : base(world)
 {
     Name = new string(reader.ReadChars(32)).Trim('\0');
 }
Esempio n. 17
0
        public void FilterSceneForRenderer(WSceneView view, WWorld world)
        {
            if (m_bOverrideSceneCamera)
            {
                view.OverrideSceneCamera(m_SceneCameraOverride);
            }

            foreach (WScene scene in world.Map.SceneList)
            {
                foreach (var renderable in scene.GetChildrenOfType <IRenderable>())
                {
                    renderable.AddToRenderer(view);
                }
            }

            Staff camera = (Staff)SelectedEvent.Actors.ToList().Find(x => x.StaffType == StaffType.Camera);

            if (camera != null)
            {
                Cut c = camera.FirstCut;

                while (c != null)
                {
                    OpenTK.Vector3 eye_pos    = new OpenTK.Vector3();
                    OpenTK.Vector3 target_pos = new OpenTK.Vector3();

                    Substance eye = c.Properties.Find(x => x.Name.ToLower() == "eye");
                    if (eye != null)
                    {
                        Substance <ObservableCollection <BindingVector3> > eye_vec = eye as Substance <ObservableCollection <BindingVector3> >;
                        eye_pos = eye_vec.Data[0].BackingVector;

                        WLinearColor draw_color = WLinearColor.White;
                        if (EditorSelection.SelectedObjects.Contains(eye_vec.Data[0]))
                        {
                            draw_color = WLinearColor.FromHexString("0xFF4F00FF");
                        }

                        world.DebugDrawBillboard("eye.png", eye_pos, new OpenTK.Vector3(100, 100, 100), draw_color, 0.025f);
                    }

                    Substance target = c.Properties.Find(x => x.Name.ToLower() == "center");
                    if (target != null)
                    {
                        Substance <ObservableCollection <BindingVector3> > target_vec = target as Substance <ObservableCollection <BindingVector3> >;
                        target_pos = target_vec.Data[0].BackingVector;

                        WLinearColor draw_color = WLinearColor.White;
                        if (EditorSelection.SelectedObjects.Contains(target_vec.Data[0]))
                        {
                            draw_color = WLinearColor.FromHexString("0xFF4F00FF");
                        }

                        world.DebugDrawBillboard("target.png", target_pos, new OpenTK.Vector3(100, 100, 100), draw_color, 0.025f);
                    }

                    if (eye != null && target != null)
                    {
                        world.DebugDrawLine(eye_pos, target_pos, WLinearColor.Black, 100000.0f, 0.025f);
                    }

                    c = c.NextCut;
                }
            }
        }
Esempio n. 18
0
 public WJ3DRenderNode(WWorld world, string name) : base(world, name)
 {
 }
Esempio n. 19
0
 public WDOMRenderNode(WWorld world, string name) : base(world)
 {
     Name = name;
 }
Esempio n. 20
0
 public RenderSystem(WWorld world)
 {
     m_cameraList = new List<Camera>();
     m_world = world;
 }
Esempio n. 21
0
 public RenderSystem(WWorld world)
 {
     m_cameraList = new List <Camera>();
     m_world      = world;
 }
 public DOMOrganizerNode(WWorld world, string header) : base(world)
 {
     Name = header;
 }
Esempio n. 23
0
        public Map CreateFromDirectory(WWorld world, EditorCore editorCore, string folderPath)
        {
            if (world == null)
                throw new ArgumentNullException("world", "No world to load map into specified.");

            if (string.IsNullOrEmpty(folderPath))
                throw new ArgumentException("folderPath is null or empty!");

            if (!System.IO.Directory.Exists(folderPath))
                throw new System.IO.DirectoryNotFoundException("folderPath not found, ensure the directory exists first!");

            // Calculate the Map Name from the folderPath - it should be the last segment of the folder path.s
            System.IO.DirectoryInfo rootFolderInfo = new System.IO.DirectoryInfo(folderPath);
            string mapName = rootFolderInfo.Name;

            // Sort the directories in rootFolderInfo into natural order, instead of alphabetical order which solves issues
            // where room indexes were getting remapped to the wrong one.
            IEnumerable<System.IO.DirectoryInfo> subFolders = rootFolderInfo.GetDirectories().OrderByNatural(x => x.Name);
            IEnumerable<System.IO.FileInfo> subFiles = rootFolderInfo.GetFiles().OrderByNatural(x => x.Name);

            // Maps are stored in two distinct parts. A Stage which encompasses global data for all rooms, and then
            // one or more rooms. We're going to load both the room and stage into ZArchives and then load the data
            // stored in them into different data.
            var archiveFolderMap = new Dictionary<string, VirtualFilesystemDirectory>();
            foreach (var dirInfo in subFolders)
            {
                VirtualFilesystemDirectory archive = null;

                string folderName = dirInfo.Name;
                if (folderName.ToLower().StartsWith("stage"))
                {
                    archive = new VirtualFilesystemDirectory(folderName);

                    if (archiveFolderMap.ContainsKey("stage"))
                    {
                        WLog.Warning(LogCategory.EditorCore, null, "{0} contains more than one stage archive, ignoring second...", folderPath);
                        continue;
                    }
                }
                else if (folderName.ToLower().StartsWith("room"))
                {
                    archive = new VirtualFilesystemDirectory(folderName);
                }

                // sea has LOD folders which don't have the right sub-folder setup, boo. This skips them for now,
                // maybe later we can add an ArchiveType.LOD.
                if (archive == null)
                    continue;

                // Fill the archives with their contents.
                archive.ImportFromDisk(dirInfo.FullName);
                archiveFolderMap[folderName.ToLower()] = archive;
            }

            // We're also going to try and process the files inside the folder to see if they're archives.
            foreach (var fileInfo in subFiles)
            {
                VirtualFilesystemDirectory archive = WArchiveTools.ArcUtilities.LoadArchive(fileInfo.FullName);

                // File wasn't a valid RARC archive.
                if (archive == null)
                    continue;

                if (archive.Name.ToLower().StartsWith("stage"))
                {
                    if (archiveFolderMap.ContainsKey("stage"))
                    {
                        WLog.Warning(LogCategory.EditorCore, null, "{0} contains more than one stage archive, ignoring second...", folderPath);
                        continue;
                    }
                }

                string arcName = System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName).ToLower();
                archiveFolderMap[arcName] = archive;
            }

            Map newMap = new Map();
            newMap.Name = mapName;
            newMap.ProjectFilePath = System.IO.Path.GetDirectoryName(folderPath);

            var sceneMap = CreateScenesFromArchives(newMap, archiveFolderMap);
            LoadEntities(newMap, editorCore, sceneMap, world);
            LoadModels(sceneMap);

            return newMap;
        }
Esempio n. 24
0
        private void LoadEntities(Map newMap, EditorCore core, Dictionary<Scene, VirtualFilesystemDirectory> archiveMap, WWorld world)
        {
            MapEntityLoader entityLoader = new MapEntityLoader(core, newMap);

            // For each room/scene, find the associated dzr/dzs file and load its
            // contents into the entityLoader.
            foreach (var kvp in archiveMap)
            {
                // Check to see if this Archive has stage/room entity data.
                var roomEntData = kvp.Value.FindByExtension(".dzr");
                var stageEntData = kvp.Value.FindByExtension(".dzs");

                VirtualFilesystemFile vfsFile = null;
                if (roomEntData.Count > 0)
                    vfsFile = roomEntData[0];
                else if (stageEntData.Count > 0)
                    vfsFile = stageEntData[0];
                else
                    continue;

                using (EndianBinaryReader reader = new EndianBinaryReader(new System.IO.MemoryStream(vfsFile.File.GetData()), Endian.Big))
                {
                    WLog.Info(LogCategory.EntityLoading, null, "Loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}...", vfsFile.Name, vfsFile.Extension);
                    entityLoader.LoadFromStream(kvp.Key, reader);
                    WLog.Info(LogCategory.EntityLoading, null, "Finished loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}.", vfsFile.Name, vfsFile.Extension);
                }
            }

            // Once we've loaded all of the entities from the stream, we're going to
            // post-process them to resolve object references.
            entityLoader.PostProcessEntities();

            // Finally, we can actually convert these into map objects
            foreach (var roomOrStageData in entityLoader.GetData())
            {
                Stage stage = roomOrStageData.Key as Stage;
                Room room = roomOrStageData.Key as Room;

                if (stage != null)
                {
                    PostProcessStage(stage, roomOrStageData.Value);
                    foreach (var entity in stage.Entities)
                        entity.World = world;
                }
                if (room != null)
                {
                    PostProcessRoom(room, roomOrStageData.Value);
                    foreach (var entity in room.Entities)
                        entity.World = world;
                }
            }
        }
Esempio n. 25
0
 public WDOMGroupNode(FourCC fourCC, WWorld world) : base(world)
 {
     FourCC    = fourCC;
     IsVisible = true;
 }