private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { List<Item> objs = Clipboard.GetData("SADXLVLObjectList") as List<Item>; if (objs == null) { MessageBox.Show("Paste operation failed - this is a known issue and is being worked on."); return; // todo: finish implementing proper copy/paste } Vector3 center = new Vector3(); foreach (Item item in objs) center.Add(item.Position.ToVector3()); center = new Vector3(center.X / objs.Count, center.Y / objs.Count, center.Z / objs.Count); foreach (Item item in objs) { item.Position = new Vertex(item.Position.X - center.X + cam.Position.X, item.Position.Y - center.Y + cam.Position.Y, item.Position.Z - center.Z + cam.Position.Z); item.Paste(); } selectedItems.Add(new List<Item>(objs)); DrawLevel(); }
/// <summary> /// Changes the relative velocity between the character and its support. /// </summary> /// <param name="supportData">Support data to use to jump.</param> /// <param name="velocityChange">Change to apply to the character and support relative velocity.</param> /// <param name="relativeVelocity">Relative velocity to update.</param> void ApplyJumpVelocity(ref SupportData supportData, Vector3 velocityChange, ref Vector3 relativeVelocity) { Vector3 tmp; Body.LinearVelocity.Add( ref velocityChange, out tmp ); Body.LinearVelocity = tmp; var entityCollidable = supportData.SupportObject as EntityCollidable; if (entityCollidable != null) { if (entityCollidable.Entity.IsDynamic) { Vector3 change; velocityChange.Mult( jumpForceFactor, out change ); //Multiple characters cannot attempt to modify another entity's velocity at the same time. entityCollidable.Entity.Locker.Enter(); try { change.Mult( -Body.Mass, out tmp ); entityCollidable.Entity.LinearMomentum.Add( ref tmp, out tmp ); entityCollidable.Entity.LinearMomentum = tmp; } finally { entityCollidable.Entity.Locker.Exit(); } velocityChange.Add( ref change, out velocityChange ); } } //Update the relative velocity as well. It's a ref parameter, so this update will be reflected in the calling scope. Vector3.Add(ref relativeVelocity, ref velocityChange, out relativeVelocity); }
protected void CreateVertices(object sender, EventArgs e) { VertexBuffer buffer = (VertexBuffer)sender; VERTEX_FORMAT[] vertices = (VERTEX_FORMAT[])buffer.Lock(0,0); float val = 0.0f; float minZ = m_globalClipping.ZMin; float maxZ = m_globalClipping.ZMax; float a = MAXHUEVALUE / (maxZ - minZ); float b = -minZ * a; int i=0; ILColorProvider colHelp = new ILColorProvider(0.0f,0.5f,1.0f); for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++) { val = m_sourceArray.GetValue(c,r); vertices[i].X = c; vertices[i].Y = r; vertices[i].Z = val; vertices[i++].Color = colHelp.H2RGB(MAXHUEVALUE - val * a - b); } } #region create normals // Vector3 normal; i = 0; for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++,i++) { normal = new Vector3(); if (c > 0 && c < m_cols) normal.Add(vertices[i-1].Position); if (c < m_cols-1) normal.Add(vertices[i+1].Position); if (r > 0 && r < m_rows) normal.Add(vertices[i-m_cols].Position); if (r < m_rows - 1) normal.Add(vertices[i+m_cols].Position); normal.Normalize(); vertices[i].Normal = normal; } } #endregion buffer.Unlock(); m_vertexReady = true; }
public void drawContactPoint( Display render, ref Vector3 PointOnB, ref Vector3 normalOnB, double distance, int lifeTime, ref Vector3 color ) { Vector3 tmpD; PointOnB.Add( ref normalOnB, out tmpD ); drawLine( render, ref PointOnB, ref tmpD, ref color, ref color ); }
public void add() { var a = new Vector3(1, 3, 5); var b = new Vector3(5, 7, 9); Assert.Equal(new Vector3(6, 10, 14), a.Add(b)); }