/// <inheritdoc /> public IDocumentQuery <TProjection> SelectFields <TProjection>(ProjectionBehavior projectionBehavior, params string[] fields) { return(SelectFields <TProjection>(new QueryData(fields, fields) { IsProjectInto = true, ProjectionBehavior = projectionBehavior })); }
/// <inheritdoc /> public IDocumentQuery <TProjection> SelectFields <TProjection>(ProjectionBehavior projectionBehavior) { var propertyInfos = ReflectionUtil.GetPropertiesAndFieldsFor <TProjection>(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToList(); var projections = propertyInfos.Select(x => x.Name).ToArray(); var fields = propertyInfos.Select(p => p.Name).ToArray(); return(SelectFields <TProjection>(new QueryData(fields, projections) { IsProjectInto = true, ProjectionBehavior = projectionBehavior })); }
/// <summary> /// Set the preferred behavior of the projection matrix. /// </summary> /// <param name="behavior">The behavior of which projection matrix to apply.</param> public void SetProjectionBehavior(ProjectionBehavior behavior) { FlushRenderStream(); CurrentState.ProjectionBehavior = behavior; SyncViewMatrix(); }
/// <inheritdoc /> IDocumentQueryCustomization IDocumentQueryCustomization.Projection(ProjectionBehavior projectionBehavior) { Projection(projectionBehavior); return(this); }
/// <inheritdoc /> IRawDocumentQuery <T> IRawDocumentQuery <T> .Projection(ProjectionBehavior projectionBehavior) { ProjectionBehavior = projectionBehavior; return(this); }
/// <summary> /// Render a line made out of quads. /// </summary> /// <param name="pointOne">The point to start the line.</param> /// <param name="pointTwo">The point to end the line at.</param> /// <param name="color">The color of the line.</param> /// <param name="thickness">The thickness of the line in world units. The line will always be at least 1 pixel thick.</param> /// <param name="snapToPixel">Whether to snap the start and ending positions to the nearest pixel.</param> /// <param name="renderMode">How to treat the points given.</param> public void RenderLine(Vector3 pointOne, Vector3 pointTwo, Color color, float thickness = 1f, bool snapToPixel = true, RenderLineMode renderMode = RenderLineMode.Center) { bool cameraWasOn = CurrentState.ViewMatrix !.Value; SetUseViewMatrix(false); ProjectionBehavior oldProjection = CurrentState.ProjectionBehavior !.Value; SetProjectionBehavior(ProjectionBehavior.AlwaysCameraProjection); Matrix4x4 viewMatrix = cameraWasOn ? Camera.ViewMatrix : Matrix4x4.Identity; if (cameraWasOn) { thickness *= Camera.CalculatedScale; } pointOne = Vector3.Transform(pointOne, ModelMatrix * viewMatrix); pointTwo = Vector3.Transform(pointTwo, ModelMatrix * viewMatrix); PushModelMatrix(Matrix4x4.Identity, false); if (snapToPixel) { if (thickness < 1.0f) { thickness = 1.0f; } pointOne = pointOne.IntCastRoundXY(); pointTwo = pointTwo.IntCastRoundXY(); } Vector3 direction = Vector3.Normalize(pointTwo - pointOne); var normal = new Vector3(-direction.Y, direction.X, 0); Vector3 delta = normal * (thickness / 2f); Vector3 deltaNeg = -delta; if (renderMode == RenderLineMode.Inward) { pointOne += delta; pointTwo += delta; } else if (renderMode == RenderLineMode.Outward) { pointOne -= delta; pointTwo -= delta; } Span <VertexData> vertices = RenderStream.GetStreamMemory(4, BatchMode.Quad); vertices[0].Vertex = pointOne + delta; vertices[1].Vertex = pointTwo + delta; vertices[2].Vertex = pointTwo + deltaNeg; vertices[3].Vertex = pointOne + deltaNeg; uint c = color.ToUint(); for (var i = 0; i < vertices.Length; i++) { vertices[i].Color = c; vertices[i].UV = Vector2.Zero; } PopModelMatrix(); SetUseViewMatrix(cameraWasOn); SetProjectionBehavior(oldProjection); }