Closed filharvey closed 9 years ago
Crap. I will see if I can find some time to improve on this...
Was an easy fix.
On Sun, Nov 16, 2014 at 6:26 AM, IonSwitz notifications@github.com wrote:
Crap. I will see if I can find some time to improve on this...
— Reply to this email directly or view it on GitHub https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/125#issuecomment-63220649 .
Phil Harvey filharvey@gmail.com
Ok, good. is it something that can be easily fixed and added to the extension?
Use this version of stroke.as.
Has vertices. and works very nicely.
On Sun, Nov 16, 2014 at 7:19 AM, IonSwitz notifications@github.com wrote:
Ok, good. is it something that can be easily fixed and added to the extension?
— Reply to this email directly or view it on GitHub https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/125#issuecomment-63222596 .
Phil Harvey filharvey@gmail.com
Sorry, I'm not sure if it is me or GitHub, but I dont see any code at all...?
In stroke.as
line 409
if ( i < numVertices - 1 ) { var i2:int = (i << 1); indices[indiciesCounter++] = i2; indices[indiciesCounter++] = i2+1; indices[indiciesCounter++] = i2+2; indices[indiciesCounter++] = i2+3; indices[indiciesCounter++] = i2+2; indices[indiciesCounter++] = i2+1; }
line 529
outputIndices.push(i2, i2 + 1, i2 + 2, i2 + 3, i2 + 2, i2 + 1);
That seems to fix it, it is just a re-ordering of indicies.
On Sun, Nov 16, 2014 at 7:44 AM, IonSwitz notifications@github.com wrote:
Sorry, I'm not sure if it is me or GitHub, but I dont see any code at all...?
— Reply to this email directly or view it on GitHub https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/125#issuecomment-63223760 .
Phil Harvey filharvey@gmail.com
I am running some scenarios here to repeat the bug, but I can't get the initial bug to appear.
I create a Sprite3D, I draw a shape and I rotate the Sprite3D to see the backside of the Sprite3D and the shape. Regardless if I run with the old or with your code, the shape appears. Does Starling have a backface-cull setting somewhere that I have completely missed?
you did at one stage have to add
public override function render(support:RenderSupport, parentAlpha:Number):void { // Starling does not make any depth-tests, so we use a trick in order to only show // the front quads: we're activating backface culling, i.e. we hide triangles at which // we look from behind. Starling.current.context.setCulling(Context3DTriangleFace.BACK); super.render(support, parentAlpha); Starling.current.context.setCulling(Context3DTriangleFace.NONE); }
so yes culling is enabled as if you rotate an object it should only be forward facing in 3d.
Phil
On Sun, Nov 16, 2014 at 8:16 AM, IonSwitz notifications@github.com wrote:
I am running some scenarios here to repeat the bug, but I can't get the initial bug to appear.
I create a Sprite3D, I draw a shape and I rotate the Sprite3D. Regardless if I run with the old or with your code, the shape appears. Does Starling have a backface-cull setting somewhere that I have completely missed?
— Reply to this email directly or view it on GitHub https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/125#issuecomment-63225297 .
Phil Harvey filharvey@gmail.com
Great! Now I can reproduce it. The Stroke works correctly with your fix, now I need to sort out the Fill as well :)
EDIT:Seems the fills work correctly already. Excellent. Checking in the fix now.
This appears to be fully fixed now. For reference, this is my test harness, adding a Quad and a Shape to a Sprite3D and rotating it:
package
{
import starling.events.Event;
import starling.events.EnterFrameEvent;
import starling.display.Sprite3D;
import flash.display3D.Context3DTriangleFace;
import starling.display.Quad;
import starling.display.Shape;
import starling.core.RenderSupport;
import starling.core.Starling;
public class Sprite3DTest extends Sprite3D
{
public function Sprite3DTest()
{
super();
addEventListener(Event.ADDED_TO_STAGE, onAdded);
}
public override function render(support:RenderSupport, parentAlpha:Number):void
{
Starling.current.context.setCulling(Context3DTriangleFace.BACK);
super.render(support, parentAlpha);
Starling.current.context.setCulling(Context3DTriangleFace.NONE);
}
protected function enterFrameHandler(e:EnterFrameEvent) : void
{
this.rotationY += 0.02;
}
protected function onAdded ( e:Event ):void
{
addEventListener(EnterFrameEvent.ENTER_FRAME, enterFrameHandler);
var quad:Quad = new Quad(300, 30, 0);
quad.alpha = 0.75;
quad.y = 0;
quad.x = stage.stageWidth - 300;
addChild(quad);
var shape:Shape = new Shape();
addChild(shape);
shape.x = 800;
shape.graphics.beginFill(0xFF02F1);
shape.graphics.lineStyle(4, 0, 1);
shape.graphics.moveTo(99, 99);
shape.graphics.lineTo(100, 100);
shape.graphics.lineTo(300, 100);
shape.graphics.lineTo(300, 300);
shape.graphics.lineTo(100, 300);
shape.graphics.lineTo(100, 100);
shape.graphics.endFill();
this.alignPivot();
this.x += 500;
this.y += 500;
}
}
}
Thanks
On Sun, Nov 16, 2014 at 8:59 AM, IonSwitz notifications@github.com wrote:
This appears to be fully fixed now. For reference, this is my test harness, adding a Quad and a Shape to a Sprite3D and rotating it:
package
{ import starling.events.Event; import starling.events.EnterFrameEvent; import starling.display.Sprite3D; import flash.display3D.Context3DTriangleFace; import starling.display.Quad; import starling.display.Shape;
import starling.core.RenderSupport; import starling.core.Starling;
public class Sprite3DTest extends Sprite3D {
public function Sprite3DTest() { super(); addEventListener(Event.ADDED_TO_STAGE, onAdded); } public override function render(support:RenderSupport, parentAlpha:Number):void { Starling.current.context.setCulling(Context3DTriangleFace.BACK); super.render(support, parentAlpha); Starling.current.context.setCulling(Context3DTriangleFace.NONE); } protected function enterFrameHandler(e:EnterFrameEvent) : void { this.rotationY += 0.02; } protected function onAdded ( e:Event ):void { addEventListener(EnterFrameEvent.ENTER_FRAME, enterFrameHandler); var quad:Quad = new Quad(300, 30, 0); quad.alpha = 0.75; quad.y = 0; quad.x = stage.stageWidth - 300; addChild(quad); var shape:Shape = new Shape(); addChild(shape); shape.x = 800; shape.graphics.beginFill(0xFF02F1); shape.graphics.lineStyle(4, 0, 1); shape.graphics.moveTo(99, 99); shape.graphics.lineTo(100, 100); shape.graphics.lineTo(300, 100); shape.graphics.lineTo(300, 300); shape.graphics.lineTo(100, 300); shape.graphics.lineTo(100, 100); shape.graphics.endFill(); this.alignPivot(); this.x += 500; this.y += 500; }
}
}
— Reply to this email directly or view it on GitHub https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/125#issuecomment-63227311 .
Phil Harvey filharvey@gmail.com
For lines the index order is wrong and the line (stoke) fills do not show as they are back facing.