Ejemplo n.º 1
0
        private void MotionStances_OnClick(object sender, MouseButtonEventArgs e)
        {
            if (MotionTable == null)
            {
                return;
            }

            var selected = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem;

            if (selected == null)
            {
                return;
            }

            var motionStance = (MotionStance)selected.Content;

            MainWindow.Status.WriteLine($"Playing motion {motionStance}.Ready");

            var motionCmds = MotionTable.GetMotionCommands(motionStance);

            SetCommands(motionCmds);
            SetDefaultMotion(motionStance);

            ModelViewer.DoStance(motionStance);
        }
Ejemplo n.º 2
0
        private static void ProcessArgs(string [] args, ModelViewer modelViewer)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                switch (args[i])
                {
                case "--mesh_file":
                    modelViewer.InitialModel = args[++i];
                    break;

                case "--repository_path":
                    modelViewer.RepositoryDirectoryList.Add(args[++i]);
                    break;

                case "--advanced":
                    modelViewer.AdvancedOptions = true;
                    break;

                default:
                    if (modelViewer.InitialModel == null)
                    {
                        modelViewer.InitialModel = args[i];
                    }
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 private void Start()
 {
     if (_instance != null)
     {
         throw new Exception("Second singleton");
     }
     _instance = this;
 }
Ejemplo n.º 4
0
    ////////////////////////////////////////////
    //
    // Function
    //
    ////////////////////////////////////////////

    protected override void Awake()
    {
        base.Awake();
        m_ModelViewer    = ModelViewer.instance;
        m_VoxelViewer    = VoxelViewer.instance;
        m_SimulateViewer = GameObject.Find("SimulateViewer").GetComponent <SimulateViewer>();
        m_ModelMgr       = GameObject.Find("ModelMgr").GetComponent <ModelMgr>();
    }
Ejemplo n.º 5
0
        public ItemViewer()
        {
            try
            {
                Classifications           = new EditorClassifications();
                Classifications.Filenames = new string[] { "obj.dat" };
                FileExtensions            = "";
                StaticFileExtensions      = "";
                ConfigureForm             = new Configure();

                Window window = new Window();
                this.Controls = new Control[window.Controls.Count];
                for (int i = 0; i < window.Controls.Count; i++)
                {
                    this.Controls[i] = window.Controls[i];
                }
                name_label     = (Label)window.Controls.Find("lblName", true)[0];
                pic_item_small = (PictureBox)window.Controls.Find("pItemSmall", true)[0];
                pic_item_large = (PictureBox)window.Controls.Find("pItemLarge", true)[0];
                properties     = (PropertyGrid)window.Controls.Find("prop_item", true)[0];
                model_viewer   = (ModelViewer)window.Controls.Find("modelViewer", true)[0];
                model_viewer.Controls[1].MouseUp      += model_viewer_MouseUp;
                model_viewer.software_control.MouseUp += model_viewer_MouseUp;
                properties.PropertyValueChanged       += properties_PropertyValueChanged;

                name_label.Text = "Select an item";

                ItemToolbox toolbox = new ItemToolbox();
                ToolControls = new Control[toolbox.Controls.Count];
                for (int i = 0; i < ToolControls.Length; i++)
                {
                    ToolControls[i] = toolbox.Controls[i];
                }
                NumericUpDown n_item   = (NumericUpDown)toolbox.Controls.Find("nItem", true)[0];
                NumericUpDown n_amount = (NumericUpDown)toolbox.Controls.Find("nAmount", true)[0];
                lock_sprite = (CheckBox)toolbox.Controls.Find("chkModelSprite", true)[0];

                n_item.ValueChanged   += delegate(object sender, EventArgs e) { SelectItem((int)n_item.Value, (int)n_amount.Value, true); };
                n_amount.ValueChanged += delegate(object sender, EventArgs e) { SelectItem((int)n_item.Value, (int)n_amount.Value); };

                checkerboard = new Bitmap(32, 32);
                Graphics g = Graphics.FromImage(checkerboard);
                g.Clear(Color.White);
                g.FillRectangle(Brushes.LightGray, 0, 0, 16, 16);
                g.FillRectangle(Brushes.LightGray, 16, 16, 16, 16);

                pic_item_small.BackgroundImage = checkerboard;
                pic_item_large.BackgroundImage = checkerboard;
                last_item   = 0;
                last_amount = 1;

                initialized = false;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
            }
        }
Ejemplo n.º 6
0
 public void Init(int w, int h, ModelViewer viewer, Browser browser, EditorCommandManager commandManager, GUISkin skin)
 {
     //width = w;
     //height = h;
     this.viewer         = viewer;
     this.browser        = browser;
     this.commandManager = commandManager;
     this.skin           = skin;
     initBlockType();
 }
Ejemplo n.º 7
0
        public MainForm()
        {
            InitializeComponent();

            ShowDirectory(AppDomain.CurrentDomain.BaseDirectory);

            ModelViewer      = new ModelViewer();
            ModelViewer.Dock = DockStyle.Fill;
            viewerBox.Controls.Add(ModelViewer);
        }
Ejemplo n.º 8
0
 public SkinsVM(Screen screen)
 {
     if (screen.Type != Screen.ScreenType.Skins)
     {
         throw new ArgumentException();
     }
     _firstOn        = true;
     Screen          = screen;
     _mv             = ModelViewer.GetInstance();
     Screen.TurnedOn = TurnOnHandler;
     Screen.Rect.transform.Find("Back").GetComponent <Button>().onClick.AddListener(HandleBackButton);
 }
Ejemplo n.º 9
0
        public ObjectViewer()
        {
            Classifications           = new EditorClassifications();
            Classifications.Filenames = new string[] { "loc.dat" };
            FileExtensions            = "";
            StaticFileExtensions      = "";
            ConfigureForm             = new Configure();

            Window window = new Window();

            this.Controls = new Control[window.Controls.Count];
            for (int i = 0; i < window.Controls.Count; i++)
            {
                this.Controls[i] = window.Controls[i];
            }
            name_label   = (Label)window.Controls.Find("lblName", true)[0];
            properties   = (PropertyGrid)window.Controls.Find("prop_item", true)[0];
            model_viewer = (ModelViewer)window.Controls.Find("modelViewer", true)[0];
            properties.PropertyValueChanged += properties_PropertyValueChanged;

            name_label.Text = "Select an object";

            ItemToolbox toolbox = new ItemToolbox();

            ToolControls = new Control[toolbox.Controls.Count];
            for (int i = 0; i < ToolControls.Length; i++)
            {
                ToolControls[i] = toolbox.Controls[i];
            }
            NumericUpDown n_item = (NumericUpDown)toolbox.Controls.Find("nItem", true)[0];

            n_type = (NumericUpDown)toolbox.Controls.Find("nType", true)[0];

            n_item.ValueChanged += delegate(object sender, EventArgs e) { SelectObject((int)n_item.Value, true); };
            n_type.ValueChanged += delegate(object sender, EventArgs e)
            {
                if (last_type != (int)n_type.Value)
                {
                    last_type = (int)n_type.Value;
                    SelectObject((int)n_item.Value, true);
                }
            };

            checkerboard = new Bitmap(32, 32);
            Graphics g = Graphics.FromImage(checkerboard);

            g.Clear(Color.White);
            g.FillRectangle(Brushes.LightGray, 0, 0, 16, 16);
            g.FillRectangle(Brushes.LightGray, 16, 16, 16, 16);

            last_object = 0;
            initialized = false;
        }
Ejemplo n.º 10
0
    ////////////////////////////////////////////
    //
    // Function
    //
    ////////////////////////////////////////////

    private void Awake()
    {
        m_VoxelViewer = VoxelViewer.instance;
        m_ModelViewer = ModelViewer.instance;
        var informationMgr = InformationMgr.instance;
        var models         = GetComponentsInChildren <MeshFilter>(true);

        m_Pages = new Page[models.Length];
        for (int i = 0; i < m_Pages.Length; ++i)
        {
            var model     = models[i].gameObject;
            var voxelData = VoxelizeUtility.instance.ToVoxelData(informationMgr, model);
            m_Pages[i] = new Page(model, voxelData);
            model.SetActive(false);
        }
        m_ModelViewer.Show(m_Pages[m_PageIndex].model);
    }
Ejemplo n.º 11
0
    public ShowroomVM(Screen screen)
    {
        if (screen.Type != Screen.ScreenType.Showroom)
        {
            throw new ArgumentException();
        }
        Screen = screen;
        screen.Rect.transform.Find("Back").GetComponent <Button>().onClick.AddListener(HandleBackButton);
        screen.Rect.transform.Find("Left").GetComponent <ClickHandler>().Clicked  = () => Next(true);
        screen.Rect.transform.Find("Right").GetComponent <ClickHandler>().Clicked = () => Next(false);
        _use = screen.Rect.transform.Find("Use").GetComponent <Button>();
        _use.onClick.AddListener(Use);
        _useText = screen.Rect.transform.Find("Use").GetComponentInChildren <Text>();

        screen.TurnedOn = TurnOnHandler;
        _skins          = SkinsContainer.GetInstance().Skins;
        _mv             = ModelViewer.GetInstance();
        _progress       = ProgressData.GetInstance();
    }
Ejemplo n.º 12
0
        private void MotionCommands_OnClick(object sender, MouseButtonEventArgs e)
        {
            if (MotionTable == null)
            {
                return;
            }

            var selected = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem;

            if (selected == null)
            {
                return;
            }

            var motionCommand = (MotionCommand)selected.Content;

            MainWindow.Status.WriteLine($"Playing motion {(MotionStance)ModelViewer.ViewObject.PhysicsObj.MovementManager.MotionInterpreter.InterpretedState.CurrentStyle}.{motionCommand}");

            ModelViewer.DoMotion(motionCommand);
        }
Ejemplo n.º 13
0
        public void LoadModelWithClothingBase()
        {
            if (CurrentClothingItem == null)
            {
                return;
            }

            if (SetupIds.SelectedIndex == -1)
            {
                return;
            }

            if (PaletteTemplates.SelectedIndex == -1)
            {
                return;
            }

            float shade = 0;

            if (Shades.Visibility == Visibility.Visible)
            {
                shade = (float)(Shades.Value / Shades.Maximum);
                if (float.IsNaN(shade))
                {
                    shade = 0;
                }
            }

            var selectedSetup = SetupIds.SelectedItem as ListBoxItem;
            var setupId       = (uint)selectedSetup.DataContext;

            var selectedPalette = PaletteTemplates.SelectedItem as ListBoxItem;
            var paletteTemplate = (PaletteTemplate)(uint)selectedPalette.DataContext;

            ModelViewer.LoadModel(setupId, CurrentClothingItem, paletteTemplate, shade);
        }
 public SetAssetRepositoryDialog(ModelViewer app)
 {
     this.app = app;
     InitializeComponent();
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            string initialModel = null;

            if (args.Length > 0)
            {
                initialModel = args[0];
            }
            try
            {
                // Set the current directory to the the directory of the excutable
                String execDir = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
                Directory.SetCurrentDirectory(execDir);
                // Changes the CurrentCulture of the current thread to the invariant culture.
                Thread.CurrentThread.CurrentCulture = new CultureInfo("", false);

                // Initialize logging
                if (!Directory.Exists(ConfigFolder))
                {
                    Directory.CreateDirectory(ConfigFolder);
                }
                if (!Directory.Exists(LogFolder))
                {
                    Directory.CreateDirectory(LogFolder);
                }
                LogUtil.InitializeLogging(Path.Combine(ConfigFolder, "LogConfig.xml"), "DefaultLogConfig.xml", FallbackLogfile);

                int processor = 1;
                foreach (ProcessThread thread in Process.GetCurrentProcess().Threads)
                {
                    thread.ProcessorAffinity = (IntPtr)processor;
                }

                ModelViewer modelViewer = new ModelViewer();

                string argsString = "";
                foreach (string arg in args)
                {
                    if (argsString.Length == 0)
                    {
                        argsString = arg;
                    }
                    else
                    {
                        argsString = argsString + " " + arg;
                    }
                }
                args = ParseArgumentString(argsString);
                ProcessArgs(args, modelViewer);

                modelViewer.Show();
                modelViewer.Start();
            }
            catch (FileNotFoundException ex)
            {
                // try logging the error here first, before Root is disposed of
                LogUtil.ExceptionLog.ErrorFormat("Caught file not found exception for {0}: {1}", ex.FileName, ex);
                throw;
            }
            catch (Exception ex)
            {
                // try logging the error here first, before Root is disposed of
                LogUtil.ExceptionLog.ErrorFormat("Caught exception: {0}", ex);
                throw;
            }
        }
Ejemplo n.º 16
0
        public ModelViewModel(ViewModelXY xy, ViewModelXY xz, ViewModelXY yz, int sizeX = 0, int sizeY = 0)
        {
            if (sizeX != 0 && sizeY != 0)
            {
                isMapElement = true;
                mapSizeX     = sizeX;
                mapSizeY     = sizeY;
            }

            Elements.Get = new List <Element>();

            exporter = new WavefrontExporter(Elements.Get);

            this.xy = xy;
            this.xz = xz;
            this.yz = yz;

            InsertCommand.ExecuteFunc       = x => insert();
            SelectCommand.ExecuteFunc       = x => select();
            SelectSingleCommand.ExecuteFunc = x => selectSingle();
            CopyCommand.ExecuteFunc         = x => copy();
            CubeCommand.ExecuteFunc         = x => cube();
            NewModelCommand.ExecuteFunc     = x => newModel();
            ListCommand.ExecuteFunc         = x => list();
            CloseCommand.ExecuteFunc        = x => close();
            SaveCommand.ExecuteFunc         = x => save();
            LoadCommand.ExecuteFunc         = x => load();
            ExportCommand.ExecuteFunc       = x => export();
            MoveCommand.ExecuteFunc         = x => move();
            ResizeCommand.ExecuteFunc       = x => resize();
            BoneCommand.ExecuteFunc         = x => bone();
            TextureCommand.ExecuteFunc      = x => texture();

            Image0.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.einfügen);
            Image1.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.auswahl2);
            Image2.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.auswahl4);
            Image3.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.kopie);
            Image4.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.würfel2);
            Image5.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.würfelplus);
            Image6.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.liste2);
            Image7.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.diskette);
            Image8.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.close);
            Image9.Get  = ImageHelper.ConvertImageToWpfImage(Resources.Resource.export);
            Image10.Get = ImageHelper.ConvertImageToWpfImage(Resources.Resource.schieben);
            Image11.Get = ImageHelper.ConvertImageToWpfImage(Resources.Resource.größe_ändern);
            Image12.Get = ImageHelper.ConvertImageToWpfImage(Resources.Resource.load);
            Image13.Get = ImageHelper.ConvertImageToWpfImage(Resources.Resource.texture);
            Image14.Get = ImageHelper.ConvertImageToWpfImage(Resources.Resource.bone);

            this.xy.DrawCubeAction = drawCube;
            this.xz.DrawCubeAction = drawCube;
            this.yz.DrawCubeAction = drawCube;

            this.xy.NewCubeAction = newCube;
            this.xz.NewCubeAction = newCube;
            this.yz.NewCubeAction = newCube;

            this.xy.MoveAction = move;
            this.xz.MoveAction = move;
            this.yz.MoveAction = move;

            this.xy.ResizeAction = resize;
            this.xz.ResizeAction = resize;
            this.yz.ResizeAction = resize;

            this.xy.AddAction = add;
            this.xz.AddAction = add;
            this.yz.AddAction = add;

            this.xy.SelectAction = select;
            this.xz.SelectAction = select;
            this.yz.SelectAction = select;

            this.xy.LoadedAction = loaded;
            this.xz.LoadedAction = loaded;
            this.yz.LoadedAction = loaded;

            this.xy.BoneAction = bone;
            this.xz.BoneAction = bone;
            this.yz.BoneAction = bone;

            var modelWindowViewModel = new ModelViewWindowViewModel();
            var window = ViewManager.ShowView(typeof(ModelViewWindow), modelWindowViewModel);

            engine = new ModelViewer(ViewManager.GetWindowHandle(window));
            modelWindowViewModel.Engine = engine;

            SetPropertyChangeForAll();
        }
