DigitalHax Posted April 9, 2012 Share Posted April 9, 2012 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. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Daimour Posted April 9, 2012 Share Posted April 9, 2012 Try to use CameraPick() command. There is an example of using CameraPick() in fpscontroller.lua script (when pressing E key). Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted April 9, 2012 Author Share Posted April 9, 2012 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 Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Benton Posted April 9, 2012 Share Posted April 9, 2012 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. Quote 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 Link to comment Share on other sites More sharing options...
Pixel Perfect Posted April 9, 2012 Share Posted April 9, 2012 CameraPick() is indeed raycasting Quote 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++ Link to comment Share on other sites More sharing options...
DigitalHax Posted April 10, 2012 Author Share Posted April 10, 2012 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? Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Benton Posted April 10, 2012 Share Posted April 10, 2012 tags? Quote 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 Link to comment Share on other sites More sharing options...
Daimour Posted April 10, 2012 Share Posted April 10, 2012 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? Yes. You can use SetEntityKey() and GetEntityKey(). Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted April 10, 2012 Author Share Posted April 10, 2012 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. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
DigitalHax Posted April 11, 2012 Author Share Posted April 11, 2012 Does anyone know how I can use it as a check? I am having trouble figuring it out... Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Daimour Posted April 12, 2012 Share Posted April 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted April 12, 2012 Author Share Posted April 12, 2012 Im just not sure how to set out the if statement for steps 3 & 4. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Daimour Posted April 12, 2012 Share Posted April 12, 2012 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.