Sprites doubling in size for no apparent reason

Blitz3D Forums/Blitz3D Programming/Sprites doubling in size for no apparent reason

Viperfish(Posted 2005) [#1]
Hi all,

I'm hoping someone may have experienced this and can shed some light on this problem for me.

I have several different camera angles in my current project and they all work great. Except one. When I switch to enemy cam some of the sprites in the scene increase dramatically in size when viewed through this camera. Others do not.

See the following screen shot and notice the size of the sun and sun spots. This is the Cockpitcam...


Now a similar angle through the Enemycam...


Notice that the sun which is a single sprite has increased in size by atleast double while the sun spots are unchanged.

Also, the following 2 screen shots are the same ship. The first viewed from the cockpitcam and the second from the enemycam...


Notice the exhaust flares have increased in size.

The sprite scale of the affected sprites are set only when they are loaded. They are not changed anywhere in the main loop code. The camera zoom is the same for all cameras. The only consistent thing I can see is that the affected sprites are parented to something else. Free sprites seem not to change but I can't see how that can cause this problem.

Has anyone had this happen before? Any ideas?

Regards
John


BlitzSupport(Posted 2005) [#2]
Are the parents of the affected sprites scaled at all during execution?


Viperfish(Posted 2005) [#3]
No. They are both moved each round, though. The sun is parented to the sky which moves with the camera. It's pitch, roll and yaw are all corrected each frame to keep it in position. The exhaust flares are parented to the enemies which are updated each round.


Viperfish(Posted 2005) [#4]
I found this problem is caused by parenting the camera to a previously scaled mesh!! Is this a bug?

The enemy meshes are loaded at startup and then scaled x3. When enemycam is selected *most* sprites automatically increase in size by the same amount. Wierd!

I've replicated the problem in the following code. Try it. It doesn't make any sense to me why sprites would increase in size by the scale of the camera's parent.




gosse(Posted 2005) [#5]
woah, weird, definately a bug


BlitzSupport(Posted 2005) [#6]
(Hope this makes sense -- clinically brain dead right now, so it might all be misinterpreted gibberish...)

I'd say that when the new camera is created as a child of parentent1 it has the 'normal' scale, but when created as a child of parentent2, which is scaled to 3, 3, 3, it's adopting that scaling, which is correct behaviour -- it's using the scale of its local space, which for any entity is defined by its parent. I think the sprite is affected differently because they use a different scaling system (ie. ScaleSprite) tied to the current camera.

I noticed that in the "Select whichcamera" part you are freeing the camera, then creating a new camera with no handle, then calling PositionEntity on the freed camera handle -- this looks like a Blitz bug since it's not pointing to any camera, or not supposed to be! Same thing when it comes back round to freeing the camera again... PositionEntity at least should crash/give debug error!

Anyway, if you just re-parent the existing camera, there's no scaling of the sprite:

Graphics3D 640,480,16,0

;load a sprite. I tested this with a sprite 128 x 128.
sprt = LoadSprite("sprite1.jpg")
PositionEntity sprt,-8,0,10

;Creat a mesh
mesh = CreateSphere()
PositionEntity mesh,8,0,10

;create 2 meshes, side by side, to act as parents. Within a game these could be spaceships, characters,
;vehicles etc.
parentent1 = CreateCube()
parentent2 = CreateCube()
PositionEntity parentent1,5,0,-50
PositionEntity parentent2,-5,0,-50

;Scale one of the parent entities.
ScaleEntity parentent2,3,3,3

;create a camera.
camera = CreateCamera(parentent1)
PositionEntity camera,0,0,0
PointEntity camera,sprt

While Not KeyDown(1)
	;Hit the space bar to change cameras. Notice how the sprite changes in size!!
	;The mesh does not.
	If KeyHit(57)
		whichcamera% = -1-whichcamera%
		;FreeEntity camera
		Select whichcamera%
			Case 0 
				EntityParent(camera, parentent1)
			Case -1
				EntityParent(camera, parentent2)
		End Select
		PositionEntity camera,0,0,0
		PointEntity camera,sprt
	End If
	RenderWorld
	Text 320,10,"Press SPACE to change cameras.",True,True
	Flip
Wend
End


Not sure if this covers what you're trying to do, or why it's different for a new camera as opposed to using the same one -- might also be something to do with new cameras having scale reset?