Ejemplo n.º 17
0
        public void UpdateFields()
        {
            boneNameLabel.Text = selectedBone;
            if (skeleton.ContainsBone(boneNameLabel.Text))
            {
                Bone       bone = skeleton.GetBone(boneNameLabel.Text);
                Quaternion q    = ModelViewer.GetRotation(bone.FullTransform);
                boneNameLabel.Text = bone.Name;
                bonePosition.Text  = bone.FullTransform.Translation.ToString();
                boneRotation.Text  = q.ToString();
                boneRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
                q = bone.Orientation;
                relPosition.Text  = bone.Position.ToString();
                relRotation.Text  = q.ToString();
                relRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
                Bone    bindBone = skeleton.GetBone(boneNameLabel.Text);
                Matrix4 bindBoneFullTransform = bindBone.BindDerivedInverseTransform.Inverse();
                q = ModelViewer.GetRotation(bindBoneFullTransform);
                bindPosition.Text  = bindBoneFullTransform.Translation.ToString();
                bindRotation.Text  = q.ToString();
                bindRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
                AnimationState currentAnimation = modelViewer.CurrentAnimation;
                if (currentAnimation != null)
                {
                    animationName.Text = "Animation: " + currentAnimation.Name;
                    float currentTime = currentAnimation.Time;
                    animationTime.Text = "Time: " + currentTime.ToString();
                    Animation          anim = skeleton.GetAnimation(currentAnimation.Name);
                    NodeAnimationTrack animTrack = anim.NodeTracks[bone.Handle];
                    KeyFrame           keyFrame1, keyFrame2;
                    ushort             dummy;
                    animTrack.GetKeyFramesAtTime(currentTime, out keyFrame1, out keyFrame2, out dummy);
                    AnimationStateSet helperAnimSet = new AnimationStateSet();
                    helperSkeleton.InitAnimationState(helperAnimSet);
                    AnimationState helperAnimation = helperAnimSet.GetAnimationState(currentAnimation.Name);
                    helperAnimation.IsEnabled = true;
                    helperAnimation.Time      = keyFrame1.Time;
                    helperSkeleton.SetAnimationState(helperAnimSet);
                    Bone helperBone = helperSkeleton.GetBone(bone.Handle);
                    // currentAnimation.Time;
                    keyFrame1Time.Text = helperAnimation.Time.ToString();
                    q = ModelViewer.GetRotation(helperBone.FullTransform);
                    keyFrame1Position.Text  = helperBone.FullTransform.Translation.ToString();
                    keyFrame1Rotation.Text  = q.ToString();
                    keyFrame1Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
                    helperAnimation.Time    = keyFrame2.Time;
                    helperSkeleton.SetAnimationState(helperAnimSet);
                    keyFrame2Time.Text = helperAnimation.Time.ToString();
                    q = ModelViewer.GetRotation(helperBone.FullTransform);
                    keyFrame2Position.Text  = helperBone.FullTransform.Translation.ToString();
                    keyFrame2Rotation.Text  = q.ToString();
                    keyFrame2Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
#if NOT
                    keyFrame1Time.Text = keyFrame1.Time.ToString();
                    q = keyFrame1.Rotation;
                    keyFrame1Position.Text  = helperBone.Translate.ToString();
                    keyFrame1Rotation.Text  = q.ToString();
                    keyFrame1Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
                    keyFrame2Time.Text      = keyFrame2.Time.ToString();
                    q = keyFrame2.Rotation;
                    keyFrame2Position.Text  = keyFrame2.Translate.ToString();
                    keyFrame2Rotation.Text  = q.ToString();
                    keyFrame2Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
#endif
                }
                else
                {
                    animationName.Text = "No animation selected";
                }
                bonePosition.Show();
                boneRotation.Show();
                boneRotation2.Show();
                relPosition.Show();
                relRotation.Show();
                relRotation2.Show();
                bindPosition.Show();
                bindRotation.Show();
                bindRotation2.Show();
                if (currentAnimation != null)
                {
                    prevKeyframeLabel.Show();
                    keyFrame1TimeLabel.Show();
                    keyFrame1PositionLabel.Show();
                    keyFrame1RotationLabel.Show();
                    keyFrame1Time.Show();
                    keyFrame1Position.Show();
                    keyFrame1Rotation.Show();
                    keyFrame1Rotation2.Show();
                    nextKeyframeLabel.Show();
                    keyFrame2TimeLabel.Show();
                    keyFrame2PositionLabel.Show();
                    keyFrame2RotationLabel.Show();
                    keyFrame2Time.Show();
                    keyFrame2Position.Show();
                    keyFrame2Rotation.Show();
                    keyFrame2Rotation2.Show();
                }
                else
                {
                    prevKeyframeLabel.Hide();
                    keyFrame1TimeLabel.Hide();
                    keyFrame1PositionLabel.Hide();
                    keyFrame1RotationLabel.Hide();
                    keyFrame1Time.Hide();
                    keyFrame1Position.Hide();
                    keyFrame1Rotation.Hide();
                    keyFrame1Rotation2.Hide();
                    nextKeyframeLabel.Hide();
                    keyFrame2TimeLabel.Hide();
                    keyFrame2PositionLabel.Hide();
                    keyFrame2RotationLabel.Hide();
                    keyFrame2Time.Hide();
                    keyFrame2Position.Hide();
                    keyFrame2Rotation.Hide();
                    keyFrame2Rotation2.Hide();
                }
            }
            else
            {
                boneNameLabel.Text = "Invalid Bone Selected";
                bonePosition.Hide();
                boneRotation.Hide();
                boneRotation2.Hide();
                relPosition.Hide();
                relRotation.Hide();
                relRotation2.Hide();
                bindPosition.Hide();
                bindRotation.Hide();
                bindRotation2.Hide();
                prevKeyframeLabel.Hide();
                keyFrame1TimeLabel.Hide();
                keyFrame1PositionLabel.Hide();
                keyFrame1RotationLabel.Hide();
                keyFrame1Time.Hide();
                keyFrame1Position.Hide();
                keyFrame1Rotation.Hide();
                keyFrame1Rotation2.Hide();
                nextKeyframeLabel.Hide();
                keyFrame2TimeLabel.Hide();
                keyFrame2PositionLabel.Hide();
                keyFrame2RotationLabel.Hide();
                keyFrame2Time.Hide();
                keyFrame2Position.Hide();
                keyFrame2Rotation.Hide();
                keyFrame2Rotation2.Hide();
            }
        }
