public DrawInfo(Matrix3?matrix = null, Matrix3?matrixInverse = null, ColourInfo?colour = null, BlendingInfo?blending = null) { Matrix = matrix ?? Matrix3.Identity; MatrixInverse = matrixInverse ?? Matrix3.Identity; Colour = colour ?? ColourInfo.SingleColour(Color4.White); Blending = blending ?? new BlendingInfo(); }
public Matrix3 GetMatrix3(StringHash key, Matrix3? @default = null) { var result = @default.GetValueOrDefault(Matrix3.Zero); Urho3D_Object_Event_GetMatrix3(_map, key.Hash, ref result); return(result); }
public TextureConverter(uint[] data, int width, byte?alphaTolerance, float?hullTolerance, bool?holeDetection, bool?multipartDetection, bool?pixelOffsetOptimization, Matrix3?transform) { Initialize(data, width, alphaTolerance, hullTolerance, holeDetection, multipartDetection, pixelOffsetOptimization, transform); }
public Box2Rotated GetWorldBounds(TileRef tileRef, Matrix3?worldMatrix = null, Angle?angle = null) { var grid = _mapManager.GetGrid(tileRef.GridIndex); if (worldMatrix == null || angle == null) { var gridXform = EntityManager.GetComponent <TransformComponent>(grid.GridEntityId); var(_, wAng, wMat) = gridXform.GetWorldPositionRotationMatrix(); worldMatrix = wMat; angle = wAng; } var center = worldMatrix.Value.Transform((Vector2)tileRef.GridIndices + 0.5f) * grid.TileSize; var translatedBox = Box2.CenteredAround(center, (grid.TileSize, grid.TileSize)); return(new Box2Rotated(translatedBox, -angle.Value, center)); }
public DrawInfo(Matrix3?matrix = null, Matrix3?matrixInverse = null) { Matrix = matrix ?? Matrix3.Identity; MatrixInverse = matrixInverse ?? Matrix3.Identity; }
public static VertexBufferBinding Load(GraphicsDevice device, String filename, Matrix3?positionTransform = null) { var library = Injector.Global.Resolve <Library>(); var loader = new WavefrontObjLoader(); using (var stream = library.OpenRead(filename)) { loader.LoadObj(stream); } if (positionTransform.HasValue) { Matrix3 transform = positionTransform.Value; for (int j = 0; j < loader.VertexList.Count; j++) { loader.VertexList[j].Vector = Matrix3.Transform(loader.VertexList[j].Vector, transform); } } // vertex buffer var vertexCount = loader.TriangleCount * 3; var vertices = new PositionColorTexture[vertexCount]; int i = 0; foreach (var face in loader.FaceList) { var v = face.VertexIndexList; var t = face.TextureVertexIndexList; vertices[i + 0] = new PositionColorTexture { Position = loader.VertexList[v[0] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[0] - 1].Vector }; vertices[i + 2] = new PositionColorTexture { Position = loader.VertexList[v[1] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[1] - 1].Vector }; vertices[i + 1] = new PositionColorTexture { Position = loader.VertexList[v[2] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[2] - 1].Vector }; i += 3; if (v.Length == 4) { vertices[i + 0] = new PositionColorTexture { Position = loader.VertexList[v[2] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[2] - 1].Vector }; vertices[i + 2] = new PositionColorTexture { Position = loader.VertexList[v[3] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[3] - 1].Vector }; vertices[i + 1] = new PositionColorTexture { Position = loader.VertexList[v[0] - 1].Vector, Color = new Vector4(1, 1, 1, 1), Texture = loader.TextureList[t[0] - 1].Vector }; i += 3; } } var buffer = GraphicsBuffer.Create(device, vertices, false); return(new VertexBufferBinding { Buffer = buffer, Count = vertexCount, Declaration = PositionColorTexture.Layout, Stride = PositionColorTexture.Layout.Stride, }); }
private void Initialize(uint[] data, int?width, byte?alphaTolerance, float?hullTolerance, bool?holeDetection, bool?multipartDetection, bool?pixelOffsetOptimization, Matrix3?transform) { if (data != null && !width.HasValue) { throw new ArgumentNullException("width", "'width' can't be null if 'data' is set."); } if (data == null && width.HasValue) { throw new ArgumentNullException("data", "'data' can't be null if 'width' is set."); } if (data != null && width.HasValue) { SetTextureData(data, width.Value); } if (alphaTolerance.HasValue) { AlphaTolerance = alphaTolerance.Value; } else { AlphaTolerance = 20; } if (hullTolerance.HasValue) { HullTolerance = hullTolerance.Value; } else { HullTolerance = 1.5f; } if (holeDetection.HasValue) { HoleDetection = holeDetection.Value; } else { HoleDetection = false; } if (multipartDetection.HasValue) { MultipartDetection = multipartDetection.Value; } else { MultipartDetection = false; } if (pixelOffsetOptimization.HasValue) { PixelOffsetOptimization = pixelOffsetOptimization.Value; } else { PixelOffsetOptimization = false; } if (transform.HasValue) { Transform = transform.Value; } else { Transform = Matrix3.Identity; } }