Running mouse over an entity show its entity name
Blitz3D Forums/Blitz3D Beginners Area/Running mouse over an entity show its entity name
| ||
Hi - I have 2 queries:- (1) What I want to do is make an entity pickable, so that if, say, I MouseDown(1) to select it, then MouseDown(3) to drag it to a new location and then release the button to leave the object there. Or, even, to give an entity's name when just running the mouse over it (displaying the entity name in, say, white text above the object would be cool!). I have searched various forums and can do this when I know the entity's name, but can't do it by purely running the mouse over the 3d object or clicking to select the object. My aim is to have a load of differently named 3d entities that I can choose to move somewhere new as and when, purely by running the mouse over them and using MouseDown commands to select and move/drop. (2) How do I select multiple objects using something which achieves the above (as per a Rise of Nations type select). I know there are smart people out there - to help bale out those who are more "creative"! Help! Cheers! |
| ||
Paulus, Check out the samples folder in your installation - it has examples of the (1) aspect you asked for. The multiple selection is a lot more complex than it appears, you'd need to introduce an array or set of types where you set a flag to do what (1) above does, and have a method of shwoing which is selected or not (alpha changes, colour changes or something like that). IPete2. |
| ||
Thanks IPete2 Already been through this lot, but doesn't help me (I didn't say I was smart!). Was hoping for a two-liner piece of code, something like:- If MouseDown(1) Then ; code to show Text hovering above entity with entity name End If or whatever! Cheers - Paul |
| ||
Here you go...Graphics3D 800,600,0,2 ; Create your camera camera=CreateCamera() MoveEntity camera,0,0,-10 ; Create your object TestObject=CreateCube() ; Make the object pickable EntityPickMode TestObject,1 ; Give the object a nice name NameEntity (TestObject,"Brian") While Not KeyDown(1) ; See when the mouse is and what pickable entity is under it. CameraPick(camera,MouseX(),MouseY()) ; Draw the scene RenderWorld ; Print the entities name if its picked. If PickedEntity()<>0 Then Text 10,10,EntityName(PickedEntity()) ; Flippydeedoodah Flip Wend |
| ||
Uncle Cool. Genius. You showed me in seconds where I was struggling for hours ... and to think I was almost there! Just the multiple selection conundrum now. It would be cool to say have the ability to select - as per Windows Explorer where you either select everything you want with a mouse-drag or to also hold Ctrl and reclick to exclude files, or - in this case obviously - 3d objects. IPete2's technique makes sense - again, I'm wondering if anyone has the code for the job. Here's hoping... Cheers |
| ||
Making multiple selections should be easy. Here is the basic idea... Have an array or type to store the entity ids while ctrl is down if mousehit(1) then if something is picked then if it has already been picked before do something (unselect or ignore it) else add it to your list endif end end wend do something with you list alternatively you could simply not worry about if an entity has been selected before whilst collecting the mouse clicks, and then after ctrl has been released remove the duplicate entities. obviously you will need to clear you list each time ctrl is pressed |
| ||
Uncle - thanks again. The whole thing is becoming clearer now! Cheers |