Ejemplo n.º 18
0
 public BoneDisplay(ModelViewer parent) : this()
 {
     modelViewer = parent;
 }
Ejemplo n.º 19
0
        public void LoadTag(PakFile Pak, PakFile.PakTag Tag)
        {
            tabMeta.Controls.Clear();
            tabMeta.Controls.Add(vS3D);
            vS3D.Dock = DockStyle.Fill;

            if (vMode == null)
            {
                vMode = new ModelViewer();      //this cant go in the constructor because the
                //tabModel.Controls.Clear();    //ElementHost in the ModelViewer requires an
                tabModel.Controls.Add(vMode);   //STA thread, whereas the map open thread
                vMode.Dock = DockStyle.Fill;    //is MTA because it's done via ThreadPool
                vMode.DefaultModeFormat = settings.ModeFormat;

                vMode.TagExtracted    += new TagExtractedEventHandler(extractor_TagExtracted);
                vMode.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting);
            }
            else
            {
                vMode.Clear();
            }

            if (vSbsp == null)
            {
                vSbsp = new BSPViewer();
                //tabModel.Controls.Clear();
                tabModel.Controls.Add(vSbsp);
                vSbsp.Dock = DockStyle.Fill;
                vSbsp.DefaultModeFormat = settings.ModeFormat;

                vSbsp.TagExtracted    += new TagExtractedEventHandler(extractor_TagExtracted);
                vSbsp.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting);
            }
            else
            {
                vSbsp.Clear();
            }

            pak        = Pak;
            item       = Tag;
            metaLoaded = rawLoaded = modelLoaded = false;

            vMode.RenderBackColor = settings.ViewerColour;
            vSbsp.RenderBackColor = settings.ViewerColour;
            vSbsp.TextureScale    = settings.pakScale / 100f;

            switch (item.Class)
            {
                #region bitmaps
            case TagType.Textures:
            case TagType.TexturesMips64:
                tabControl1.TabPages.Remove(tabModel);

                tabRaw.Controls.Clear();

                if (!tabControl1.TabPages.Contains(tabRaw))
                {
                    tabControl1.TabPages.Add(tabRaw);
                }

                tabRaw.Controls.Add(eBitm);
                eBitm.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabRaw)
                {
                    eBitm.LoadBitmapTag(pak, item);
                    rawLoaded = true;
                }
                break;
                #endregion

                #region models
            case TagType.Templates:
                tabControl1.TabPages.Remove(tabRaw);
                vMode.Visible = true;
                vSbsp.Visible = false;

                //if (!tabControl1.TabPages.Contains(tabRaw))
                //    tabControl1.TabPages.Add(tabRaw);

                if (!tabControl1.TabPages.Contains(tabModel))
                {
                    tabControl1.TabPages.Add(tabModel);
                }

                //tabRaw.Controls.Add(eMode);
                //eMode.Dock = DockStyle.Fill;

                //tabModel.Controls.Clear();
                //tabModel.Controls.Add(vMode);
                //vMode.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabMeta)
                {
                    //vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    vS3D.LoadModelHierarchy(pak, item);
                    metaLoaded = true;
                }
                //else if (tabControl1.SelectedTab == tabRaw)
                //{
                //    eMode.DataFolder = settings.dataFolder;
                //    eMode.PermFilter = settings.permFilter;
                //    eMode.LoadModelTag(cache, tag);
                //    rawLoaded = true;
                //}
                else if (tabControl1.SelectedTab == tabModel)
                {
                    //vMode.RenderBackColor = settings.ViewerColour;
                    vMode.PermutationFilter = new List <string>(settings.permFilter.Split(' '));
                    vMode.LoadModelTag(pak, item,
                                       settings.Flags.HasFlag(SettingsFlags.LoadSpecular),
                                       settings.Flags.HasFlag(SettingsFlags.ForceLoadModels));
                    modelLoaded = true;
                }
                break;
                #endregion

                #region bsps
            case TagType.Scene:
                tabControl1.TabPages.Remove(tabRaw);
                vMode.Visible = false;
                vSbsp.Visible = true;

                if (!tabControl1.TabPages.Contains(tabModel))
                {
                    tabControl1.TabPages.Add(tabModel);
                }

                //tabRaw.Controls.Add(eSbsp);
                //eMode.Dock = DockStyle.Fill;

                //tabModel.Controls.Clear();
                //tabModel.Controls.Add(vSbsp);
                //vSbsp.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabMeta)
                {
                    //vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    vS3D.LoadModelHierarchy(pak, item);
                    metaLoaded = true;
                }
                //else if (tabControl1.SelectedTab == tabRaw)
                //{
                //    eMode.DataFolder = settings.dataFolder;
                //    eMode.PermFilter = settings.permFilter;
                //    eMode.LoadModelTag(cache, tag);
                //    rawLoaded = true;
                //}
                if (tabControl1.SelectedTab == tabModel)
                {
                    vSbsp.LoadBSPTag(pak, item, settings.Flags.HasFlag(SettingsFlags.ForceLoadModels));
                    modelLoaded = true;
                }
                break;
                #endregion

                #region other
            default:
                tabControl1.TabPages.Remove(tabModel);
                tabControl1.TabPages.Remove(tabRaw);

                vS3D.DisplayTagInfo(pak, item);
                break;
                #endregion
            }
        }
