public void StopTransform() { if (_mode == TransformationMode.None) { return; } _mode = TransformationMode.None; if (_selection.SelectedGameObject && _selection.SelectedGameObject.GetComponent <Rigidbody>()) { var rb = _selection.SelectedGameObject.GetComponent <Rigidbody>(); rb.isKinematic = _initalSelectedIsKinematic; if (!_initalSelectedIsKinematic && _averageVelocity.Count > 2) { var avg = Vector3.zero; var count = _averageVelocity.Count; while (_averageVelocity.Count > 0) { avg += _averageVelocity.Dequeue(); } var velocity = Vector3.Scale(InertiaScale, avg / count * 60); rb.AddForce(velocity); Debug.Log("Set velocity to :" + velocity); } } if (_averageVelocity != null) { _averageVelocity.Clear(); } }
private void ChangeTransformationMode() { var totalTransformationModeEntries = Enum.GetValues(typeof(TransformationMode)).Length; _transformationMode = (TransformationMode)(((int)_transformationMode + 1) % totalTransformationModeEntries); NativeUtility.UserFriendlyPrint($"Transformation Mode: {_transformationMode}"); }
private Color GetAxisColor(TransformationMode mode, AxisFlags axis) { Color color = (mActiveMode == mode) ? (GetAxisColor(axis)) : (mSettings.GetAxisColor(axis)); return(color); }
void CheckForChanges() { if ((lastDepthMode != depthMode) || (lastColorResolution != colorResolution) || (lastFPS != fps) || (lastTransformationMode != transformationMode)) { StartKinect(); lastDepthMode = depthMode; lastColorResolution = colorResolution; lastFPS = fps; lastTransformationMode = transformationMode; } }
private void Pick() { Viewport vp = mGraphics.GraphicsDevice.Viewport; mGraphics.GraphicsDevice.Viewport = mInput.Viewport; mPickBuffer.PushMatrix(MatrixMode.View, ViewMatrix); mPickBuffer.PushMatrix(MatrixMode.Projection, ProjectionMatrix); mPickBuffer.PushMatrix(MatrixMode.World, WorldMatrix); mPickBuffer.PushVertexDeclaration(mVertexDeclaration); foreach (TransformationMode mode in mDrawFunctions.Keys) { TransformationMode local_mode = mode; if ((mEnabledModes & local_mode) != local_mode) { continue; } foreach (AxisFlags flags in mDrawFunctions[local_mode].Keys) { AxisFlags local_flags = flags; mPickBuffer.PushPickID(((uint)local_mode << 8) | (uint)flags); mPickBuffer.QueueRenderFunction(delegate(GraphicsDevice device) { mDrawFunctions[local_mode][local_flags](local_flags); }); mPickBuffer.PopPickID(); } } mPickBuffer.PopVertexDeclaration(); mPickBuffer.PopMatrix(MatrixMode.View); mPickBuffer.PopMatrix(MatrixMode.Projection); mPickBuffer.PopMatrix(MatrixMode.World); // render the pick buffer queue mPickBuffer.Render(); // pick using current mouse position and convert picked // value back into an Axis value (safe, as the default pick buffer // id is 0 (AxisFlags.None) and only AxisFlags values are being rendered as // pick ids in the above render pass uint pick_id = mPickBuffer.Pick(mInput.X, mInput.Y); mSelectedAxes = (AxisFlags)(pick_id & 0xFF); mActiveMode = (TransformationMode)((pick_id >> 8) & 0xFF); mGraphics.GraphicsDevice.Viewport = vp; }
/// <summary> /// Creates a new instance of Manipulator /// </summary> /// <param name="graphics">The IGraphicsDeviceService with which drawing will be performed</param> /// <param name="camera">A provider for camera view and projection data</param> /// <param name="input">A provider for input data</param> public Manipulator(IGraphicsDeviceService graphics, XICamera camera, XIInputProvider input) { mGraphics = graphics; mCamera = camera; mInput = input; mSelectedAxes = AxisFlags.None; mActiveMode = TransformationMode.None; mEnabledModes = TransformationMode.None; mVectorSpace = VectorSpace.World; mPickBuffer = new XPickBuffer(graphics); mSettings = new ManipulatorSettings(); mSettings.RestoreDefaults(); mGraphics.DeviceCreated += new EventHandler(OnDeviceCreated); mGraphics.DeviceReset += new EventHandler(CreateDepthBuffer); mGraphics.DeviceResetting += new EventHandler(DisposeDepthBuffer); mGraphics.DeviceDisposing += new EventHandler(OnDeviceDisposing); if ((mGraphics.GraphicsDevice != null) && !mGraphics.GraphicsDevice.IsDisposed) { OnDeviceCreated(this, null); CreateDepthBuffer(this, null); } mUndoStack = new Stack <TransformState>(); mRedoStack = new Stack <TransformState>(); mDrawFunctions = new DrawFunctions(); mManipFunctions = new ManipFunctions(); mDrawFunctions[TransformationMode.None][AxisFlags.X] = mDrawFunctions[TransformationMode.None][AxisFlags.Y] = mDrawFunctions[TransformationMode.None][AxisFlags.Z] = delegate(AxisFlags axis) { Vector3 unit = GetUnitAxis(axis); XPrimitives.DrawLine(mGraphics.GraphicsDevice, Vector3.Zero, unit); }; InitTranslation(); InitRotation(); InitScale(); }
public bool Import(string json) { try { KinectConfiguration fromJson = JsonUtility.FromJson <KinectConfiguration>(json); this.transformationMode = fromJson.transformationMode; this.colorResolution = fromJson.colorResolution; this.depthMode = fromJson.depthMode; this.fps = fromJson.fps; this.volumeScale = fromJson.volumeScale; this.depthRangeModifier = fromJson.depthRangeModifier; return(true); } catch (Exception ex) { Debug.Log("Kinect Configuration deserialization failed with :" + ex.Message); return(false); } }
/// <summary> /// This is called when the request is PUT/POST/PATCH to read the body /// </summary> /// <returns></returns> internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode transformation, CancellationToken cancellationToken) { var request = WebSession.Request; long contentLength = request.ContentLength; // send the request body bytes to server if (contentLength > 0 && hasMulipartEventSubscribers && request.IsMultipartFormData) { var reader = getStreamReader(true); string boundary = HttpHelper.GetBoundaryFromContentType(request.ContentType); using (var copyStream = new CopyStream(reader, writer, bufferPool, bufferSize)) { while (contentLength > copyStream.ReadBytes) { long read = await readUntilBoundaryAsync(copyStream, contentLength, boundary, cancellationToken); if (read == 0) { break; } if (contentLength > copyStream.ReadBytes) { var headers = new HeaderCollection(); await HeaderParser.ReadHeaders(copyStream, headers, cancellationToken); OnMultipartRequestPartSent(boundary, headers); } } await copyStream.FlushAsync(cancellationToken); } } else { await copyBodyAsync(true, false, writer, transformation, OnDataSent, cancellationToken); } }
public void FixedUpdate() { if (_selection.SelectedGameObject == null) { _mode = TransformationMode.None; } switch (_mode) { case TransformationMode.Translate: Translate(); break; case TransformationMode.Rotate: Rotate(); break; case TransformationMode.Scale: Scale(); break; } }
public void StartTransform(TransformationMode mode) { _selection.PerformSelection(); if (!_selection.SelectedGameObject) { return; } _mode = mode; _isTranslateCrossedThreshold = false; _initCursorWorldPos = _cursor.CursorWorldPosition; _initCursorViewPos = _cursor.CursorViewportPosition; _initSelectedWorldPos = _selection.SelectedGameObject.transform.position; _initCursorScreenOffset = (Vector2)Camera.main.WorldToScreenPoint(_initSelectedWorldPos) - _cursor.CursorScreenPosition; var rb = _selection.SelectedGameObject.GetComponent <Rigidbody>(); if (rb) { _initalSelectedIsKinematic = rb.isKinematic; rb.isKinematic = true; } }
private static extern IntPtr qt_pixmap_scaled(IntPtr raw, IntPtr size, AspectRatioMode aspectMode, TransformationMode mode);
void DetermineTransformationMode() { var keys = InputState.KeyboardState; if (keys.IsKeyDown(Keys.G)) { TransformationMode = TransformationMode.Grab; } else if (keys.IsKeyDown(Keys.R)) { TransformationMode = TransformationMode.Rotate; } else if (keys.IsKeyDown(Keys.S)) { TransformationMode = TransformationMode.Scale; } }
public void ResetState() { TransformationMode = TransformationMode.None; SelectedAxes = new Vector3(0, 0, 0); HotKey = HotKeys.None; }
void PollMouseAction() { if (InputState.MouseLeftButtonPressed) { if (TransformationMode != TransformationMode.None) TransformationMode = TransformationMode.Commit; } else if (InputState.MouseRightButtonPressed) { if (TransformationMode == TransformationMode.None) TransformationMode = TransformationMode.Select; else TransformationMode = TransformationMode.Cancel; } }
void PollHotKeys() { var keys = InputState.KeyboardState; if (keys.IsKeyDown(Keys.LeftShift)) { if (InputState.IsKeyPressed(Keys.A)) HotKey = HotKeys.Add; else if (InputState.IsKeyPressed(Keys.I)) HotKey = HotKeys.Insert; } if (keys.IsKeyDown(Keys.LeftControl)) { if (InputState.IsKeyPressed(Keys.O)) HotKey = HotKeys.Open; else if (InputState.IsKeyPressed(Keys.P)) HotKey = HotKeys.PlayMode; else if (InputState.IsKeyPressed(Keys.S)) HotKey = HotKeys.Save; } if (InputState.IsKeyPressed(Keys.Delete)) if (TransformationMode == TransformationMode.None) HotKey = HotKeys.Delete; if (InputState.IsKeyPressed(Keys.M)) HotKey = HotKeys.Make; if (InputState.IsKeyPressed(Keys.Space)) HotKey = HotKeys.TogglePlay; if (keys.IsKeyDown(Keys.Subtract)) HotKey = HotKeys.Previous; if (keys.IsKeyDown(Keys.Add)) HotKey = HotKeys.Next; if (keys.IsKeyDown(Keys.NumPad0)) HotKey = HotKeys.Camera0; // Cancel any transformation operations when the pressed key is part of a hotkey command if (HotKey != HotKeys.None) TransformationMode = TransformationMode.None; }
public Pixmap Scale(Size size, AspectRatioMode aspectMode = AspectRatioMode.IgnoreAspectRatio, TransformationMode mode = TransformationMode.FastTransformation) { return(new Pixmap(qt_pixmap_scaled(Handle, size.Handle, aspectMode, mode))); }
private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, HttpWriter writer, TransformationMode transformation, Action <byte[], int, int> onCopy, CancellationToken cancellationToken) { var stream = getStreamReader(isRequest); var requestResponse = isRequest ? (RequestResponseBase)WebSession.Request : WebSession.Response; bool isChunked = useOriginalHeaderValues? requestResponse.OriginalIsChunked : requestResponse.IsChunked; long contentLength = useOriginalHeaderValues ? requestResponse.OriginalContentLength : requestResponse.ContentLength; if (transformation == TransformationMode.None) { await writer.CopyBodyAsync(stream, isChunked, contentLength, onCopy, cancellationToken); return; } LimitedStream limitedStream; Stream decompressStream = null; string contentEncoding = useOriginalHeaderValues ? requestResponse.OriginalContentEncoding : requestResponse.ContentEncoding; Stream s = limitedStream = new LimitedStream(stream, bufferPool, isChunked, contentLength); if (transformation == TransformationMode.Uncompress && contentEncoding != null) { s = decompressStream = DecompressionFactory.Create(contentEncoding, s); } try { using (var bufStream = new CustomBufferedStream(s, bufferPool, bufferSize, true)) { await writer.CopyBodyAsync(bufStream, false, -1, onCopy, cancellationToken); } } finally { decompressStream?.Dispose(); await limitedStream.Finish(); limitedStream.Dispose(); } }
internal async Task CopyResponseBodyAsync(HttpWriter writer, TransformationMode transformation, CancellationToken cancellationToken) { await copyBodyAsync(false, false, writer, transformation, OnDataReceived, cancellationToken); }