### Author Topic: X_SPRITE scaling  (Read 1637 times)

#### Qedo

• Dr. Type
• Posts: 382
• to program what I have do how should programming?
##### X_SPRITE scaling
« on: 2020-Mar-25 »
I'm not sure but I suspect that the scaling parameter of X_SPRITE is incorrect.
I try to explain in the simplest way possible what I did to verify
I created a yellow sprite of size 640x480 with horizontal and vertical black lines spaced 100 pixels between them.
I placed this natural size X_SPRITE (scaling = 1) at the origin of the scene x = 0 z = 0 with downward movement to y = -240 (half its height)
I would have expected the positioning of the center of the sprite to correspond with the center of the axes but instead the result is as shown in figure 1
To obtain the positioning of the sprite centered on the axes I must instead move it down -120 as in figure 2
To justify the results obtained, the only logic that comes to mind is that the X_SPRITE is drawn not with scaling = 1 but instead with scaling = 0.5. that is, half of its size
This is my theory. I don't know if anything escapes me and I'm asking for your opinion  and your experience.
I didn't create this thread in BUG  just because I'm not sure it is
Thank you
Ciao

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10851
• here on my island the sea says 'hello'
##### Re: X_SPRITE scaling
« Reply #1 on: 2020-Mar-26 »
IIRC - it's quite some time - the top coordinate for X_SPRITE is the top center of the sprite. Sort of - like the 2D SPRITE commands, but X centered.

#### Qedo

• Dr. Type
• Posts: 382
• to program what I have do how should programming?
##### Re: X_SPRITE scaling
« Reply #2 on: 2020-Mar-26 »
I'm confused. the manual says about X_SPRITE:

"Draws a 2D sprite at a 3D position. This technique is also known as Billboarding. The hot spot of the sprite (the part which will be drawn at the give location) is the sprite's bottom center."

also if it were how you write:

"the top coordinate for X_SPRITE is the top center of the sprite. Sort of - like the 2D SPRITE commands, but X centered."

the behavior of the program would be completely inexplicable.
Have you tried the example attached?

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10851
• here on my island the sea says 'hello'
##### Re: X_SPRITE scaling
« Reply #3 on: 2020-Apr-14 »
Bottom center it is. Try x_drawaxis at the xyz of the sprite and use a texture thats power of 2 in size, if you think theres a bug....

#### Qedo

• Dr. Type
• Posts: 382
• to program what I have do how should programming?
##### Re: X_SPRITE scaling
« Reply #4 on: 2020-Apr-14 »
tried with 512x256 same result.
The shift is consistent with 1/2 scaling instead of 1 as it should be.

#### Steinbock

• Mr. Drawsprite
• Posts: 66
##### Re: X_SPRITE scaling
« Reply #5 on: 2020-Apr-23 »
Hi Quedo

As i am working on this project https://www.glbasic.com/forum/index.php?topic=11154.0 with X_SPRITE it seems at least here no issue
Time will come. It's just a matter of time...

#### Qedo

• Dr. Type
• Posts: 382
• to program what I have do how should programming?
##### Re: X_SPRITE scaling
« Reply #6 on: 2020-Apr-24 »
Steinbock thanks for checking.
X_SPRITE works well except for the scaling parameter (in my opinion). Did you get to check it?
Ciao

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10851
• here on my island the sea says 'hello'
##### Re: X_SPRITE scaling
« Reply #7 on: 2020-Apr-25 »
To me it seems to be working as exprected:
Code: (glbasic) [Select]
`SETCURRENTDIR("Media") // go to media filesLOADSPRITE "rect640x480.bmp", 0SYSTEMPOINTER TRUEGETSCREENSIZE sx%,sy%CLEARSCREEN RGB(255,255,255)LOCAL mx, my, b1, b2WHILE TRUE MOUSESTATE mx, my, b1, b2 X_MAKE3D 1,1500,80 X_DRAWAXES 0,0,0 X_CAMERA 111,111,111, 0, 0, 0 X_DRAWAXES 0,0,0 LOCAL x = -3 LOCAL y = 7 LOCAL z = (-320 + mx) / 4.0 LOCAL scale = (480-my) / 640 + 0.25 X_DRAWAXES x,y,z X_SPRITE 0, x,y,z, scale SHOWSCREENWEND`

#### Qedo

• Dr. Type
• Posts: 382
• to program what I have do how should programming?
##### Re: X_SPRITE scaling
« Reply #8 on: 2020-Apr-25 »
I tried it, but in your example you move X_SPRITE on the Z axis with the movement of the mouse "mx" and the scale of X_SPRITE with the mouse "my" and it is therefore difficult if not impossible to verify if scaling is correct. Instead in my example I blocked X_SPRITE and the room that are relieved and I only made the movement on the Y axis of X_SPRITE. Have you tried it?
For the rest X_SPRITE works fine but in any case in my program I am using XSPRITE routine as an alternative
Thanks