Ejemplo n.º 20
0
        public void LoadTag(CacheBase Cache, CacheBase.IndexItem Tag)
        {
            if (vMode == null)
            {
                vMode = new ModelViewer();      //this cant go in the constructor because the
                //tabModel.Controls.Clear();    //ElementHost in the ModelViewer requires an
                tabModel.Controls.Add(vMode);   //STA thread, whereas the map open thread
                vMode.Dock = DockStyle.Fill;    //is MTA because it's done via ThreadPool
                vMode.DefaultModeFormat = settings.ModeFormat;

                vMode.TagExtracted    += new TagExtractedEventHandler(extractor_TagExtracted);
                vMode.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting);
            }
            else
            {
                vMode.Clear();
            }

            if (vSbsp == null)
            {
                vSbsp = new BSPViewer();
                //tabModel.Controls.Clear();
                tabModel.Controls.Add(vSbsp);
                vSbsp.Dock = DockStyle.Fill;
                vSbsp.DefaultModeFormat = settings.ModeFormat;

                vSbsp.TagExtracted    += new TagExtractedEventHandler(extractor_TagExtracted);
                vSbsp.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting);
            }
            else
            {
                vSbsp.Clear();
            }

            cache      = Cache;
            tag        = Tag;
            metaLoaded = rawLoaded = modelLoaded = false;

            vMode.RenderBackColor = settings.ViewerColour;
            vSbsp.RenderBackColor = settings.ViewerColour;
            vSbsp.TextureScale    = settings.mapScale / 100f;

            switch (Tag.ClassCode)
            {
                #region bitm
            case "bitm":
                tabControl1.TabPages.Remove(tabModel);

                tabRaw.Controls.Clear();

                if (!tabControl1.TabPages.Contains(tabRaw))
                {
                    tabControl1.TabPages.Add(tabRaw);
                }

                tabRaw.Controls.Add(eBitm);
                eBitm.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabMeta)
                {
                    vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    metaLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabRaw)
                {
                    eBitm.LoadBitmapTag(cache, tag);
                    rawLoaded = true;
                }
                break;
                #endregion

                #region mode
            case "mode":
            case "mod2":
                tabRaw.Controls.Clear();
                vSbsp.Visible = false;
                vMode.Visible = true;

                if (!tabControl1.TabPages.Contains(tabRaw))
                {
                    tabControl1.TabPages.Add(tabRaw);
                }

                if (!tabControl1.TabPages.Contains(tabModel))
                {
                    tabControl1.TabPages.Add(tabModel);
                }

                tabRaw.Controls.Add(eMode);
                eMode.Dock = DockStyle.Fill;

                //tabModel.Controls.Clear();
                //tabModel.Controls.Add(vMode);
                //vMode.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabMeta)
                {
                    vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    metaLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabRaw)
                {
                    eMode.DataFolder = settings.dataFolder;
                    eMode.PermFilter = settings.permFilter;
                    eMode.LoadModelTag(cache, tag);
                    rawLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabModel)
                {
                    //vMode.RenderBackColor = settings.ViewerColour;
                    vMode.PermutationFilter = new List <string>(settings.permFilter.Split(' '));
                    vMode.LoadModelTag(cache, tag,
                                       settings.Flags.HasFlag(SettingsFlags.LoadSpecular),
                                       settings.Flags.HasFlag(SettingsFlags.UsePermFilter),
                                       settings.Flags.HasFlag(SettingsFlags.ForceLoadModels));
                    modelLoaded = true;
                }
                break;
                #endregion

                #region sbsp
            case "sbsp":
                tabRaw.Controls.Clear();
                vMode.Visible = false;
                vSbsp.Visible = true;

                if (!tabControl1.TabPages.Contains(tabRaw))
                {
                    tabControl1.TabPages.Add(tabRaw);
                }

                if (!tabControl1.TabPages.Contains(tabModel))
                {
                    tabControl1.TabPages.Add(tabModel);
                }

                tabRaw.Controls.Add(eSbsp);
                eSbsp.Dock = DockStyle.Fill;

                //tabModel.Controls.Clear();
                //tabModel.Controls.Add(vSbsp);
                //vSbsp.Dock = DockStyle.Fill;

                if (tabControl1.SelectedTab == tabMeta)
                {
                    vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    metaLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabRaw)
                {
                    eSbsp.DataFolder = settings.dataFolder;
                    eSbsp.LoadBSPTag(cache, tag);
                    rawLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabModel)
                {
                    vSbsp.LoadBSPTag(cache, tag, settings.Flags.HasFlag(SettingsFlags.ForceLoadModels));
                    modelLoaded = true;
                }
                break;
                #endregion

                #region snd!
            case "snd!":
                tabControl1.TabPages.Remove(tabModel);

                tabRaw.Controls.Clear();

                if (cache.Version < DefinitionSet.Halo3Retail)
                {
                    tabControl1.TabPages.Remove(tabRaw);
                }
                else
                {
                    if (!tabControl1.TabPages.Contains(tabRaw))
                    {
                        tabControl1.TabPages.Add(tabRaw);
                    }

                    if (cache.Version < DefinitionSet.Halo4Retail)
                    {
                        tabRaw.Controls.Add(eSnd_);
                        eSnd_.Dock = DockStyle.Fill;
                    }
                    else
                    {
                        tabRaw.Controls.Add(eSnd4);
                        eSnd4.Dock = DockStyle.Fill;
                    }
                }


                if (tabControl1.SelectedTab == tabMeta)
                {
                    vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    metaLoaded = true;
                }
                else if (tabControl1.SelectedTab == tabRaw)
                {
                    if (cache.Version < DefinitionSet.Halo4Retail)
                    {
                        eSnd_.LoadSoundTag(cache, tag);
                    }
                    else
                    {
                        eSnd4.LoadSoundTag(cache, tag);
                    }

                    rawLoaded = true;
                }
                break;
                #endregion

                #region unic
            case "unic":
                tabControl1.TabPages.Remove(tabModel);

                tabRaw.Controls.Clear();

                if (cache.Version < DefinitionSet.Halo3Beta)
                {
                    tabControl1.TabPages.Remove(tabRaw);
                }
                else
                {
                    if (!tabControl1.TabPages.Contains(tabRaw))
                    {
                        tabControl1.TabPages.Add(tabRaw);
                    }

                    tabRaw.Controls.Add(vUnic);
                    vUnic.Dock = DockStyle.Fill;

                    if (tabControl1.SelectedTab == tabMeta)
                    {
                        vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                        metaLoaded = true;
                    }
                    else if (tabControl1.SelectedTab == tabRaw)
                    {
                        vUnic.LoadUnicTag(cache, tag);
                        rawLoaded = true;
                    }
                }
                break;
                #endregion

                #region other
            default:
                tabControl1.TabPages.Remove(tabModel);
                tabControl1.TabPages.Remove(tabRaw);

                if (tabControl1.SelectedTab == tabMeta)
                {
                    vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder);
                    metaLoaded = true;
                }
                break;
                #endregion
            }
        }