Jump to content

Mouse picking


Raul
 Share

Recommended Posts

Hello guys,

 

After a long pause, I started learning Leadwerks again. I am trying C# because is much easier for me (I know VB.NET).

 

I am trying to learn how to use mouse picking. Please can you provide me some sample? I want to know when I am clicking on a mesh (it's a sphere)

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

Hi. First of all, for your information, the headers work with VB .NET as well, if you want to code in VB.

 

Here is a code example in C#, I don't know if I uploaded that version yet. Tell me if it doesn't work, means I didn't.

 

while (!Window.HasRequestedClose)
{
   if (new Pick(camera, Graphics.Width / 2, Graphics.Height / 2, 500).Entity.Class == "Mesh"))
   {
       // do things
   }
}

Link to comment
Share on other sites

   if (new Pick(camera, Graphics.Width / 2, Graphics.Height / 2, 500).Entity.Class == "Mesh"))

 

have you removed the non-working radius parameter in the C# version? as well as the collisiontype, since I am assuming that the 'Entity.Class=="Mesh"' is your pickfilter? seems to be missing some parameters...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Me again:

 

So I use Raycasting.CameraPick to test the collision between my cursor and my planet (a sphere)

 

I record the data in

Pick pick

 

Now I am interested to know what mesh did I exactly hit with my mouse. Because every sphere represent a 'planet' in my game. One way is to compare the position of the pointed mesh with my all meshes but I was thinking at something more exactly, because there will be more meshes with same position later in my game. ;)

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

Yes, I receive almost all the data in the 'pick.entity' (position, roatation, etc.) but I need to know what mesh did I pressed... something like an ID

 

I need this info because I have 2 arrays: planet[ ] and meshPlanet[ ]

planet is a class with all info (position, type, name, population, etc.) and meshPlanet is the Leadwerks mesh. When I click on a meshPlanet I want to know what planet did I clicked..

 

From pick.entity I can't find something usefull except Position..

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

You'll need the new version for working picks, apparently. Sorry, don't have time to upload it today.

 

When you pick something, however, remember you get the mesh. So any key set to the model won't be accessible. Use Pick.Entity.Parent to get the model of the mesh picked, I assume.

Link to comment
Share on other sites

You'll need the new version for working picks, apparently. Sorry, don't have time to upload it today.

?? how long could that possibly take?

 

When you pick something, however, remember you get the mesh. So any key set to the model won't be accessible. Use Pick.Entity.Parent to get the model of the mesh picked, I assume.

true. RVL, my example code was just that... an example for getting the name key... you should be able to get the model like lazlo suggested

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

?? how long could that possibly take?

Considering the fact that I don't want to release an in-between unstable version, that Tyler is gone and that no one gives feedback (despite the fact that it was asked repeatedly in my posts and blog) on how they want the C# headers, a while.

Link to comment
Share on other sites

Considering the fact that I don't want to release an in-between unstable version, that Tyler is gone and that no one gives feedback (despite the fact that it was asked repeatedly in my posts and blog) on how they want the C# headers, a while.

 

fair enough... but thats not what was implied in your previous post... RVL just wanted to do a pick and you commented that they were fixed in the latest version but you didn't have time to upload it.

 

But if your reasoning is that its an unstable version and you are awaiting feedback then thats understandable. People should be made aware of these facts so they do not waste time trying to develop with something that is unstable. Anybody seriously trying to do a project with LE needs to know these things so they can make a decision on using a language that is officially supported or one that is community supported like C#.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

:D

 

you lost me somewhere here:

 

When you pick something, however, remember you get the mesh. So any key set to the model won't be accessible. Use Pick.Entity.Parent to get the model of the mesh picked, I assume.

 

If I use: pick.Entity.Position I will receive the position of the sphere (Mesh.Sphere) which I clicked.. Why to use .Parent?

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

He suggested that because I suggested that you get the name key of the entity you picked. Models contain keys, meshes, scripts,etc... so to get the name key from the pick.entity (which returns the mesh because picks only work on meshes and terrain), you would have to use the parent of the pick.entity to be able to get its model which holds the key for its name.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

well new version or not, if you are just using meshes for your planets that I assume you are creating with CreateSphere(), then it won't inherently have the ability to store keys... but you could create a class for your planets to do so...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...