Example #1
0
        private void moveObj_MouseMove(object sender, MouseEventArgs e)
        {
            if (moveObj_mouseDown)
            {
                if (Globals.item_selected > -1 && Globals.list_selected > -1)
                {
                    Object3D obj = getSelectedObject();
                    if (obj == null)
                    {
                        return;
                    }
                    if (obj.IsReadOnly)
                    {
                        return;
                    }
                    short speedMult = 30;

                    int mx = e.X - moveObj_lastMouseX;
                    int my = -(e.Y - moveObj_lastMouseY);

                    float CX   = (float)Math.Sin(camera.Yaw);
                    float CZ   = (float)-Math.Cos(camera.Yaw);
                    float CX_2 = (float)Math.Sin(camera.Yaw + (Math.PI / 2));
                    float CZ_2 = (float)-Math.Cos(camera.Yaw + (Math.PI / 2));

                    if (obj.isPropertyShown(Object3D.FLAGS.POSITION_X))
                    {
                        obj.xPos = (short)(moveObj_savedX - (short)(CX * my * speedMult * Globals.objSpeedMultiplier) - (short)(CX_2 * mx * speedMult * Globals.objSpeedMultiplier));
                    }
                    if (obj.isPropertyShown(Object3D.FLAGS.POSITION_Z))
                    {
                        obj.zPos = (short)(moveObj_savedZ - (short)(CZ * my * speedMult * Globals.objSpeedMultiplier) - (short)(CZ_2 * mx * speedMult * Globals.objSpeedMultiplier));
                    }
                    if (keepOnGround.Checked)
                    {
                        dropObjectToGround();
                    }
                    if (camera.isOrbitCamera())
                    {
                        camera.updateOrbitCamera(ref camMtx);
                    }
                    glControl1.Invalidate();
                    propertyGrid1.Refresh();
                    glControl1.Update(); // Needed after calling propertyGrid1.Refresh();
                }
            }
        }
Example #2
0
 public void updateOrbitCamera(ref Matrix4 cameraMatrix)
 {
     if (camMode == CameraMode.ORBIT)
     {
         Object3D obj = getSelectedObject();
         if (obj == null)
             return;
         pos.X = obj.xPos + (float)(Math.Cos(orbitPhi) * -Math.Sin(orbitTheta) * orbitDistance);
         pos.Y = obj.yPos + (float)(-Math.Sin(orbitPhi) * orbitDistance);
         pos.Z = obj.zPos + (float)(Math.Cos(orbitPhi) * Math.Cos(orbitTheta) * orbitDistance);
         lookat.X = obj.xPos;
         lookat.Y = obj.yPos;
         lookat.Z = obj.zPos;
         cameraMatrix = Matrix4.LookAt(pos.X, pos.Y, pos.Z, lookat.X, lookat.Y, lookat.Z, 0, 1, 0);
         setRotationFromLookAt();
     }
 }
Example #3
0
        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            string label = e.ChangedItem.Label;

            if (Globals.list_selected > -1 && Globals.list_selected < 3)
            {
                Object3D obj = getSelectedObject();
                if (obj == null)
                {
                    return;
                }
                if (label.Equals("All Acts"))
                {
                    obj.ShowHideActs((bool)e.ChangedItem.Value);
                    propertyGrid1.Refresh();
                }
                else if (label.Equals("Behavior") || label.Equals("Model ID"))
                {
                    if (Globals.item_selected > -1)
                    {
                        treeView1.Nodes[Globals.list_selected].Nodes[Globals.item_selected].Text
                            = obj.getObjectComboName();
                    }
                }
                obj.updateROMData();
                if (camera.isOrbitCamera())
                {
                    camera.updateOrbitCamera(ref camMtx);
                }
                glControl1.Invalidate();
            }
            else if (Globals.list_selected == 3)
            {
                object warp         = getSelectedWarp();
                string warpTypeName = warp.GetType().Name;
                if (warpTypeName.Equals("Warp"))
                {
                    ((Warp)warp).updateROMData();
                }
                else if (warpTypeName.Equals("WarpInstant"))
                {
                    ((WarpInstant)warp).updateROMData();
                }
            }
        }
