L B Posted September 8, 2010 Share Posted September 8, 2010 I'm trying the following code. When I middle-click, it creates a warrior at pick position and assigns its "canSelect" key to "true". When I click, it checks the "canSelect" entity of the key to know if it is selectable. However, that key checking always returns the default value (a.k.a. empty string), as if the model didn't keep its keys through the raycast. Note: It's C#, but the syntax is very readable, so I assume you can all read it. using System; using System.Collections.Generic; using Aerora.Logic; using Leadwerks; namespace Aerora { static class Client { public static bool Run = true; private static Entity selected; private static Entity Selected { get { return selected; } set { if (Selected != null) { Selected.Color = Color.White; } selected = value; Selected.Color = Color.Red; } } public static void Main(string[] args) { Engine.Initialize(DisplayMode.Window); Framework.Initialize(); Filtering.Optimize(); FileSystem.Initialize(@"C:\Program Files\Aerora"); Framework.Effects.Bloom.Enabled = true; Framework.Effects.VolumetricLighting.Enabled = true; Framework.StatisticMode = StatisticMode.FrameRate; Scene scene = new Scene("abstract::Dust Valley.sbx", Framework.Camera); Explorer explorer = new Explorer(Framework.Camera); Random r = new Random(); List<Model> warriors = new List<Model>(); while (Client.Run && !Window.HasRequestedClose) { explorer.Update(); Pick pick = new Pick(Framework.Camera, Mouse.X, Mouse.Y, 5000); if (Mouse.ButtonHit(MouseButton.Middle)) { Model warrior = new Model("abstract::warrior_character_skin.gmf") { Position = pick.Position, ViewRange = ViewRange.Infinite, Scale = 0.3f, Rotation = new Vector3(0, r.Next(), 0) }; warrior.Keys["canSelect"] = "true"; //pick.Entity.Keys["canSelect"] == "true"; // Returns true. warriors.Add(warrior); } else if (Mouse.ButtonHit(MouseButton.Left)) { if (pick.Entity.Keys["canSelect"] == "true") // Returns false. { Selected = pick.Entity; } } foreach (Model warrior in warriors) { warrior.Animate(Timing.Time / 20); } Timing.Update(); Framework.Update(); Framework.Render(); Graphics.Flip(); } Framework.Terminate(); Engine.Terminate(); } } } Quote Link to comment Share on other sites More sharing options...
Rick Posted September 8, 2010 Share Posted September 8, 2010 I didn't look at the code, but is it the case of mesh vs model? I know that who thing is around with picking. Quote Link to comment Share on other sites More sharing options...
L B Posted September 8, 2010 Author Share Posted September 8, 2010 Ahh, there we go. Thanks. Is there a way to get the mesh from the model? Quote Link to comment Share on other sites More sharing options...
Rick Posted September 8, 2010 Share Posted September 8, 2010 I can't remember off the top of my head, but one is the parent of the other, and I can't remember what pick.entity returns (mesh or model) It's always a trial and error when I have to do this because I can't remember the order. I actually find that kind of annoying. What is the point of the model part of that? Why isn't it all just a mesh? Quote Link to comment Share on other sites More sharing options...
L B Posted September 8, 2010 Author Share Posted September 8, 2010 Models have attached physics bodies, don't they? And pick returns mesh, therefore I guess Model is the parent of Mesh. Quote Link to comment Share on other sites More sharing options...
Rick Posted September 9, 2010 Share Posted September 9, 2010 Models have attached physics bodies, don't they? But don't they require .phy files that we must create with that phygen tool to work correctly with the physics engine? If so what's the point then of having them included when we load a mesh? Quote Link to comment Share on other sites More sharing options...
L B Posted September 9, 2010 Author Share Posted September 9, 2010 I personally never touched a .phy file. If you load a model that doesn't have one, it will be created at runtime. Quote Link to comment Share on other sites More sharing options...
Rick Posted September 9, 2010 Share Posted September 9, 2010 I thought there were issues with that working correctly without custom phy files? Maybe that was an older version of LE. Quote Link to comment Share on other sites More sharing options...
Soamp Posted September 9, 2010 Share Posted September 9, 2010 Hi, I think the picked thing is mesh. I usually use 2 ways to access the model from its mesh. (in LUA actually bt I hope it helps) 1 - when I create my model I access the mesh with this command : local mymesh=GetChild(mymodel,1) then I set its Target to my model, using SetTarget command. so I can access the model from the picked mesh, with GetTarget command. 2 - There is a LUA function in "scripts\utilities.lua" called GetMeshModel. its a simple loop to get model from its mesh. I think you can use a similar code in any other language. I hope it helps. 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.