CameraPick - question?
Blitz3D Forums/Blitz3D Beginners Area/CameraPick - question?
| ||
I'm doing some tests before I will start my first 3D project, but I had ran into a problem: I use scaled sprites (texture is 128 x 256 - so scaling is needed to show the right size) with viewmode 2 or 4. I need the entity to be picked by mouse, so I use CameraPick... The thing is, it seems to pick by the original sprite size, not the scaled one. Anyone has any ideas??? Maybe there is some other method to pick sprites in 3D? PS Just after I had posted this I came up with the idea of creating an invisible cube/sphere for each sprite. Well, it will take longer and I'm not sure if the command will pick the invisible entity... Any ideas on this one too? |
| ||
Mmm, maybe have a look at the EntityBox() command? I don't know if it will work with sprites though. |
| ||
Well, I figured out that I can change the collision sphere radius for a sprite and then I can pick it, but there's another problem: CameraPick returns number of the entity, not a handle... Do I just have to write them all down so I can use them later??? That doesn't seem to be right. |
| ||
Graphics3D 800,600 SetBuffer BackBuffer() cam=CreateCamera() MoveEntity cam,0,0,-5 sprite=CreateSprite() ScaleSprite sprite,2,1 EntityBox sprite,-2,-1,-1,4,2,2 EntityPickMode sprite,3 While Not KeyHit(1) Cls If MouseHit(1) Then hit=CameraPick(cam,MouseX(),MouseY()) EndIf UpdateWorld RenderWorld Text 10,10,"Sprite Handle: "+sprite Text 10,20,"Picked Entity's Handle: "+hit Flip Wend End |
| ||
Awesome! Thanks man! I think I just messed up with collision box's coordinates. It's so confusing in 3D (I'm not sure if I will be able to do it by myself ;-) )... |
| ||
Oops, there was a little bug, this is the updated code:Graphics3D 800,600 SetBuffer BackBuffer() cam=CreateCamera() MoveEntity cam,0,0,-5 sprite=CreateSprite() ScaleSprite sprite,2,1 ;updated the Z values for the EntityBox command, the original EntityBox values created a box rather than a flat "plane" EntityBox sprite,-2,-1,0,4,2,0 EntityPickMode sprite,3 While Not KeyHit(1) Cls If MouseHit(1) Then hit=CameraPick(cam,MouseX(),MouseY()) EndIf UpdateWorld RenderWorld Text 10,10,"Sprite Handle: "+sprite Text 10,20,"Picked Entity's Handle: "+hit Flip Wend End |