Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: MZ About transforming pictures with multiple origins
- Original author: r66r
- Original date: April 27, 2024
- Source thread: https://forums.rpgmakerweb.com/threads/about-transforming-pictures-with-multiple-origins.168115/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support
Summary
I'm currently developing a plugin that allows me to manipulate pictures with different transformations (translation, mirroring, rotation, scaling, ...), according to origins based on the following 9 coordinate points: Code: X---X---X | | |
Archived First Post
I'm currently developing a plugin that allows me to manipulate pictures with different transformations (translation, mirroring, rotation, scaling, ...), according to origins based on the following 9 coordinate points:
All the transformations are working independently as expected. However, I have a problem with the origin management. For example, if I position a picture on X and Y coordinates based on the top left origin, and then try a rotation based on the bottom left origin, the origin point moves to the original X/Y coordinates and my image ends up rotated in the wrong place.
After a long analysis of the code (and a lot of headaches to understand how it works), I discovered that the Sprite_Picture object had only one possible anchor, via this function (original code from rmmz_sprites.js):
This means that each transformation can only be linked to one origin at a time. And as the picture sprite is updated with each game frame, if the origin changes, all the dimensions (X/Y position, X/Y scale, angle) are readjusted to this origin, causing the unwanted edge effect.
Please note that, apart from a function for resetting all transformations made on a picture, each transformation controlled by my plugin is independent of the others (contrary to the standard Move Picture function in RMMZ).
So in your opinion, is it possible to manage several origins per transformation (origin for positioning, origin for rotation, origin for scaling, etc.) with the Sprite_Picture object? Or is this a limitation of the PIXI.Sprite object (subsequently inherited by all RMMZ's Sprite_* objects)? And what solution could be envisaged to get around this problem (if any)?
Thank you in advance for any help or suggestions.
PS: For your information, the code currently under development for my plugin, if you want to test some ideas: raw code (gitlab).
Code:
X---X---X
| | |
X---X---X
| | |
X---X---X
All the transformations are working independently as expected. However, I have a problem with the origin management. For example, if I position a picture on X and Y coordinates based on the top left origin, and then try a rotation based on the bottom left origin, the origin point moves to the original X/Y coordinates and my image ends up rotated in the wrong place.
After a long analysis of the code (and a lot of headaches to understand how it works), I discovered that the Sprite_Picture object had only one possible anchor, via this function (original code from rmmz_sprites.js):
Code:
Sprite_Picture.prototype.updateOrigin = function() {
const picture = this.picture();
if (picture.origin() === 0) {
this.anchor.x = 0;
this.anchor.y = 0;
} else {
this.anchor.x = 0.5;
this.anchor.y = 0.5;
}
};
This means that each transformation can only be linked to one origin at a time. And as the picture sprite is updated with each game frame, if the origin changes, all the dimensions (X/Y position, X/Y scale, angle) are readjusted to this origin, causing the unwanted edge effect.
Code:
Sprite_Picture.prototype.update = function() {
Sprite_Clickable.prototype.update.call(this);
this.updateBitmap();
if (this.visible) {
this.updateOrigin();
this.updatePosition();
this.updateScale();
this.updateTone();
this.updateOther();
}
};
Please note that, apart from a function for resetting all transformations made on a picture, each transformation controlled by my plugin is independent of the others (contrary to the standard Move Picture function in RMMZ).
So in your opinion, is it possible to manage several origins per transformation (origin for positioning, origin for rotation, origin for scaling, etc.) with the Sprite_Picture object? Or is this a limitation of the PIXI.Sprite object (subsequently inherited by all RMMZ's Sprite_* objects)? And what solution could be envisaged to get around this problem (if any)?
Thank you in advance for any help or suggestions.
PS: For your information, the code currently under development for my plugin, if you want to test some ideas: raw code (gitlab).
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...