Jump to content

Picking, terrain vs other meshes


Rick
 Share

Recommended Posts

I'm curious how other people determine if the terrain was picked vs other meshes. According to http://www.leadwerks.com/wiki/index.php?title=Raycasting#CameraPick the pick.surface will be null if it's not a mesh (ie. terrain). So I'm going off that, but is there a down side to that? Is this how we should tell if the terrain vs a mesh if being picked by the camera?

 

Also, the way I had to tell that was by using strcmp() against pick.surface since a simple check against 0 (null) didn't work. It works and I get why it works since TEntity is just a char*, but it does seem strange when you read it in code. Is there another way that looks like it makes more sense? Seems like there should almost be a IsEntityNull() method or something in the engine.

Link to comment
Share on other sites

What do you mean? I do wrap my mesh objects with user data of a class instance, but I don't for the terrain. I could check for null but wouldn't this basically mean I have to create a generic class that everything has SetEntityUserData in? Or are you talking a different kind of class?

Link to comment
Share on other sites

GetEntityKey(entity,"class") should return "Mesh" or "Model" for a mesh type entity, and "Terrain" for terrain. :)

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

If it isn't class, it would have to be classname as the key. It works, I used it in Jeklynn Heights in C++ for the 3rd person camera collision. It would react differently to terrain and meshes, based on a check against the key.

 

Not sure if something has changed regarding this between 2.30 and 2.31, so I guess I can say I haven't tried it "yet/now".

 

Let me test...

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

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...