Example #4
0
        private void rotObj_MouseMove(object sender, MouseEventArgs e)
        {
            if (rotObj_mouseDown)
            {
                if (Globals.item_selected > -1 && Globals.list_selected > -1)
                {
                    Object3D obj = getSelectedObject();
                    if (obj == null)
                    {
                        return;
                    }
                    if (obj.IsReadOnly)
                    {
                        return;
                    }
                    float speedMult = 0.5f;

                    int mx = e.X - rotObj_lastMouseX;
                    int my = -(e.Y - rotObj_lastMouseY);

                    float CZ   = (float)Math.Sin(camera.Yaw);
                    float CX   = (float)-Math.Cos(camera.Yaw);
                    float CZ_2 = (float)Math.Sin(camera.Yaw + (Math.PI / 2));
                    float CX_2 = (float)-Math.Cos(camera.Yaw + (Math.PI / 2));
                    if (obj.isPropertyShown(Object3D.FLAGS.ROTATION_X))
                    {
                        obj.xRot = (short)(rotObj_savedX - (short)(CX * my * speedMult * Globals.objSpeedMultiplier) - (short)(CX_2 * mx * speedMult * Globals.objSpeedMultiplier));
                        obj.xRot = keepDegreesWithin360(obj.xRot);
                    }
                    if (obj.isPropertyShown(Object3D.FLAGS.ROTATION_Z))
                    {
                        obj.zRot = (short)(rotObj_savedZ - (short)(CZ * my * speedMult * Globals.objSpeedMultiplier) - (short)(CZ_2 * mx * speedMult * Globals.objSpeedMultiplier));
                        obj.zRot = keepDegreesWithin360(obj.zRot);
                    }

                    if (camera.isOrbitCamera())
                    {
                        camera.updateOrbitCamera(ref camMtx);
                    }
                    glControl1.Invalidate();
                    propertyGrid1.Refresh();
                    glControl1.Update(); // Needed after calling propertyGrid1.Refresh();
                }
            }
        }
Example #5
0
 private void dropObjectToGround()
 {
     if (Globals.item_selected > -1 && Globals.list_selected > -1)
     {
         Object3D obj = getSelectedObject();
         if (obj == null)
         {
             return;
         }
         obj.yPos = level.getCurrentArea().collision.dropToGround(new Vector3(obj.xPos, obj.yPos, obj.zPos));
         if (camera.isOrbitCamera())
         {
             camera.updateOrbitCamera(ref camMtx);
         }
         glControl1.Invalidate();
         propertyGrid1.Refresh();
         glControl1.Update(); // Needed after calling propertyGrid1.Refresh();
     }
 }
Example #6
0
 private void moveObj_MouseDown(object sender, MouseEventArgs e)
 {
     if (Globals.item_selected > -1 && Globals.list_selected > -1)
     {
         Object3D obj = getSelectedObject();
         if (obj == null)
         {
             return;
         }
         if (obj.IsReadOnly)
         {
             return;
         }
         moveObj_mouseDown  = true;
         moveObj_lastMouseX = e.X;
         moveObj_lastMouseY = e.Y;
         moveObj_savedX     = obj.xPos;
         moveObj_savedY     = obj.yPos;
         moveObj_savedZ     = obj.zPos;
     }
 }
