-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation graphics.drawTriangles(_vertex, _indexes, _uv); #119
Comments
Hello. Thank you for reporting this The beginBitmapFill method has been deprecated and will not be implemented again. The reasons are that adding a bitmap requires a new instance of a texture to be created, and applied, and that is wasteful. Use beginTextureFill instad. drawTriangles is part of the "It would be nice" set of features that we currently have not implemented. We will see if we find the time, at some point. |
👍 👍 Any progress on 'drawTriangles'? This would be an awesome feature. I am trying to port http://en.nicoptere.net/?p=476 into Starling, for animating bitmaps along a distorted path... great effect for game. Super awesome extension by the way! Keep it up! You Rock!!! |
I'm finding myself more and more swamped, unfortunately, and there is no time for me to be updating this project at this time. I'm sorry. However, as far as I can tell, the "drawTriangles" needed for that effect on that site can be replicated using the TriangleStrip class, I think? Create a TriangleStrip, addChild it to your Sprite (or whatever) and call "addVertex" for each vertex in the triangle list you get from the code in the nicoptere examples? |
Cool I will give that a try! Thanks for taking the time to look into it, much appreciate!
|
To transfer this into Starling: public function draw( graphics:Graphics, smooth:Boolean = false ):void
From his example, you create a Texture from the BitmapData, assign it to the TriangleStrip, and instead of drawTriangles, you do addVertex on the TriangleStrip for every vertex, index and UV pair in the lists. If I were to do something like this, that's the route I would go, at least. |
Cool it worked! You Rock! Mostly working at least, a bit of an issue with my implementation... My geometry skills are very lacking these days... getting misshapen result. public function draw():void
{
_triangleStrip.clear();
for(var i:int=0; i<vertices.length; i+=2){
_triangleStrip.addVertex(vertices[i], vertices[i+1], uvs[i], uvs[i+1]);
}
// graphics.drawTriangles( vertices, indices, uvs );
} Thanks again for your help! This feature is a life saver... cheers! |
Never mind, I got it working! Wasn't taking into account that the example from nicoptere was using quads, duh.
|
Very nice, glad you got that to work. One of the problems, from what I have understood about drawTriangles, is that it has a number of combined functionalities ( you can omit indices, etc) that might be hard to figure out. It might turn out to be easy, for sure, but It's one of those things that take a while to work out and get it to be compatible in a reasonable way with the "original" drawTriangles |
As you've noticed, the triangle strip primitive doesn't work the same way as Flash's 'drawTriangles' - You don't get to supply your own array of indices alongside the vertex data. The triangle strip shares some vertices for efficiency. Full details here http://en.wikipedia.org/wiki/Triangle_strip This may be 'a good thing' in your particular case, however it's not as flexible as supplying your own indices. |
Could you please add implementation for this :
graphics.clear();
graphics.beginBitmapFill(_image.bitmapData, null, false, true);
graphics.drawTriangles(_vertex, _indexes, _uv);
???
The text was updated successfully, but these errors were encountered: