public unsafe void TestCast() { var fromMatrix = new RawMatrix { Row1 = new RawVector4 { X = 1.0f, Y = 2.0f, Z = 3.0f, W = 4.0f }, Row4 = new RawVector4 { X = 5.0f, Y = 6.0f, Z = 7.0f, W = 8.0f } }; // Cast RawMatrix to Matrix structure Matrix toMatrix = *(Matrix *)Interop.Cast(ref fromMatrix); Assert.True(toMatrix.Row1 == new Vector4 { X = 1.0f, Y = 2.0f, Z = 3.0f, W = 4.0f }); Assert.True(toMatrix.Row4 == new Vector4 { X = 5.0f, Y = 6.0f, Z = 7.0f, W = 8.0f }); // Check CastOut: output a Matrix by using a function that is requiring a RawMatrix type Matrix temp; Modify(out *(RawMatrix *)Interop.CastOut(out temp)); Assert.True(temp.Row1 == new Vector4 { X = 1.0f, Y = 2.0f, Z = 3.0f, W = 4.0f }); Assert.True(temp.Row4 == new Vector4 { X = 5.0f, Y = 6.0f, Z = 7.0f, W = 8.0f }); }
public override IMatrix GetNext() { List <int> labelsList = new List <int>(); List <Vector <Double> > instanceList = new List <Vector <double> >(); while (!sr.EndOfStream && labelsList.Count < MaxSlots) { string line = sr.ReadLine(); var f = line.Split(delim); if (SparseFormat) { labelsList.Add(int.Parse(f[0])); dim = int.Parse(f[1]); var valueList = new List <Tuple <int, double> >(); for (int k = 2; k < f.Length; k++) { string[] sub = f[k].Split(':'); int cordinate = int.Parse(sub[0]); double value = double.Parse(sub[1]); valueList.Add(new Tuple <int, double>(cordinate, value * NormalizationFactor)); } var features = Vector <double> .Build.DenseOfIndexed(dim, valueList); instanceList.Add(features); } else { //dense format dim = f.Length; if (LabelColumn >= dim) { labelsList.Add(int.MaxValue); } else { labelsList.Add(int.Parse(f[LabelColumn])); dim--; } double[] featuresArray = new double[dim]; for (int k = 0; k < f.Length; k++) { if (k == LabelColumn) { continue; } featuresArray[(k > LabelColumn) ? k - 1 : k] = double.Parse(f[k]); } var features = Vector <double> .Build.DenseOfArray(featuresArray); instanceList.Add(features * NormalizationFactor); } } Labels = labelsList.ToArray(); var m = new RawMatrix(Matrix <double> .Build.DenseOfRowVectors(instanceList), Scale, EMatrixFormat.ColumnMajor, 0); return(m); }
RawMatrix Map(SharpDX.Matrix from) { RawMatrix matIdentity = new RawMatrix();// Matrix.Identity; matIdentity.M11 = from.M11; matIdentity.M12 = from.M12; matIdentity.M13 = from.M13; matIdentity.M14 = from.M14; matIdentity.M21 = from.M21; matIdentity.M22 = from.M22; matIdentity.M23 = from.M23; matIdentity.M24 = from.M24; matIdentity.M31 = from.M31; matIdentity.M32 = from.M32; matIdentity.M33 = from.M33; matIdentity.M34 = from.M34; matIdentity.M41 = from.M41; matIdentity.M42 = from.M42; matIdentity.M43 = from.M43; matIdentity.M44 = from.M44; return(matIdentity); }
/// <summary> /// /// </summary> public static RawVector3 Multiply(this RawMatrix m, float x, float y, float z, float w) { return(new RawVector3( m.M11 * x + m.M12 * y + m.M13 * z + m.M14 * w , m.M21 * x + m.M22 * y + m.M23 * z + m.M24 * w , m.M31 * x + m.M32 * y + m.M33 * z + m.M34 * w )); }
/// <summary> /// Draws a line strip in screen space with a specified input transformation matrix. /// </summary> /// <param name="vertices"><para>Array of vertices that make up the line. See <see cref="RawVector3"/>.</para></param> /// <param name="transform"><para>A scale, rotate, and translate (SRT) matrix for transforming the points. See <see cref="RawMatrix"/>. If this matrix is a projection matrix, any stippled lines will be drawn with a perspective-correct stippling pattern. Or, you can transform the vertices and use <see cref="SharpDX.Direct3D9.Line.Draw"/> to draw the line with a nonperspective-correct stipple pattern.</para></param> /// <param name="color"><para>Color of the line. See <see cref="RawColor4"/>.</para></param> /// <returns>If the method succeeds, the return value is <see cref="SharpDX.Direct3D9.ResultCode.Success"/>. If the method fails, the return value can be one of the following: <see cref="SharpDX.Direct3D9.ResultCode.InvalidCall"/>, D3DXERR_INVALIDDATA.</returns> /// <unmanaged>HRESULT ID3DXLine::DrawTransform([In] const void* pVertexList,[In] unsigned int dwVertexListCount,[In] const D3DXMATRIX* pTransform,[In] D3DCOLOR Color)</unmanaged> public void DrawTransform(RawVector3[] vertices, RawMatrix transform, RawColorBGRA color) { unsafe { fixed(void *pVertexListRef = vertices) DrawTransform((IntPtr)pVertexListRef, vertices.Length, ref transform, color); } }
private void SetupMatrices(int width, int height) { RawMatrix matOrtho = Map(SharpDX.Matrix.OrthoOffCenterLH(0, width, height, 0, 0.0f, 1.0f)); RawMatrix matIdentity = Map(SharpDX.Matrix.Identity); this.device.SetTransform(TransformState.Projection, matOrtho); this.device.SetTransform(TransformState.World, matIdentity); this.device.SetTransform(TransformState.View, matIdentity); }
/// <summary> /// Draws a line strip in screen space with a specified input transformation matrix. /// </summary> /// <param name="vertices"><para>Array of vertices that make up the line. See <see cref="RawVector3"/>.</para></param> /// <param name="transform"><para>A scale, rotate, and translate (SRT) matrix for transforming the points. See <see cref="RawMatrix"/>. If this matrix is a projection matrix, any stippled lines will be drawn with a perspective-correct stippling pattern. Or, you can transform the vertices and use <see cref="SharpDX.Direct3D9.Line.Draw"/> to draw the line with a nonperspective-correct stipple pattern.</para></param> /// <param name="color"><para>Color of the line. See <see cref="RawColor4"/>.</para></param> /// <returns>If the method succeeds, the return value is <see cref="SharpDX.Direct3D9.ResultCode.Success"/>. If the method fails, the return value can be one of the following: <see cref="SharpDX.Direct3D9.ResultCode.InvalidCall"/>, D3DXERR_INVALIDDATA.</returns> /// <unmanaged>HRESULT ID3DXLine::DrawTransform([In] const void* pVertexList,[In] unsigned int dwVertexListCount,[In] const D3DXMATRIX* pTransform,[In] D3DCOLOR Color)</unmanaged> public void DrawTransform <T>(T[] vertices, RawMatrix transform, RawColorBGRA color) where T : struct { unsafe { if (Utilities.SizeOf <T>() != sizeof(RawVector3)) { throw new ArgumentException("Invalid size for T. Must be 3 floats (12 bytes)"); } DrawTransform((IntPtr)Interop.Fixed(vertices), vertices.Length, ref transform, color); } }
private void Modify(out RawMatrix matrix) { matrix = new RawMatrix { Row1 = new RawVector4 { X = 1.0f, Y = 2.0f, Z = 3.0f, W = 4.0f }, Row4 = new RawVector4 { X = 5.0f, Y = 6.0f, Z = 7.0f, W = 8.0f }, }; }
public void Render() { context.ClearRenderTargetView(renderTargetView, new RawColor4(0, 128, 255, 255)); context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); camPosRel = new RawVector3((float)Math.Sin(CamRot) * CamDis, CamHeight, (float)Math.Cos(CamRot) * CamDis); camPosRel += CamPos; view = Matrix.LookAtLH(camPosRel, CamPos, Vector3.UnitY); foreach (RenderObject ro in objects) { ro.Render(context, view, proj); } swapChain.Present(0, PresentFlags.None); }
public void Render() { RawVector3 position = new Vector3(PositionX, PositionY, PositionZ); RawVector3 lookAt = new Vector3(0, 0, 1); float pitch = RotationX * 0.0174532925f; float yaw = RotationY * 0.0174532925f;; float roll = RotationZ * 0.0174532925f;; RawMatrix rotationMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, roll); lookAt = Vector3.TransformCoordinate(lookAt, rotationMatrix); RawVector3 up = Vector3.TransformCoordinate(Vector3.UnitY, rotationMatrix); lookAt = Vector3.Add(position, lookAt); ViewMatrix = Matrix.LookAtLH(position, lookAt, up); }
public virtual byte[][] Translate() { if (RawMatrix == null) { throw new Exception("계산 전용 변환 클래스입니다."); } byte[][] temp = RawMatrix.Copy2D(); this.Translate(ref temp); foreach (var t in Filters) { t.Translate(ref temp); } return(temp); }
public static void Resize(PictureBox f) { if (renderTargetView != null) { renderTargetView.Dispose(); } backBuffer.Dispose(); swapChain.ResizeBuffers(1, f.ClientSize.Width, f.ClientSize.Height, SharpDX.DXGI.Format.Unknown, SwapChainFlags.AllowModeSwitch); backBuffer = Texture2D.FromSwapChain <Texture2D>(swapChain, 0); renderTargetView = new RenderTargetView(device, backBuffer); viewport = new RawViewportF(); viewport.X = 0; viewport.Y = 0; viewport.Width = f.ClientSize.Width; viewport.Height = f.ClientSize.Height; context.Rasterizer.SetViewport(viewport); proj = Matrix.PerspectiveFovLH((float)Math.PI / 3f, f.ClientSize.Width / (float)f.ClientSize.Height, 0.5f, 100f); }
public void Resize(PictureBox f) { if (renderTargetView != null) { renderTargetView.Dispose(); } if (depthStencilView != null) { depthStencilView.Dispose(); } if (backBuffer != null) { backBuffer.Dispose(); } swapChain.ResizeBuffers(1, f.ClientSize.Width, f.ClientSize.Height, Format.Unknown, SwapChainFlags.AllowModeSwitch); viewport = new RawViewportF(); viewport.X = 0; viewport.Y = 0; viewport.Width = f.ClientSize.Width; viewport.Height = f.ClientSize.Height; viewport.MinDepth = 0; viewport.MaxDepth = 1; backBuffer = Texture2D.FromSwapChain <Texture2D>(swapChain, 0); renderTargetView = new RenderTargetView(device, backBuffer); Texture2D depthBuffer = new Texture2D(device, new Texture2DDescription() { Format = Format.D32_Float_S8X24_UInt, ArraySize = 1, MipLevels = 1, Width = f.ClientSize.Width, Height = f.ClientSize.Height, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }); depthStencilView = new DepthStencilView(device, depthBuffer); context.Rasterizer.SetViewport(viewport); context.OutputMerger.SetTargets(depthStencilView, renderTargetView); context.OutputMerger.SetRenderTargets(depthStencilView, renderTargetView); proj = Matrix.PerspectiveFovLH((float)Math.PI / 3f, f.ClientSize.Width / (float)f.ClientSize.Height, 0.5f, 100000f); }
public static void Render() { context.OutputMerger.SetRenderTargets(renderTargetView); context.ClearRenderTargetView(renderTargetView, new RawColor4(0, 128, 255, 255)); camPos = new RawVector3((float)Math.Sin(CamRot) * CamDis, 0, (float)Math.Cos(CamRot) * CamDis); view = Matrix.LookAtLH(camPos, Vector3.Zero, Vector3.UnitY); world = Matrix.Identity * view * proj; world = Matrix.Transpose(world); DataStream data; context.MapSubresource(constantBuffer, 0, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out data); data.Write(world); context.UnmapSubresource(constantBuffer, 0); context.VertexShader.SetConstantBuffer(0, constantBuffer); foreach (RenderObject ro in objects) { ro.Render(context); } swapChain.Present(0, PresentFlags.None); }
public unsafe void TestCastArray() { var fromMatrices = new RawMatrix[] { new RawMatrix { Row1 = new RawVector4 { X = 1.0f, Y = 2.0f, Z = 3.0f, W = 4.0f }, Row4 = new RawVector4 { X = 5.0f, Y = 6.0f, Z = 7.0f, W = 8.0f } } }; // Cast RawMatrix[] to Matrix[] var toMatrices = Interop.CastArray <Matrix, RawMatrix>(fromMatrices); // Check validity Assert.True(toMatrices != null); Assert.True(fromMatrices.Length == toMatrices.Length); // Check that access is possible ValidateArray(toMatrices); }
// Token: 0x06000182 RID: 386 RVA: 0x00013E70 File Offset: 0x00012070 public void DrawTexture(string textureKey, RectangleF rect, float rotation = 0f, float opacity = 1f) { D3D9Texture texture = this.textureManager.GetTexture(textureKey); this.sprite.Begin(SpriteFlags.AlphaBlend); RawMatrix transform = this.sprite.Transform; Vector2 vector; vector..ctor(rect.Width / (float)texture.Bitmap.Width, rect.Height / (float)texture.Bitmap.Height); if (rotation == 0f) { this.sprite.Transform = Matrix.Scaling(vector.X, vector.Y, 0f) * Matrix.Translation(rect.X, rect.Y, 0f); this.sprite.Draw(texture.Texture, Color.White); } else { Vector3 vector2 = texture.Center.ToVector3(0f); this.sprite.Transform = Matrix.Translation(-vector2) * Matrix.RotationZ(rotation) * Matrix.Translation(vector2) * Matrix.Scaling(vector.X, vector.Y, 0f) * Matrix.Translation(rect.X, rect.Y, 0f); this.sprite.Draw(texture.Texture, Color.White); } this.sprite.Transform = transform; this.sprite.End(); }
/// <summary> /// Sets the named property to the given value. /// </summary> /// <param name="index">Index of the property</param> /// <param name="value">Value of the property</param> /// <unmanaged>HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize)</unmanaged> public unsafe void SetValue(int index, RawMatrix value) { SetValue(index, PropertyType.Matrix4x4, new IntPtr(&value), sizeof(RawMatrix)); }
/// <summary> /// Sets the named property to the given value. /// </summary> /// <param name="name">Name of the property</param> /// <param name="value">Value of the property</param> /// <unmanaged>HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize)</unmanaged> public unsafe void SetValueByName(string name, RawMatrix value) { SetValueByName(name, PropertyType.Matrix4x4, new IntPtr(&value), sizeof(RawMatrix)); }
/// <summary> /// Sets a matrix. /// </summary> /// <param name="effectHandle">The effect handle.</param> /// <param name="value">The value.</param> /// <returns> /// A <see cref="SharpDX.Result"/> object describing the result of the operation. /// </returns> /// <unmanaged>HRESULT ID3DXBaseEffect::SetMatrix([In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix)</unmanaged> public void SetValue(EffectHandle effectHandle, RawMatrix value) { SetMatrix(effectHandle, ref value); }
public override IMatrix GetNext() { if (!layerPrepared) { convolutionEngine.Prepare(); layerPrepared = true; } if (Features == null)//if features are not set, read from file { if (sr.EndOfStream) { return(null); } string line = sr.ReadLine(); var f = line.Split(Delimiter); if (SparseFormat) { Console.WriteLine("Sparse Format"); Labels = new int[] { int.Parse(f[0]) }; dim = int.Parse(f[1]); var valueList = new List <Tuple <int, double> >(); for (int k = 2; k < f.Length; k++) { string[] sub = f[k].Split(':'); for (int i = 0; i < sub.Length; i++) { Console.WriteLine(sub[i]); } int cordinate = int.Parse(sub[0]); double value = double.Parse(sub[1]); valueList.Add(new Tuple <int, double>(cordinate, value * NormalizationFactor)); } Features = Vector <double> .Build.DenseOfIndexed(dim, valueList); } else { //dense format Console.WriteLine("Dense Format"); dim = f.Length; if (LabelColumn >= dim) { Labels = new int[] { int.MaxValue } } ; else { Labels = new int[] { int.Parse(f[LabelColumn]) }; dim--; } double[] featuresArray = new double[dim]; for (int k = 0; k < f.Length; k++) { if (k == LabelColumn) { continue; } featuresArray[(k > LabelColumn) ? k - 1 : k] = double.Parse(f[k]); } Features = Vector <double> .Build.DenseOfArray(featuresArray); } } double[,] mat = new double[Corners.Length, Offsets.Length]; for (int c = 0; c < Corners.Length; c++) { for (int o = 0; o < Offsets.Length; o++) { var l = convolutionEngine.Location(Corners[c], Offsets[o], InputShape); mat[c, o] = (l >= 0) ? Features[l] : 0; // padding } } var m = new RawMatrix(Matrix <double> .Build.DenseOfArray(mat), Scale, EMatrixFormat.ColumnMajor, 0); _features = null; return(m); }
/// <summary> /// Sets a matrix. /// </summary> /// <param name="device">The device.</param> /// <param name="effectHandle">The effect handle.</param> /// <param name="value">The value.</param> /// <returns> /// A <see cref="SharpDX.Result"/> object describing the result of the operation. /// </returns> /// <unmanaged>HRESULT ID3DXConstantTable::SetMatrix([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix)</unmanaged> public void SetValue(Device device, EffectHandle effectHandle, RawMatrix value) { SetMatrix(device, effectHandle, ref value); }
/// <summary> /// Draws the bitmap. /// </summary> /// <param name="bitmap">The bitmap.</param> /// <param name="opacity">The opacity.</param> /// <param name="interpolationMode">The interpolation mode.</param> /// <param name="sourceRectangle">The source rectangle.</param> /// <param name="perspectiveTransformRef">The perspective transform ref.</param> /// <unmanaged>void ID2D1DeviceContext::DrawBitmap([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_F* destinationRectangle,[In] float opacity,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In, Optional] const D2D_RECT_F* sourceRectangle,[In, Optional] const D2D_MATRIX_4X4_F* perspectiveTransform)</unmanaged> public void DrawBitmap(SharpDX.Direct2D1.Bitmap bitmap, float opacity, SharpDX.Direct2D1.InterpolationMode interpolationMode, RawRectangleF sourceRectangle, RawMatrix perspectiveTransformRef) { DrawBitmap(bitmap, null, opacity, interpolationMode, sourceRectangle, perspectiveTransformRef); }
/// <summary> /// Converts the specified expression to a RawMatrix. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The RawMatrix. Returns <c>null</c> if the specified expression is not vector.</returns> public static RawMatrix AsRawMatrix(this SymbolicExpression expression) { if (!expression.IsVector()) { return null; } int rowCount = 0; int columnCount = 0; if (expression.IsMatrix()) { if (expression.Type == SymbolicExpressionType.RawVector) { return new RawMatrix(expression.Engine, expression.DangerousGetHandle()); } else { rowCount = expression.GetFunction<Rf_nrows>()(expression.DangerousGetHandle()); columnCount = expression.GetFunction<Rf_ncols>()(expression.DangerousGetHandle()); } } if (columnCount == 0) { rowCount = expression.GetFunction<Rf_length>()(expression.DangerousGetHandle()); columnCount = 1; } IntPtr coerced = expression.GetFunction<Rf_coerceVector>()(expression.DangerousGetHandle(), SymbolicExpressionType.RawVector); var dim = new IntegerVector(expression.Engine, new[] { rowCount, columnCount }); SymbolicExpression dimSymbol = expression.Engine.GetPredefinedSymbol("R_DimSymbol"); var matrix = new RawMatrix(expression.Engine, coerced); matrix.SetAttribute(dimSymbol, dim); return matrix; }
public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { VerticalSyncEnabled = DSystemConfiguration.VerticalSyncEnabled; var factory = new Factory1(); var adapter = factory.GetAdapter1(0); var monitor = adapter.GetOutput(0); var modes = monitor.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced); var rational = new Rational(0, 1); if (VerticalSyncEnabled) { foreach (var mode in modes) { if (mode.Width == configuration.Width && mode.Height == configuration.Height) { rational = new Rational(mode.RefreshRate.Numerator, mode.RefreshRate.Denominator); break; } } } var adapterDescription = adapter.Description; VideoCardMemory = adapterDescription.DedicatedVideoMemory >> 10 >> 10; VideoCardDescription = adapterDescription.Description; monitor.Dispose(); adapter.Dispose(); factory.Dispose(); var swapChainDesc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(configuration.Width, configuration.Height, rational, Format.R8G8B8A8_UNorm), Usage = Usage.RenderTargetOutput, OutputHandle = windowHandle, SampleDescription = new SampleDescription(1, 0), IsWindowed = !DSystemConfiguration.FullScreen, Flags = SwapChainFlags.None, SwapEffect = SwapEffect.Discard }; SharpDX.Direct3D11.Device device; SwapChain swapChain; SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, swapChainDesc, out device, out swapChain); Device = device; SwapChain = swapChain; DeviceContext = device.ImmediateContext; var backBuffer = Texture2D.FromSwapChain <Texture2D>(SwapChain, 0); RenderTargetView = new RenderTargetView(device, backBuffer); backBuffer.Dispose(); Texture2DDescription depthBufferDesc = new Texture2DDescription() { Width = configuration.Width, Height = configuration.Height, MipLevels = 1, ArraySize = 1, Format = Format.D24_UNorm_S8_UInt, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }; DepthStencilBuffer = new Texture2D(device, depthBufferDesc); DepthStencilStateDescription depthStencilDesc = new DepthStencilStateDescription() { IsDepthEnabled = true, DepthWriteMask = DepthWriteMask.All, DepthComparison = Comparison.Less, IsStencilEnabled = true, StencilReadMask = 0xFF, StencilWriteMask = 0xFF, FrontFace = new DepthStencilOperationDescription() { FailOperation = StencilOperation.Keep, DepthFailOperation = StencilOperation.Increment, PassOperation = StencilOperation.Keep, Comparison = Comparison.Always }, BackFace = new DepthStencilOperationDescription() { FailOperation = StencilOperation.Keep, DepthFailOperation = StencilOperation.Decrement, PassOperation = StencilOperation.Keep, Comparison = Comparison.Always } }; DepthStencilState = new DepthStencilState(Device, depthStencilDesc); DeviceContext.OutputMerger.SetDepthStencilState(DepthStencilState, 1); DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription() { Format = Format.D24_UNorm_S8_UInt, Dimension = DepthStencilViewDimension.Texture2D, Texture2D = new DepthStencilViewDescription.Texture2DResource() { MipSlice = 0 } }; DepthStencilView = new DepthStencilView(Device, DepthStencilBuffer, depthStencilViewDesc); DeviceContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView); RasterizerStateDescription rasterDesc = new RasterizerStateDescription() { IsAntialiasedLineEnabled = false, CullMode = CullMode.Back, DepthBias = 0, DepthBiasClamp = .0f, IsDepthClipEnabled = true, FillMode = FillMode.Solid, IsFrontCounterClockwise = false, IsMultisampleEnabled = false, IsScissorEnabled = false, SlopeScaledDepthBias = .0f }; RasterState = new RasterizerState(Device, rasterDesc); DeviceContext.Rasterizer.State = RasterState; DeviceContext.Rasterizer.SetViewport(0, 0, configuration.Width, configuration.Height, 0, 1); ProjectionMatrix = Matrix.PerspectiveFovLH((float)(Math.PI / 4), ((float)configuration.Width / (float)configuration.Height), DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth); WorldMatrix = Matrix.Identity; return(true); } catch { return(false); } }
/// <summary> /// /// </summary> public static RawVector3 TransformCoord(this RawMatrix m, RawVector3 v) { var v2 = Multiply(m, v.X, v.Y, v.Z, 1); return(new RawVector3(v2.X, v2.Y, v2.Z)); }