Example #7
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = e.Node;

            //Console.WriteLine("Selected: " + node.Text);
            if (node.Parent == null)
            {
                propertyGrid1.SelectedObject = null;
                Globals.list_selected        = -1;
                Globals.item_selected        = -1;
                objectComboPresetToolStripMenuItem.Enabled = false;
            }
            else
            {
                objectComboPresetToolStripMenuItem.Enabled = true;
                if (node.Parent.Text.Equals("3D Objects"))
                {
                    Globals.list_selected        = 0;
                    Globals.item_selected        = node.Index;
                    propertyGrid1.SelectedObject = level.getCurrentArea().Objects[node.Index];
                    if (camera.isOrbitCamera())
                    {
                        camera.updateOrbitCamera(ref camMtx);
                        glControl1.Invalidate();
                    }
                    //int addr = level.getCurrentArea().Objects[node.Index].getROMAddress();
                    //ROM.Instance.printROMSection(addr, addr + 0x18);
                }
                else if (node.Parent.Text.Equals("Macro 3D Objects"))
                {
                    Globals.list_selected        = 1;
                    Globals.item_selected        = node.Index;
                    propertyGrid1.SelectedObject = level.getCurrentArea().MacroObjects[node.Index];
                    if (camera.isOrbitCamera())
                    {
                        camera.updateOrbitCamera(ref camMtx);
                        glControl1.Invalidate();
                    }
                    //int addr = level.getCurrentArea().MacroObjects[node.Index].getROMAddress();
                    //ROM.Instance.printROMSection(addr, addr + 10);
                }
                else if (node.Parent.Text.Equals("Special 3D Objects"))
                {
                    Globals.list_selected        = 2;
                    Globals.item_selected        = node.Index;
                    propertyGrid1.SelectedObject = level.getCurrentArea().SpecialObjects[node.Index];
                    if (camera.isOrbitCamera())
                    {
                        camera.updateOrbitCamera(ref camMtx);
                        glControl1.Invalidate();
                    }
                    //int addr = level.getCurrentArea().SpecialObjects[node.Index].getROMAddress();
                    //ROM.Instance.printROMSection(addr, addr + 12);
                }
                else if (node.Parent.Text.Equals("Warps"))
                {
                    Globals.list_selected = 3;
                    Globals.item_selected = node.Index;
                    Area area = level.getCurrentArea();
                    if (node.Index < area.Warps.Count)
                    {
                        propertyGrid1.SelectedObject = area.Warps[node.Index];
                    }
                    else if (node.Index < area.Warps.Count + area.PaintingWarps.Count)
                    {
                        propertyGrid1.SelectedObject = area.PaintingWarps[node.Index - area.Warps.Count];
                    }
                    else
                    {
                        propertyGrid1.SelectedObject = area.InstantWarps[node.Index - area.Warps.Count - area.PaintingWarps.Count];
                    }
                }
            }

            Object3D obj = getSelectedObject();

            if (obj != null)
            {
                if (obj.IsReadOnly)
                {
                    objectComboPresetToolStripMenuItem.Enabled = false;
                }
                obj.UpdateProperties();
                propertyGrid1.Refresh();
            }

            glControl1.Invalidate();
            glControl1.Update();
        }
Example #8
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.P:
                if (Globals.list_selected != -1 && Globals.item_selected != -1)
                {
                    int      listSel = Globals.list_selected;
                    int      objSel  = Globals.item_selected;
                    Object3D obj     = getSelectedObject();
                    if (obj == null)
                    {
                        return;
                    }
                    string newName = Prompts.ShowInputDialog("Type the new combo name", "New combo name");
                    if (newName.Length > 0)
                    {
                        obj.Title = newName;
                        uint segmentAddress = 0;
                        if (level.ModelIDs.ContainsKey(obj.ModelID))
                        {
                            segmentAddress = level.ModelIDs[obj.ModelID].GeoDataSegAddress;
                        }
                        ObjectComboEntry oce = new ObjectComboEntry(newName, obj.ModelID,
                                                                    segmentAddress, obj.getBehaviorAddress());
                        Globals.insertNewEntry(oce);
                        refreshObjectsInList();
                        treeView1.SelectedNode = treeView1.Nodes[listSel].Nodes[objSel];
                        Globals.list_selected  = listSel;
                        Globals.item_selected  = objSel;
                        propertyGrid1.Refresh();
                    }
                    ModelComboFile.writeObjectCombosFile(Globals.getDefaultObjectComboPath());
                    Console.WriteLine("Saved Object Combos!");
                }
                break;

            case Keys.D1:
                trySwitchArea(1);
                break;

            case Keys.D2:
                trySwitchArea(2);
                break;

            case Keys.D3:
                trySwitchArea(3);
                break;

            case Keys.D4:
                trySwitchArea(4);
                break;

            case Keys.D5:
                trySwitchArea(5);
                break;

            case Keys.D6:
                trySwitchArea(6);
                break;

            case Keys.D7:
                trySwitchArea(7);
                break;

            case Keys.D0:
                trySwitchArea(0);
                break;
            }
        }
