Updating from 278 to 279

52 views
Skip to first unread message

FatRedBird

unread,
May 13, 2016, 11:05:58 AM5/13/16
to Genome2D
Hello

Ive attempted updating our project from the Genome2d_1_0_278.swc to Genome2d_1_0_279.swc

This seems to have caused a few issues. Firstly
GTextureAtlas.addSubTexture requires different parameters,

originally:
 (name, regionRectangle, pivotX, pivotY)
now:
(name, regionRectangle, frameX,frameY,frameWidth,frameHeight);

We didn't have frame info available to quickly test with this new definition, but assuming it took the dimensions of a relatively positioned rectangle I put in some seemingly sensible values to quickly see if anything started getting rendered. I used, 0,0,100,100.
Now the project compiles, but it still doesn't seem to be rendering anything.

After sticking a break point into one of our rendering functions I can see that pivotX and Y are NaN, however setting them to sensible values didn't seem to help.
I can see that the GTextures width and height values seem to be set to infinity, I can't see how to change that so I guess we'll just have to use the frameWidth and frameHeight properties instead where neccessary.. but before I go about changing those properties I'm still stuck looking at a black screen, even with poorly defined framing our texturesheets are pretty choc full so I'd expect to see something.

Can you think of anything that might have drastically changed between the 2 versions?

Robin

sHTiF

unread,
May 14, 2016, 4:27:30 PM5/14/16
to Genome2D
Can you send a minimal example reproducing this issue? I took a look at the texture code and everything seems to be working. Also if you are interested in how frames relate to pivot check the github source for texture atlas generation where pivots are calculated.

FatRedBird

unread,
May 16, 2016, 8:11:20 AM5/16/16
to Genome2D
I've attached the files I used to make a minimal example but for the sake of other readers I'll paste the .as file contents at the end of this message.

In it's current version the file works with Genome2D_1_0_278.swc, it renders a large red square on a black background
 if you comment out 
            mTexture=mTextureAtlas.addSubTexture("subId",new Rectangle(0,0,512,512));
and uncomment
//mTexture=mTextureAtlas.addSubTexture("subId",new Rectangle(0,0,512,512),0,0,100,100);
It will compile with
Genome2D_1_0_279.swc
However, it only renders the black background. no red square.

.as file contents is as follows


package
{
    import com.genome2d.Genome2D;
    import com.genome2d.context.GContextConfig;
    import com.genome2d.context.stats.GStats;
   
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Rectangle;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;
   
    public class testRenderThing extends Sprite
    {
        private var core:Genome2D
        public function testRenderThing()
        {           
            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;           
            if(stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);                   
        }
       
        private function init(e:Event = null):void
        {
            core = Genome2D.getInstance();
            var config:GContextConfig = new GContextConfig(stage);
            GStats.visible = false;
           
            config.viewRect = new Rectangle(0,0,1024,768)
            core.onInitialized.addOnce(GInitialized);
            core.init(config)
        }
        private function GInitialized():void{    core.root.addComponent(mComp);    }
       
    }
   
}
import com.genome2d.Genome2D;
import com.genome2d.components.GCameraController;
import com.genome2d.components.GComponent;
import com.genome2d.components.renderables.IRenderable;
import com.genome2d.context.GContextCamera;
import com.genome2d.node.factory.GNodeFactory;
import com.genome2d.textures.GTexture;
import com.genome2d.textures.GTextureAtlas;
import com.genome2d.textures.GTextureSourceType;

import flash.display.BitmapData;
import flash.display3D.Context3DTextureFormat;
import flash.geom.Rectangle;

class mComp extends GComponent implements IRenderable
{
    var mTexture:GTexture
   
   
    override public function init():void
    {
        super.init();
        var mCamera:GComponent = GNodeFactory.createNodeWithComponent(GCameraController);
        node.addChild(mCamera.node);
        node.cameraGroup=(mCamera as GCameraController).contextCamera.mask;
        var bmpData:BitmapData=new BitmapData(512,512,false,0xff0000);   
       
        var mTextureAtlas:GTextureAtlas=new GTextureAtlas(       
            Genome2D.getInstance().getContext(),
            "textureAtlasName",
            GTextureSourceType.BITMAPDATA,
            bmpData,
            new Rectangle(0, 0, bmpData.width, bmpData.height),
            Context3DTextureFormat.BGRA,
            null
        );
       
        //mTexture=mTextureAtlas.addSubTexture("subId",new Rectangle(0,0,512,512),0,0,100,100);
            mTexture=mTextureAtlas.addSubTexture("subId",new Rectangle(0,0,512,512));
        mTextureAtlas.invalidateNativeTexture(true);
    }
    public function render (p_camera:GContextCamera, useMatrix:Boolean) : void
    {
        if(mTexture)    {    node.core.getContext().draw(mTexture, 0, 0);        }
    }
    private var _bounds:Rectangle = new Rectangle();
    public function getBounds(p_target:Rectangle=null):Rectangle{    return _bounds;    }       
testRenderThing-app.xml
testRenderThing.as

FatRedBird

unread,
May 16, 2016, 8:12:53 AM5/16/16
to Genome2D
Also, for consistency, here are the two genome swc files.
Genome2D_1_0_278.swc
Genome2D_1_0_279.swc

sHTiF

unread,
May 31, 2016, 5:37:20 AM5/31/16
to Genome2D
Hi, sorry to respond so late but unfortunately I wasn't able to reproduce this problem as its very old SWC files and some of the things completely changed now in 1.1 (no GTextureAtlas)

I would advise you to move to Genome2D 1.1.* versions or stay with the 278 for the moment.

If you have any issues moving to 1.1 please feel free to ask.
Reply all
Reply to author
Forward
0 new messages