/** If you wrap this with another class you MUST call render each frame */ public nSprite[] Render(nGraphicsPipe pipe) { if (_data == null) _data = new nSprite[1] { pipe.Sprite() }; if (Data.Invalid) { _data[0].Load(Data); Data.Reset(); } return _data; }
public nSprite[] Render(nGraphicsPipe pipe) { /* We can't reuse our sprites if we're changing sizes; reset them */ if (_size.Invalid) _data = null; if (Rebuild()) { var pos = _camera.ScreenBounds; var wide = (int)Math.Ceiling (pos.width / Size [0]); var high = (int)Math.Ceiling (pos.height / Size [1]); /* Always add one extra tile in every direction, to account for offset */ wide += 2; high += 2; /* new set of sprites */ if (_data == null) { _data = new nSprite[wide * high]; for (var i = 0; i < _data.Length; ++i) { _data [i] = pipe.Sprite (); } } for (var x = 0; x < wide; ++x) { for (var y = 0; y < high; ++y) { /* Tile coordinates */ var xMin = pos.x + Size [0] * x; var xMax = xMin + Size [0]; var yMin = pos.y + Size [1] * y; var yMax = yMin + Size [1]; /* Apply offset for hidden bits */ xMin -= Size[0]; xMax -= Size[0]; yMin -= Size[1]; yMax -= Size[1]; /* Set sprite to cover entire size of window */ var s = _data [y * wide + x]; s.Depth = _depth; s.Texture = Texture; s.Color.Set (Color); //s.Points.Set (new float[8] {xMax, yMax, xMax, yMin, xMin, yMin, xMin, yMax}); s.Points.Set (new float[8] {xMax, yMax, xMin, yMax, xMin, yMin, xMax, yMin}); } } Reset (); } /* Moved is a special case; don't rebuild if all we did was shuffle a little */ if (_offset.Invalid) { /* Offset cannot be larger than the size of the tile */ var ox = _offset[0] % Size[0]; var oy = _offset[1] % Size[1]; for (int i = 0; i < _data.Length; ++i) { _data[i].Position[0] = ox; _data[i].Position[1] = oy; if (_uv != null) { _data[i].UV.Set (_uv); } } _uv = null; _offset.Reset(); } return _data; }
public nSprite[] Render(nGraphicsPipe pipe) { if (_data == null) { _data = new nSprite[4]; for (var i = 0; i < _data.Length; ++i) { _data[i] = pipe.Sprite (); _data[i].Depth = _depth; } _data[0].Points.Set(LineSegment(_points[0], _points[1] + _thickness / 2.0f, _points[2], _points[3] - _thickness / 2.0f)); _data[1].Points.Set(LineSegment(_points[2], _points[3], _points[4], _points[5])); _data[2].Points.Set(LineSegment(_points[4], _points[5] - _thickness / 2.0f, _points[6], _points[7] + _thickness / 2.0f)); _data[3].Points.Set(LineSegment(_points[6], _points[7], _points[0], _points[1])); } /* Rebuild content? */ if (Redraw()) { foreach (var item in _data) { item.Color.Set(_color); item.Rotation = _rotation; item.Position.Set(_position); item.Texture = (Texture) Resources.Load("Line.jpg"); } } return _data; }
/** Create the segment buffer */ private void CreateSegments(nGraphicsPipe pipe) { _sprites = new nSprite[_segmentCount]; for (int i = 0; i < _segmentCount; ++i) { var s = pipe.Sprite(); s.Depth = 28f; s.Texture = (Texture) Resources.Load("rainbow"); s.Color.Set(new float[4] { 1f, 1f, 1f, 1f }); s.UV.Set(new float[8] { 1, 1, 1, 0, 0, 0, 0, 1 }); _sprites[i] = s; } }
public nSprite[] Render(nGraphicsPipe pipe) { if (Invalid) return null; if (_sprites == null) { _sprites = new nSprite[1]; _sprites[0] = pipe.Sprite(); _sprites[0].Points.Set(new nGQuad(Size).Points); _sprites[0].Texture = (Texture) Resources.Load("Line"); _sprites[0].Position.Set(Position); _sprites[0].Color.Set(Color); _sprites[0].Depth = nRand.Float(4f, 1f); } return _sprites; }
public nSprite[] Render(nGraphicsPipe pipe) { if (Invalid) return null; if (_sprites == null) { _sprites = new nSprite[1]; _sprites[0] = pipe.Sprite(); _sprites[0].Points.Set(new nGQuad(Size[0], Size[1]).Points); _sprites[0].Texture = (Texture) Resources.Load("points500"); _sprites[0].Position.Set(Position); _sprites[0].Depth = nRand.Float(3f, 1f); _sprites[0].Color.Set(new float[4] { nRand.Float(0f, 1f, 0f), nRand.Float(0f, 1f, 0f), nRand.Float(0f, 1f, 0f), 1f }); } return _sprites; }
public nSprite[] Render(nGraphicsPipe pipe) { if (_sprites == null) { _sprites = new nSprite[1] { pipe.Sprite() }; } return _sprites; }