Game Development Community

t2dStaticSprite render issue

by Pedro Vicente · in iTorque 2D · 07/16/2011 (10:04 pm) · 5 replies

Build: 1.4.1

Platform: All

Issues: Rendering a t2dStaticSprite causes image distortion.

Not sure if this is just a wrong set of parameters in the image block definition; I have a 89x89 png image, that when loaded is modified.

Camera size is 768x1024 *and* resolution is 768x1024 (iPad portrait).

Sprite definition is

function WordySceneGraph::CreateDragTile( %this )
{
    %obj = new t2dStaticSprite() 
    { 
        scenegraph = %this; 
    };
    %obj.setVisible( true );
    %obj.setLayer( 18 );
    %obj.setImageMap( "Tile_01_Drag_ImageMap" );
    %obj.setSize( 89, 89 );
    return %obj;
}

t2dImageMapDatablock is

new t2dImageMapDatablock(Tile_01_Drag_ImageMap) {
      imageName = "data/images/tile_01_drag.png";
      imageMode = "FULL";
      frameCount = "-1";
      filterMode = "NONE";
      filterPad = "1";
      preferPerf = "1";
      cellRowOrder = "1";
      cellOffsetX = "0";
      cellOffsetY = "0";
      cellStrideX = "0";
      cellStrideY = "0";
      cellCountX = "-1";
      cellCountY = "-1";
      cellWidth = "0";
      cellHeight = "0";
      preload = "1";
      allowUnload = "0";
   };

This might be just that this set of parameters somehow changes the image;

The documentation (browse to t2dImageMapDatablock )

docs.garagegames.com/it2d/official/

lists the parameters, but does not explain their meaning. A couple of sentences explaining what do those variables mean, maybe it could be added at some point? Anyone has some pointers on those? Thanks.

Screenshots follow.

#1
07/16/2011 (10:11 pm)
I did this image in GIMP: a 768x1024 image where I pasted the image rendered by Torque (the green square)

www.space-research.org/games/garage_games/126955_1.png
#2
07/16/2011 (10:15 pm)
Now an iPad screenshot using the above code: there is a clearly visible distortion

www.space-research.org/games/garage_games/126955_2.png
#3
07/17/2011 (12:38 am)
oops... apparently user error.

Google is your friend (replace with your favorite search engine)... so I found this page as first hit

docs.garagegames.com/tgb/official/content/documentation/Reference/Image%20Maps.h...

Excellent reference for t2dImageMapDatablock.

So, in "FULL" mode all the other parameters are not actually needed (I copied that code from a "CELL" mode block; dangers of copy/paste)

I used

new t2dImageMapDatablock(Tile_01_Drag_ImageMap) 
{
      imageName = "data/images/tile_01_drag.png";
      imageMode = "FULL";
};

like this, I get this


www.space-research.org/games/garage_games/126955_3.png

Note 1: it seems that there is *still* a bit of image change.
Note 2: I cannot locate the above URL just by browsing the main doc page.
#4
07/17/2011 (7:37 am)
Glad you resolved the issue

Note 1 Response: This is likely due to either filter padding or the curve of the edge not being handled well

Note 2 Response: That doc exists in the iT2D documentation. I'm looking at it right now under Reference->Image Maps.
#5
07/17/2011 (11:39 am)
Note 2: indeed it is; my mistake, thanks Michael.