Strange sprite behavour?

Blitz3D Forums/Blitz3D Programming/Strange sprite behavour?

Ross C(Posted 2010) [#1]
Is this a normal way for sprites to work? Upon creating a sprite, the sprite is 1x1. That's fine :)

Now, if i texture this sprite with a 1024 by 768 texture, the sprite scales it proportional to that texture...

Now, that's also fair enough... But it alters the scale of the sprite. Now when i try to scale the sprite, to the dimensions i want, i have to take into account the dimensions of the sprite. Scaling the sprite 1x1 results in the sprite have the real scale of 1.333333 : 1.

Is this a bug? It's really unhelpful...


Ross C(Posted 2010) [#2]
This code somewhat demonstrates is. Thing is, it doesn't even scale the sprite from the middle, is redimensions the sprite from the top left corner!

The sprite shown on the screen is a sprite generated via the createsprite() command, with a 1024x768 texture. Pressing the 2 key, changes the sprites texture to a 800x800 texture. Each time, the sprite automatically rescales itself...

Graphics3D 800,600
SetBuffer BackBuffer()


Global camera = CreateCamera()

Global s = CreateSprite()

PositionEntity s,0,0,10


t = CreateTexture(1024,768)
SetBuffer TextureBuffer(t)
Color 255,0,255
Rect 0,0,1024,768
SetBuffer BackBuffer()

EntityTexture s,t

ScaleSprite s,1.33333,1


t1 = CreateTexture(800,800)
SetBuffer TextureBuffer(t1)
Color 255,0,0
Rect 0,0,800,800
SetBuffer BackBuffer()


While Not KeyHit(1)


	If KeyHit(2) Then EntityTexture s,t1

	RenderWorld
	Flip
Wend



Jiffy(Posted 2010) [#3]
Don't use sprites.
Sprites and terrainmesh are Fail for speed.
Find a quad library.

A quick look got this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=917
Never used it, but handles spritelike functions.


Ross C(Posted 2010) [#4]
Yeah, i always use quads, (have my own single surface particle system) but sometimes, if it's just one, i'll use a sprite. Besides, i would still like to know if this is a bug, or a design feature. If it's a design feature, then it really does suck...


puki(Posted 2010) [#5]
Just in relation to the speed issue. I think Blitz3D is no longer optimised for sprites anyway. Previous versions of Blitz3D have incredible speed differences with them compared to latter versions. Not sure if "Sibly" did it intentionally to improve something else, or if it is a bug in the way that Blitz3D handles them.


Vorderman(Posted 2010) [#6]
Yes, sprites in the newer B3D builds are horrendously slow - in 1.64 they are pretty fast, but in the latest 1.1? even 4 sprites is enough to ruin my game's framerate.

I can't believe that Blitz was deliberately ruined as I have noticed no speed improvements of anywhere near the same magnitude to compensate for sprites becoming so slow.


Ross C(Posted 2010) [#7]
Anyone had any issues with the scaling thing i mentioned?


Stevie G(Posted 2010) [#8]
@ Ross,

There's nothing strange about it. Since when was a 1024 * 768 texture normal? Surely this relates to the textures being automatically scaled to the nearest ^2?

If you're trying to do this auto antialias thing then you really need to use a quad so that you have more control over the UV's.

Stevie


Ross C(Posted 2010) [#9]
I have used in a quad in the code i posted in the other thread about anitaliasing [EDIT]. And i know. mental block perhaps? Even after typing the bloomin thing up there, it hits me blitz is scaling my textures up to the nearest power of 2...

Still, i still don't think applying a texture to a sprite should change the scaling of a sprite, whilst keeping it scale at 1 x 1, but being rectangle. It's a tad confusing, and annoying to track down the error.


Jiffy(Posted 2010) [#10]
It appears texturing a sprite 'forces' it square by padding.
(maybe clipping & masking- but keeping the same aspect ratio.) The scale applies to the 1x1 'original' sprite, not any aspect of the texture size.




Ross C(Posted 2010) [#11]
Ah, thanks for that. Nice to know how it's working :)