Jump to content

Recommended Posts

Posted

I am looking into a few things at the moment, and one of them involves object selection.

 

First off the bat, is there any command relevant to selecting an entity? I am eager to be able to select an object and tell it to do actions. But maybe only specific objects, no grabbing any old object. It makes it a bit more complicated but any suggestions would be very helpful.

 

Thanks in advance,

 

 

 

DH.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

Try to use CameraPick() command.

There is an example of using CameraPick() in fpscontroller.lua script (when pressing E key).

 

Thanks I'll take a look at that. I also found the part of the wiki tutorial about selection to apply a texture - http://www.leadwerks.com/files/Tutorials/CPP/Collision_And_Raycasting.pdf

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

What about raycasting. I don't know if that is what CameraPick() does but in the other engines I have used I just sent out a ray from my mouse position and it returned what object was hit.

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Posted

CameraPick() is indeed raycasting

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Posted

Yes it is. And I have set up something similar to the thing in the tutorial :) Now does anyone know about entity specific selection? Or the ability to only chose specific things? Because at the moment it selects any entity. Can I add a flag of sorts so when I select it it performs a check to see if the entity specific flag is checked?

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

Yes. You can use SetEntityKey() and GetEntityKey().

 

Thanks!! That is exactly what I'm looking for :) It should work perfectly! I'll have a play with the examples and see how it could fit in to my project.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

Does anyone know how I can use it as a check? I am having trouble figuring it out...

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

1. Before main loop for each entity that may be picked up set the flag:

SetEntityKey(entity, "pickable", true)

 

2. When trying to pick up something call CameraPick() to find intersection with line of sight.

 

3. Check that intersection for entity class. So it may be terrain or mesh or something else unwanted. Here you need to find parent entity from found mesh or ignore unwanted entity class.

 

4. Check if entity is pickable by calling:

GetEntityKey(entity, "pickable")

 

5. Do what you need with pickable entity.

Posted

Im just not sure how to set out the if statement for steps 3 & 4.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

Look at fpscontroller.lua. You will find example there.

 

   --Use objects
   if KeyHit(KEY_E)==1 then
       pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
       if pick~=nil then
           repeat
               if pick.entity:GetClass()==ENTITY_MODEL then
                   break
               end
               pick.entity=pick.entity.parent
           until pick.entity==nil
           if pick.entity~=nil then
               pick.entity:SendMessage("use",controller,0)
           end
       end
   end

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.

×
×
  • Create New...