Skip to content

Commit

Permalink
ADDED Possibility to get regpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
potmo committed Apr 16, 2012
1 parent 5d09839 commit c80546d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/com/potmo/p2d/atlas/P2DTextureAtlas.as
Expand Up @@ -320,6 +320,12 @@ package com.potmo.p2d.atlas
}


public function getRegpoints():Vector.<Point>
{
return _regpoints.concat(); //clone
}


public function getVertexBuffer():VertexBuffer3D
{
return _vertexBuffer;
Expand Down
9 changes: 5 additions & 4 deletions src/com/potmo/p2d/atlas/animation/P2DSpriteAtlas.as
Expand Up @@ -9,13 +9,13 @@ package com.potmo.p2d.atlas.animation
private var _sequenceCount:uint;


public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> )
public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regPoints:Vector.<Point> )
{

_sequences = new Vector.<P2DSpriteAtlasSequence>();
_sequenceCount = 0;

createSequences( sequenceFrames, names, labels, frameSizes );
createSequences( sequenceFrames, names, labels, frameSizes, regPoints );

}

Expand Down Expand Up @@ -54,7 +54,7 @@ package com.potmo.p2d.atlas.animation
}


private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> ):void
private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regpoints:Vector.<Point> ):void
{
var length:int = names.length;

Expand All @@ -64,6 +64,7 @@ package com.potmo.p2d.atlas.animation
var sequenceName:String = names[ i ];
var sequenceFrame:int = sequenceFrames[ i ]
var label:String = labels[ i ];
var regpoint:Point = regpoints[ i ];

var sequence:P2DSpriteAtlasSequence = getP2DSequenceByName( sequenceName );

Expand All @@ -73,7 +74,7 @@ package com.potmo.p2d.atlas.animation
}
var frameSize:Point = frameSizes[ i ];

sequence.addFrame( sequenceFrame, i, label, frameSize );
sequence.addFrame( sequenceFrame, i, label, frameSize, regpoint );

}
}
Expand Down
22 changes: 17 additions & 5 deletions src/com/potmo/p2d/atlas/animation/P2DSpriteAtlasSequence.as
Expand Up @@ -16,15 +16,17 @@ package com.potmo.p2d.atlas.animation
private var _labels:Vector.<String>;
private var _atlasFrames:Vector.<uint>;
private var _sequenceOffsetInAtlas:uint;
private var _frameSize:Vector.<Point>;
private var _frameSizes:Vector.<Point>;
private var _regPoints:Vector.<Point>;


public function P2DSpriteAtlasSequence( name:String )
{
_name = name;
_labels = new Vector.<String>();
_atlasFrames = new Vector.<uint>();
_frameSize = new Vector.<Point>();
_frameSizes = new Vector.<Point>();
_regPoints = new Vector.<Point>();
_sequenceFrameCount = 0;
}

Expand Down Expand Up @@ -91,18 +93,21 @@ package com.potmo.p2d.atlas.animation
}


public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point ):void
public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point, regPoint:Point ):void
{
while ( sequenceFrame >= _sequenceFrameCount )
{
_labels.push( null );
_atlasFrames.push( -1 );
_frameSizes.push( null );
_regPoints.push( null );
_sequenceFrameCount++;
}

_labels[ sequenceFrame ] = label;
_atlasFrames[ sequenceFrame ] = atlasFrame;
_frameSize[ sequenceFrame ] = frameSize;
_frameSizes[ sequenceFrame ] = frameSize;
_regPoints[ sequenceFrame ] = regPoint;

}

Expand Down Expand Up @@ -164,7 +169,14 @@ package com.potmo.p2d.atlas.animation
public function getSizeOfFrame( atlasFrame:uint ):Point
{
var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
return _frameSize[ sequenceFrame ];
return _frameSizes[ sequenceFrame ];
}


public function getRegpointOfFrame( atlasFrame:uint ):Point
{
var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
return _regPoints[ sequenceFrame ];
}

}
Expand Down
1 change: 1 addition & 0 deletions src/com/potmo/p2d/atlas/animation/SpriteAtlasSequence.as
Expand Up @@ -10,5 +10,6 @@ package com.potmo.p2d.atlas.animation
function getName():String;
function getNextFrame( currentFrame:uint, loop:Boolean, followLabelPointers:Boolean ):uint;
function getSizeOfFrame( atlasFrame:uint ):Point;
function getRegpointOfFrame( atlasFrame:uint ):Point;
}
}
2 changes: 1 addition & 1 deletion src/com/potmo/p2d/renderer/P2DRenderer.as
Expand Up @@ -124,7 +124,7 @@ package com.potmo.p2d.renderer
_transformVector[ 0 ] = redMultiplyer;
_transformVector[ 1 ] = greenMultiplyer;
_transformVector[ 2 ] = blueMultiplyer;
_transformVector[ 3 ] = greenMultiplyer;
_transformVector[ 3 ] = alphaMultiplyer;

_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 0, _transformVector, 1 ); // this is the colortransform but we dont care about it now
_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 1, _matrixVector, 3 );
Expand Down

0 comments on commit c80546d

Please sign in to comment.