log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- RISCOSbits releases a new laptop solution (News:)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
- RISC OS London Show Report 2024 (News:1)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Rotated & scaled sprite plotting
 
  Rotated & scaled sprite plotting
  MrTAToad (01:35 11/2/2013)
 
Nicholas Kingsley Message #121893, posted by MrTAToad at 01:35, 11/2/2013
Member
Posts: 36
I've got SpriteOp 56 displaying rotated and scaled sprites now.

However, the origin of the plotting is at the bottom left, whilst I want it to be the middle (ie subtract half the width and height off the X & Y position of the sprite).

My translation code is currently (with sinp and cosp being the radian of an angle) :

scaleMatrix[0]=(int) ((endScale*cosp)*65536.0);
scaleMatrix[1]=(int) ((endScale*sinp)*65536.0);
scaleMatrix[2]=(int) ((endScale*-sinp)*65536.0);
scaleMatrix[3]=(int) ((endScale*cosp)*65536.0);
scaleMatrix[4]=nx*256;
scaleMatrix[5]=ny*256;

sourceCoords[0]=animXPos;
sourceCoords[1]=animXPos;
sourceCoords[2]=useWidth;
sourceCoords[3]=useHeight;

inreg.r[0]=56+512;
inreg.r[1]=(int) spriteInfo->spriteBlockInfo->spriteArea;
inreg.r[2]=(int) spriteInfo->spritePtr;
inreg.r[3]=1<<1;
inreg.r[4]=(int) &sourceCoords;
inreg.r[5]=0+8;
inreg.r[6]=(int) &scaleMatrix;
inreg.r[7]=-1;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);


Would the scaling matrix need to take into account half the width/height of the sprite or are the coordinate values incorrect ? I presume to convert from Draw units to OS units would be multiplication by 256...

nx and ny have been converted to OS units beforehand

[Edited by MrTAToad at 01:36, 11/2/2013]
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Rotated & scaled sprite plotting