VicToMeyeZR Posted February 4, 2010 Share Posted February 4, 2010 I am trying to create a mesh in real time but the mesh always just goes to 0,0,0 positon function class:CreateObject(model) local object=self.super:CreateObject(model) object.model = CreateSphere(object.resolution, "0") Is there a way to make it follow where the object is in the editor? Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Rick Posted February 4, 2010 Share Posted February 4, 2010 You can look at any of my Pi objects, but basically in the Update() method you can set the position of your mesh to the models position. Here is how I handle this. function class:CreateObject(model) local object = self.super:CreateObject(model) object.model = model -- this will save off the editor model so you can use it later object.sphere = CreateSphere(object.resolution, "0") function object:Update() -- I can't remember if these are the right names or not but you get the idea object.sphere:SetPosition(object.model:GetPosition()) end end Also, to avoid the sphere being to large and covering up your editor model which prevents you from being able to click it to select it (you can still select it on the tree view side), I generally offset the sphere down 1/2 the size of it. This puts the editor model 1/2 way sticking out the top so I can still select it and move it around. OR you could probably parent it. I avoid parenting because when I create objects in code when I'm in game mode I generally hide the editor model since it's not needed. It's basically used to just be able to move your objects you create in code when in editing mode. This is why I create that global game mode variable and check that in the Update() method in my Pi objects. Also, be sure to free the objects you create in the free method. Or even if you delete the editor model your object that you created in code will stay in the scene. Also note that if you try to create a body in lua code there is no way to get a collision method fired for that. I have a request in for this because it limits the usefulness of creating bodies in lua code. Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 4, 2010 Author Share Posted February 4, 2010 ah.. great. Ok, when you create a sphere, its default diameter is 2. Scale is a Vect3 setting, which would not give the result desired. What the function call to scale a sphere? Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 4, 2010 Share Posted February 4, 2010 In the lua template for the LE wizard this is used to scale a cube. ground=CreateCube() ground:SetScalef(10.0,1.0,10.0) ground:SetPositionf(0.0,-2.0,0.0) ground:Paint(material) Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 4, 2010 Author Share Posted February 4, 2010 yeah, I know the cube, but what I was wondering since there is a deafult value of diameter for a sphere, wouldn't one think that to scale that you should be able to set the diameter, and not use a Vect3 for its size? Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 4, 2010 Share Posted February 4, 2010 I'm not sure what it is you are trying to do but can't? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 4, 2010 Author Share Posted February 4, 2010 I just was trying to find the easier way to set the diameter of a created sphere other than if key=="diameter" then x0 = value y0 = value z0 = value object.model:SetScalef(x0, y0, z0, object.model) end Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 4, 2010 Share Posted February 4, 2010 surely if its a sphere you want you'd just have the one value as you'd scale it equally. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 4, 2010 Author Share Posted February 4, 2010 Thats the problem, there is no way (from the wiki) to set diameter.. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 4, 2010 Share Posted February 4, 2010 I meant: if key=="diameter" then singlevalue = value object.model:SetScalef(singlevalue, singlevalue, singlevalue, object.model) end as you'd be scaleing in the x y and z equally Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Canardia Posted February 4, 2010 Share Posted February 4, 2010 Thats the problem, there is no way (from the wiki) to set diameter.. But a sphere has 3 diameters, one for each dimension. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 4, 2010 Author Share Posted February 4, 2010 technically speaking, it only has one. Diameter is diameter.. Thats all I wanted to know. I jst saw in the wiki the default was 2, so I wasn't sure if it just set Scalef(2,2,2, mesh) Or if there was a magically function that did that for you, by just passing diameter. Because if you give it a different number for one of the size demensions, then its not a sphere any more, is a different shape. (just trying to clarify something) A sphere (from Greek σφαῖρα—sphaira, "globe, ball") is a perfectly round geometrical object in three-dimensional space, such as the shape of a round ball. Like a circle in three dimensions, a perfect sphere is completely symmetrical around its center, with all points on the surface lying the same distance r from the center point. This distance r is known as the radius of the sphere. The maximum straight distance through the sphere is known as the diameter of the sphere. It passes through the center and is thus twice the radius. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD 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.