//Save changes to model private void button4_Click(object sender, EventArgs e) { int index = Program.CurrentModelID; GameModel changes = Collection.GetGameModelByID(index); if (changes == null) { Console.WriteLine("null model -- not saving"); return; } //Info changes.name = textBox1.Text; changes.resourcePath = comboBox2.SelectedItem.ToString(); //Game info changes.Scale = Convert.ToSingle(textBoxDrawScale.Text); PSphere currentSphere = changes.GetSphere(Program.CurrentSphereID); if (currentSphere != null) { currentSphere.Sphere.Radius = Convert.ToSingle(textRadius.Text); currentSphere.AnchorPoint.X = Convert.ToSingle(textCenterX.Text); currentSphere.AnchorPoint.Y = Convert.ToSingle(textCenterY.Text); currentSphere.AnchorPoint.Z = Convert.ToSingle(textCenterZ.Text); currentSphere.Part = (PType)comboParts.SelectedItem; } Collection.WriteFile(); }
//Changing associated part for selected sphere private void comboParts_SelectedIndexChanged(object sender, EventArgs e) { if (comboParts.SelectedText != "") { PSphere currentSphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); currentSphere.Part = (PType)Enum.Parse(typeof(PType), comboParts.SelectedText); } }
private void comboBoxSphereBone_SelectedIndexChanged(object sender, EventArgs e) { PSphere sphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); if (sphere == null) { return; } sphere.BoneName = comboBoxSphereBone.Text; }
private void comboSpheres_SelectedIndexChanged(object sender, EventArgs e) { Program.CurrentSphereID = (int)comboSpheres.SelectedItem; PSphere currentSphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); textRadius.Text = currentSphere.Sphere.Radius.ToString(); textCenterX.Text = currentSphere.AnchorPoint.X.ToString(); textCenterY.Text = currentSphere.AnchorPoint.Y.ToString(); textCenterZ.Text = currentSphere.AnchorPoint.Z.ToString(); comboBoxSphereBone.SelectedItem = currentSphere.BoneName; comboParts.SelectedItem = currentSphere.Part; }
//Adds a sphere private void buttonAddSphere_Click(object sender, EventArgs e) { GameModel model = Collection.GetGameModelByID(Program.CurrentModelID); PSphere newSphere = model.AddSphere(); comboSpheres.Items.Add(newSphere.ID); Program.CurrentSphereID = newSphere.ID; textCenterX.Text = "0"; textCenterY.Text = "0"; textCenterZ.Text = "0"; textRadius.Text = "0"; Collection.WriteFile(); }
public void UpdateModel() { int ModelID = Program.CurrentModelID; PType Type = Program.CurrentPType; int SphereID = Program.CurrentSphereID; GameModel model = Collection.GetGameModelByID(Program.CurrentModelID); if (model == null) { return; } PSphere sphere = model.GetSphere(SphereID); if (sphere == null) { return; } textRadius.Text = sphere.Sphere.Radius.ToString(); textCenterX.Text = sphere.AnchorPoint.X.ToString(); textCenterY.Text = sphere.AnchorPoint.Y.ToString(); textCenterZ.Text = sphere.AnchorPoint.Z.ToString(); }
public static void Update() { OldState = NewState; NewState = Mouse.GetState(); OldMousePosition = NewMousePosition; NewMousePosition = mouseCoordsTo3D(NewState); //Adjusting values or placing an anchor if (NewState.LeftButton == ButtonState.Pressed && OldState.LeftButton == ButtonState.Pressed) { int Width = Program.mainGame.GraphicsDevice.PresentationParameters.BackBufferWidth / 2; if (Fields.Fields.AdjustingModel) { GameModel model = Collection.GetGameModelByID(Program.CurrentModelID); switch (Fields.Fields.Models) { case ModelMode.Moving: model.Position = mouseCoordsTo3D(NewState); // - model.Position; return; case ModelMode.X: if (NewState.X < Width) { model.RotationX -= 0.01f; } else { model.RotationX += 0.01f; } return; case ModelMode.Y: if (NewState.X < Width) { model.RotationY -= 0.01f; } else { model.RotationY += 0.01f; } return; case ModelMode.Z: if (NewState.X < Width) { model.RotationZ -= 0.01f; } else { model.RotationZ += 0.01f; } return; } } if (Fields.Fields.AdjustingSphere) { PSphere sphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); switch (Fields.Fields.Spheres) { case SphereMode.Anchor: switch (Fields.Fields.AxisMode) { case AxisLock.X: if (NewState.X < Width) { sphere.AnchorPoint.X -= 0.01f; } else { sphere.AnchorPoint.X += 0.01f; } return; case AxisLock.Y: if (NewState.X < Width) { sphere.AnchorPoint.Y -= 0.01f; } else { sphere.AnchorPoint.Y += 0.01f; } return; case AxisLock.Z: if (NewState.X < Width) { sphere.AnchorPoint.Z -= 0.01f; } else { sphere.AnchorPoint.Z += 0.01f; } return; } //Todo return; case SphereMode.Radius: // sphere.Sphere.Radius = Math.Abs(NewMousePosition.Length() - sphere.AnchorPoint.Length()); return; } } //Placing an anchor for a sphere if (Program.IsPlacingAnchor) { //Set the anchor point if (Program.CurrentSphereID != 999) { Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID).SetAnchorPoint(NewMousePosition.X, 0, NewMousePosition.Z); } } } //Stop adjusting mode if (NewState.RightButton == ButtonState.Pressed && OldState.RightButton == ButtonState.Pressed) { // AdjustingCamera = false; // AdjustingPhysics = false; //AdjustingModel = false; Fields.Fields.SetAllToFalse(); Program.IsPlacingAnchor = false; } }
public void InputUpdate(GameTime gameTime) { scrollTime -= gameTime.ElapsedGameTime; previous = current; current = Keyboard.GetState(); foreach (Keys k in current.GetPressedKeys()) { if (k == Keys.OemMinus) { Fields.Fields.Increasing = false; if (Fields.Fields.AdjustingSphere) { switch (Fields.Fields.Spheres) { case SphereMode.Anchor: return; case SphereMode.Radius: PSphere sphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); sphere.Radius -= 0.1f; return; } } } if (k == Keys.OemPlus) { Fields.Fields.Increasing = true; if (Fields.Fields.AdjustingSphere) { switch (Fields.Fields.Spheres) { case SphereMode.Anchor: return; case SphereMode.Radius: PSphere sphere = Collection.GetGameModelByID(Program.CurrentModelID).GetSphere(Program.CurrentSphereID); sphere.Radius += 0.1f; return; } } } if (ShiftDown()) { switch (k) { case Keys.X: Fields.Fields.AxisMode = AxisLock.X; return; case Keys.Y: Fields.Fields.AxisMode = AxisLock.Y; return; case Keys.Z: Fields.Fields.AxisMode = AxisLock.Z; return; } } if (isHeld(Keys.RightAlt) || isHeld(Keys.LeftAlt)) { switch (k) { case Keys.R: Fields.Fields.AdjustingSphere = true; Fields.Fields.Spheres = SphereMode.Radius; return; case Keys.S: Fields.Fields.AnimationRunning = !Fields.Fields.AnimationRunning; return; case Keys.N: Program.mainDialog.GoToNextAnimation(); return; case Keys.I: Fields.Fields.AnimationStep++; return; case Keys.M: Fields.Fields.AdjustingSphere = true; Fields.Fields.Spheres = SphereMode.Anchor; return; } } if (isHeld(Keys.RightControl) || isHeld(Keys.LeftControl)) { switch (k) { case Keys.Q: Camera.SetCameraOverhead(); Collection.GetGameModelByID(Program.CurrentModelID).ResetRotations(); return; case Keys.W: Camera.SetCameraFrontal(); Collection.GetGameModelByID(Program.CurrentModelID).ResetRotations(); return; case Keys.E: Camera.SetCameraSide(); Collection.GetGameModelByID(Program.CurrentModelID).ResetRotations(); return; case Keys.A: //Add model Collection.GetGameModelByID(Program.CurrentModelID).AddSphere(); return; case Keys.D: //Remove current model Collection.GetGameModelByID(Program.CurrentModelID).RemoveSphere(Program.CurrentSphereID); return; case Keys.M: Fields.Fields.AdjustingModel = true; Fields.Fields.Models = ModelMode.Moving; return; case Keys.X: Fields.Fields.AdjustingModel = true; Fields.Fields.Models = ModelMode.X; return; case Keys.Y: Fields.Fields.AdjustingModel = true; Fields.Fields.Models = ModelMode.Y; return; case Keys.Z: Fields.Fields.AdjustingModel = true; Fields.Fields.Models = ModelMode.Z; return; case Keys.I: Camera.ZoomControl(true); return; case Keys.O: Camera.ZoomControl(false); return; case Keys.R: Camera.DefaultZoom(); return; } } } }