public void PositionToEditorObject(VoxelEditorObject eo) { Vector3 eo3DCubeSize = new Vector3(eo.CubeSize); xAxisPos = new IndexPosition(eo.Max.X + 1, eo.Min.Y, eo.Min.Z) * eo3DCubeSize + new Vector3(-cubeSize, 0, -cubeSize * 2); yAxisPos = new IndexPosition(eo.Min.X, eo.Max.Y + 1, eo.Min.Z) * eo3DCubeSize + new Vector3(-cubeSize * 2, -cubeSize, -cubeSize * 2); zAxisPos = new IndexPosition(eo.Min.X, eo.Min.Y, eo.Max.Z + 1) * eo3DCubeSize + new Vector3(-cubeSize * 2, 0, -cubeSize); }
public VoxelGridObject(VoxelEditorObject voxObj) : base(voxObj.CubeSize) { Width = voxObj.Width; Height = voxObj.Height; Depth = voxObj.Depth; BuildMesh(); }
public bool Update(VoxelEditorObject eo, Camera camera) { if (!HasHold) { return(false); } Vector3 newPos = camera.GetMouse3DPosition(); Vector3 camDelta = camera.Position - lastCamPos; Vector3 delta = (newPos - startPos) * 8 * eo.CubeSize; delta -= camDelta; IndexPosition iDelta = new IndexPosition( (int)(delta.X / eo.CubeSize), (int)(delta.Y / eo.CubeSize), (int)(delta.Z / eo.CubeSize)); lastCamPos = camera.Position; if (iDelta != IndexPosition.Zero) { if (Holding == Axis.X) { eo.Translate(new IndexPosition(iDelta.X, 0, 0)); } if (Holding == Axis.Y) { eo.Translate(new IndexPosition(0, iDelta.Y, 0)); } if (Holding == Axis.Z) { eo.Translate(new IndexPosition(0, 0, iDelta.Z)); } startPos = newPos; return(true); } return(false); }