Example #9
0
        private void objectComboPresetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectComboPreset comboWindow;

            switch (Globals.list_selected)
            {
            case 0:
                comboWindow =
                    new SelectComboPreset(level, 0, "Select Object Combos", Color.DarkRed);
                comboWindow.ShowDialog();
                if (comboWindow.ClickedSelect)
                {
                    Area area = level.getCurrentArea();
                    area.Objects[Globals.item_selected].ModelID = comboWindow.ReturnObjectCombo.ModelID;
                    area.Objects[Globals.item_selected].setBehaviorFromAddress(comboWindow.ReturnObjectCombo.Behavior);
                    treeView1.Nodes[0].Nodes[Globals.item_selected].Text
                        = area.Objects[Globals.item_selected].getObjectComboName();
                    area.Objects[Globals.item_selected].SetBehaviorParametersToZero();
                    area.Objects[Globals.item_selected].UpdateProperties();
                }
                break;

            case 1:
                comboWindow =
                    new SelectComboPreset(level, 1, "Select Macro Preset", Color.DarkBlue);
                comboWindow.ShowDialog();
                if (comboWindow.ClickedSelect)
                {
                    Console.WriteLine(comboWindow.ReturnPresetMacro.PresetID);
                    Area area = level.getCurrentArea();
                    area.MacroObjects[Globals.item_selected].ModelID = comboWindow.ReturnPresetMacro.ModelID;
                    area.MacroObjects[Globals.item_selected].setPresetID(comboWindow.ReturnPresetMacro.PresetID);
                    area.MacroObjects[Globals.item_selected].setBehaviorFromAddress(comboWindow.ReturnPresetMacro.Behavior);
                    //area.MacroObjects[Globals.item_selected].SetBehaviorParametersToZero();
                    area.MacroObjects[Globals.item_selected].BehaviorParameter1
                        = comboWindow.ReturnPresetMacro.BehaviorParameter1;
                    area.MacroObjects[Globals.item_selected].BehaviorParameter2
                        = comboWindow.ReturnPresetMacro.BehaviorParameter2;
                    treeView1.Nodes[1].Nodes[Globals.item_selected].Text
                        = area.MacroObjects[Globals.item_selected].getObjectComboName();
                    area.MacroObjects[Globals.item_selected].UpdateProperties();
                }
                break;

            case 2:
            {
                Object3D obj             = getSelectedObject();
                int      specialListType = 2;
                if (obj.isPropertyShown(Object3D.FLAGS.BPARAM_1))
                {
                    specialListType = 4;
                }
                else if (obj.isPropertyShown(Object3D.FLAGS.ROTATION_Y))
                {
                    specialListType = 3;
                }
                comboWindow =
                    new SelectComboPreset(level, specialListType, "Select Special Preset", Color.DarkGreen);
                comboWindow.ShowDialog();
                if (comboWindow.ClickedSelect)
                {
                    Console.WriteLine(comboWindow.ReturnPresetMacro.PresetID);
                    Area area = level.getCurrentArea();
                    area.SpecialObjects[Globals.item_selected].ModelID = comboWindow.ReturnPresetMacro.ModelID;
                    area.SpecialObjects[Globals.item_selected].setPresetID(comboWindow.ReturnPresetMacro.PresetID);
                    area.SpecialObjects[Globals.item_selected].setBehaviorFromAddress(comboWindow.ReturnPresetMacro.Behavior);
                    //area.SpecialObjects[Globals.item_selected].SetBehaviorParametersToZero();
                    area.SpecialObjects[Globals.item_selected].BehaviorParameter1
                        = comboWindow.ReturnPresetMacro.BehaviorParameter1;
                    area.SpecialObjects[Globals.item_selected].BehaviorParameter2
                        = comboWindow.ReturnPresetMacro.BehaviorParameter2;
                    treeView1.Nodes[2].Nodes[Globals.item_selected].Text
                        = area.SpecialObjects[Globals.item_selected].getObjectComboName();
                    area.SpecialObjects[Globals.item_selected].UpdateProperties();
                }
                break;
            }
            }
            glControl1.Invalidate();
            propertyGrid1.Refresh();
            glControl1.Update(); // Needed after calling propertyGrid1.Refresh();
        }