ParaToxic Posted January 11, 2013 Share Posted January 11, 2013 Hello guys, I'm very bad in lua so I have a question about some collider box stuff. I would like to create a entity which you can place in the editor and create a 3D box with 3 mouse clicks. When you place it you click on the ground once and from this point a box starts to follow your mouse ( just a 2D square maybe). When you click a second time the box has then a fixed size and you can now control the height of the box with the mouse.When you have your height you click a third time and you have your own, perfect sized collider box. But how I can make that with mouseclicks and soone as a object, you can just place in the Editor ?? Thanks Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 11, 2013 Author Share Posted January 11, 2013 Well its just a first idea with 3 mouse clicks and the MouseX component for each scale axis.It also saves the cube in the userdata so you can load it if already exists. http://www.youtube.com/watch?v=Y4TSJDs57Tk&feature=youtu.be 1 Quote Link to comment Share on other sites More sharing options...
Daimour Posted January 12, 2013 Share Posted January 12, 2013 Looks interesting. How did you do that in Editor? Why are you using userdata? You can store Width, Height, Depth as "keys" for model. They will be stored as plain text in SBX, so you could change them manualy. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 12, 2013 Author Share Posted January 12, 2013 Well it is very bad code but it works , for my lua knowledge Yes I could store it as keys, your right require("scripts/class") local class=CreateClass(...) function class:InitDialog(grid) end function class:CreateObject(model) local object = self.super:CreateObject(model) local object=self.super:CreateObject(model) SetWorld(fw.transparency.world) object.cube=CreateCube() object.cube:SetScale(Vec3(4,4,4)) object.cube:Paint(LoadMaterial("abstract::collider.mat")) object.axis1 = 0 object.axis2 = 0 object.axis3 = 0 object.scalex = 1 object.scaley = 1 object.scalez = 1 object.setall = 0 SetWorld(fw.main.world) function object:Update() self.cube:SetPosition(self.model:GetPosition()) if self.axis1 == 0 and self.axis2 == 0 and self.axis3 == 0 then self.cube:SetScale(Vec3(self.scalex,self.scaley,MouseX()/100)) if MouseHit(1) == 1 then self.scalez = MouseX()/100 self.axis2 = 1 self.axis1 = 1 end end if self.axis1 == 1 and self.axis2 == 1 and self.axis3 == 0 then self.cube:SetScale(Vec3(MouseX()/100,self.scaley,self.scalez)) if MouseHit(1) == 1 then self.scalex = MouseX()/100 self.axis3 = 1 end end if self.axis1 == 1 and self.axis2 == 1 and self.axis3 == 1 then self.cube:SetScale(Vec3(self.scalex,MouseX()/100,self.scalez)) if MouseHit(1) == 1 then self.scaley = MouseX()/100 self.axis1 = 0 self.userdata = self.cube end end end function object:Free() if self.cube~=nil then self.cube:Free() self.cube=nil end self.super:Free()--Don't forget this!! end end 1 Quote Link to comment Share on other sites More sharing options...
Andr3wHur5t Posted January 22, 2013 Share Posted January 22, 2013 That's cool, do you mind if I use this technique for a setting sizing properties on a trigger system? Quote Tools: AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro Programing & Scripting Languages: C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby Link to comment Share on other sites More sharing options...
DigitalHax Posted January 22, 2013 Share Posted January 22, 2013 Maybe you could use grid snap to make a gritty geometry brush editor Maybe for people who can't afford LE3 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...
Rick Posted January 22, 2013 Share Posted January 22, 2013 Something to watch out for, if I'm not mistaken that code will run in game also. When I was doing stuff like this with my Pi scripts, I made a flag that would tell me if I'm in the editor or running the game so I could skip over editor parts when running the game. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 25, 2013 Author Share Posted January 25, 2013 @Rick: Thats a good idea for that.But how can I find out that I'm running it in the editor ? I saw that LE3 comes with a collisiontrigger script, so I will wait for that Also it should save the properties as keys ( I mean the scale ) and load it from keys when exist, because now when I load a scene I have to resize all the collisionboxes again. Quote Link to comment Share on other sites More sharing options...
Rick Posted January 25, 2013 Share Posted January 25, 2013 But how can I find out that I'm running it in the editor ? When you run from the editor it runs a game script. I set a global var in that script to let me know if in game mode or not. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 25, 2013 Author Share Posted January 25, 2013 Yes you are right, haven't thought about that : 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.