entitypickmode problem

Blitz3D Forums/Blitz3D Programming/entitypickmode problem

Mr. Slat(Posted 2007) [#1]
I don't know why....but, why doesn't entitypickmode work with scaled sprites? I have to work with entityradius, but it's not the effect I want....

Is this a blitz bug?

how do I overcome this problem..

Best Wishes


b32(Posted 2007) [#2]
But does it work with unscaled sprites ? Because I think PickMode 2 doesn't work with sprites at all. Maybe that is because they aren't the same as meshes in terms of geometry/vertices/faces. For instance, Pivots are also not compatible with PickMode 2.
You could maybe create a square shape instead:

And optionally use "PointEntity sprite, camera" to aim this 'sprite' on the camera.


Mr. Slat(Posted 2007) [#3]
Yes, it works with unscaled sprites..... but with entitypickmode 1....
goshh I'll have to change everything?? and scale it all over again??
jezzz


b32(Posted 2007) [#4]
Wait a minute .. do you mean your problem is that you are using spherical picking mode on your sprites, which is what you need, but the picking radius doesn't change automatically when you are scaling the sprites ?
Then you could keep using sprites and simply write a function that scales the sprite and sets the radius at the same time.

Or did you mean that you need pickmode 2, but you can't get it to work with sprites ? That was what I understood, so that is why I suggested using a mesh instead. If so, how are you using the sprites ? You could then write functions that are more or less compatible with the original sprite functions and use Ctrl+R to replace them.


Mr. Slat(Posted 2007) [#5]
no,no... If I scale the sprite, the entitypickmode will work as if it wasn't scaled....
I use entityradius (wich is stupid) because it decreases the area of entitypick.. but obviously, it's a spherical pick area....
for now I only use text textures for these sprites...
so it only works with smal Texts, For instance "no" or "yes"... If use a sprite with the text "Load Game" the area will not cover all of the, X.
I've thought of using PickedX() or PickedY(), but it harder, to do it...


Mr. Slat(Posted 2007) [#6]
For instance:

Graphics3D 800, 600, 32, 2
Cam = CreateCamera()
PositionEntity Cam, 0,0,0

textu = CreateTexture(80, 15)
SetBuffer TextureBuffer(Textu)
Cls
Text 1,1, " no"
SetBuffer BackBuffer()
Spt = CreateSprite()
EntityTexture Spt, Textu
ScaleSprite spt, 0.5, 0.1
PositionEntity spt, 0,0, 2

EntityPickMode Spt, 1
EntityRadius spt, 0.13, 0.9

While Not KeyHit(1)
e=CameraPick(Cam, MouseX(),MouseY())
If e<>Entity
entity=e
Else
entity = 0
EndIf
RenderWorld()
Text 1,1, entity
Flip
Wend

ClearWorld()
EndGraphics()

(Test it, You'll see that it works.....but the area works as if it wasn't scaled... then try it with entityradius)


b32(Posted 2007) [#7]
Here, try this:

I've made a mesh-based version of the sprite commands.
To use them, copy everything from the line 'MESH-BASED SPRITE COMMANDS' into your program.

Two commands are different:
'UpdateSprites' should be called before RenderWorld, to enable the SpriteViewModes, and 'FreeSprite' should be used instead of FreeEntity.


Mr. Slat(Posted 2007) [#8]
yeh but how do I turn them faced to camera??? if you move them along, x, they face another direction!....


b32(Posted 2007) [#9]
Have you tried using 'updatesprites (camera)'? If the sprite view mode is set to one, they should be facing the camera.


Mr. Slat(Posted 2007) [#10]
lol... ofcourse.. nope... even your code does the same thing, for instance place your camera at 1,0,-2, and you'll see


b32(Posted 2007) [#11]
Yes, I see .. Hmm .. I replaced the PointEntity command in the UpdateSprites function, and inserted a pivot to parent the sprite, so that aligning it to the camera doesn't affect it's orientation:



Mr. Slat(Posted 2007) [#12]
it works perfectly now, thanks a lot for all your help^_^


b32(Posted 2007) [#13]
I saw there is another problem: now, there is no to access the sprite's pivot. So, now if you move the sprite sideways, it will still move relatively to the camera.

You could use EntityParent(sprite) to get a handle to the pivot. If you want to Rotate/Position/Turn/Move the 'sprites', it is better to use that entity instead:
MoveEntity GetParent(sprite), -0.01, 0, 0