Misalignment caused by rotation

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Misalignment caused by rotation

Post by Erato »

Leanden wrote:
Erato wrote:

Code: Select all

template TEMP_CAR_5_NEW(y,h,d) {
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
This is your issue right here, you are defining the same offsets in both directions. Try something like this:

Code: Select all

template TEMP_CAR_5_NEW(y,h,d) {
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
And adjust the offsets in the second set for when its going in reverse.

Also why are you using the h + d modifiers?? If you are consistently using the same templates you should be able to just put absolute values in here.
I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...

As for the extra parametres, my trains don't all have the same height, and I don't want to have a billion templates. The d stands for depth; it makes the train sink deeper in the track.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Misalignment caused by rotation

Post by Leanden »

Erato wrote:
Leanden wrote:
Erato wrote:

Code: Select all

template TEMP_CAR_5_NEW(y,h,d) {
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
This is your issue right here, you are defining the same offsets in both directions. Try something like this:

Code: Select all

template TEMP_CAR_5_NEW(y,h,d) {
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
	[0, y, 8, 16+h+d, -3, -11-h]
	[9, y, 16, 14+h+d, -14, -4-h]
	[26, y, 20, 12+h+d, -10, -6-h]
	[47, y, 16, 14+h+d, -2, -4-h]
And adjust the offsets in the second set for when its going in reverse.

Also why are you using the h + d modifiers?? If you are consistently using the same templates you should be able to just put absolute values in here.
I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...

As for the extra parametres, my trains don't all have the same height, and I don't want to have a billion templates. The d stands for depth; it makes the train sink deeper in the track.
Where are you defining h and d in your code?

Can you show me an example of dual headed and asymmetrical engine spritesheets and the accompanying code?
Image
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Misalignment caused by rotation

Post by Transportman »

Erato wrote:I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...
Dualheaded engines are also a bit different, if the sprite order for the front is 1 2 3 4 5 6 7 8, the order for the back is 5 6 7 8 1 2 3 4. So you need to take that into account.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Misalignment caused by rotation

Post by Leanden »

Transportman wrote:
Erato wrote:I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...
Dualheaded engines are also a bit different, if the sprite order for the front is 1 2 3 4 5 6 7 8, the order for the back is 5 6 7 8 1 2 3 4. So you need to take that into account.
That shouldnt matter as if the sprites are all correctly aligned, it will flip into the same position.
Image
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Misalignment caused by rotation

Post by Erato »

Leanden wrote:
Transportman wrote:
Erato wrote:I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...
Dualheaded engines are also a bit different, if the sprite order for the front is 1 2 3 4 5 6 7 8, the order for the back is 5 6 7 8 1 2 3 4. So you need to take that into account.
That shouldnt matter as if the sprites are all correctly aligned, it will flip into the same position.
But they are all correctly aligned in one direction.
Leanden wrote:
Erato wrote: I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...

As for the extra parametres, my trains don't all have the same height, and I don't want to have a billion templates. The d stands for depth; it makes the train sink deeper in the track.
Where are you defining h and d in your code?

Can you show me an example of dual headed and asymmetrical engine spritesheets and the accompanying code?
When I call the template:

Image

Code: Select all

spriteset (SPRITESET_BIRMAG, "grf/BIRMAG.png") {
	TEMP_TRAIN_DOUBLE_5(1,0)
}
Image

Code: Select all

spriteset (SPRITESET_MLX01901, "grf/MLX01901.png") {
	TEMP_TRAIN_DOUBLE_8(0,0)
}

Code: Select all

template TEMP_TRAIN_DOUBLE_8(h,d) {
	[0, 0, 8, 22+h+d, -3, -14-h]
	[9, 0, 22, 17+h+d, -14, -7-h]
	[32, 0, 32, 12+h+d, -15, -6-h]
	[65, 0, 22, 17+h+d, -8, -7-h]
	[88, 0, 8, 22+h+d, -3, -14-h]
	[97, 0, 22, 17+h+d, -14, -7-h]
	[120, 0, 32, 12+h+d, -15, -6-h]
	[153, 0, 22, 17+h+d, -8, -7-h]
}

template TEMP_TRAIN_DOUBLE_5(h,d) {
	[0, 0, 8, 16+h+d, -3, -11-h]
	[9, 0, 16, 14+h+d, -14, -4-h]
	[26, 0, 20, 12+h+d, -10, -6-h]
	[47, 0, 16, 14+h+d, -2, -4-h]
	[64, 0, 8, 16+h+d, -3, -11-h]
	[73, 0, 16, 14+h+d, -14, -4-h]
	[90, 0, 20, 12+h+d, -10, -6-h]
	[111, 0, 16, 14+h+d, -2, -4-h]
}
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Misalignment caused by rotation

Post by Erato »

Transportman wrote:
Erato wrote:I tried, and it worked... For the carriages and the single-headed, symmetrical engines... But the dual headed, asymmetrical engines (which make up the majority of engines) still aren't fixed...
Dualheaded engines are also a bit different, if the sprite order for the front is 1 2 3 4 5 6 7 8, the order for the back is 5 6 7 8 1 2 3 4. So you need to take that into account.
This means that if I fix one orientation, I screw the rest up.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Misalignment caused by rotation

Post by Leanden »

Im back at work tomorrow, but if i get a chance ill compile that and see if i can work out a fix or where the error is occuring.

What might be better is if you can inbox me the full repository of your code and gfx?
Image
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Misalignment caused by rotation

Post by Erato »

I managed to fix it, and I think this is the thing you guys have tried to tell me all this time, but I use a new Spritegroup for the front and the back engine now. It works! I found this out after making a train with a different paint job on the front and on the back. I first had to figure out how to do that, and then I realised that I could fix stuff this way. So it's fixed now.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 21 guests