VicToMeyeZR Posted January 17, 2010 Share Posted January 17, 2010 Can someone give me an idea what I got wrong here. I can put the model in the editor, but as soon as I set the values for the idle animation I get Exception violation, and it crashes. Thanks require("scripts/class") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group = grid:AddGroup("Animations") group:AddProperty("idle_start", PROPERTY_INTEGER, "Idle Start Frame") group:AddProperty("idle_end", PROPERTY_INTEGER, "Idle End Frame") group:AddProperty("walk_start", PROPERTY_INTEGER, "Walk Start Frame") group:AddProperty("walk_end", PROPERTY_INTEGER, "Walk End Frame") group:AddProperty("run_start", PROPERTY_INTEGER, "Run Start Frame") group:AddProperty("run_end", PROPERTY_INTEGER, "Run End Frame") group:AddProperty("jump_start", PROPERTY_INTEGER, "Jump Start Frame") group:AddProperty("jump_end", PROPERTY_INTEGER, "Jump End Frame") group:AddProperty("crouch_start", PROPERTY_INTEGER, "Crouch Start Frame") group:AddProperty("crouch_start", PROPERTY_INTEGER, "Crouch End Frame") group:AddProperty("strafeleft_begin", PROPERTY_INTEGER, "Left Start Frame") group:AddProperty("strafeleft_end", PROPERTY_INTEGER, "Left End Frame") group:AddProperty("straferight_begin", PROPERTY_INTEGER, "Right Start Frame") group:AddProperty("straferight_end", PROPERTY_INTEGER, "Right End Frame") group:Expand(1) end function class:CreateObject(model) local object = self.super:CreateObject(model) object.model = model object.framestart = tonumber(object:GetKey("idle_start")) object.frameend = tonumber(object:GetKey("idle_end")) Notify(object.framestart) function object:SetKey(key,value) if key=="idle_start" then self.idle_start = tonumber(value) elseif key=="idle_end" then self.idle_end = tonumber(value) elseif key=="walk_start" then self.walk_start = tonumber(value) elseif key=="walk_end" then self.walk_end = tonumber(value) elseif key=="run_start" then self.run_start = tonumber(value) elseif key=="run_end" then self.run_end = tonumber(value) elseif key=="jump_start" then self.jump_start = tonumber(value) elseif key=="jump_end" then self.jump_end = tonumber(value) elseif key=="crouch_start" then self.crouch_start = tonumber(value) elseif key=="crouch_end" then self.crouch_end = tonumber(value) elseif key=="strafeleft_start" then self.strafeleft_start = tonumber(value) elseif key=="strafeleft_end" then self.strafeleft_end = tonumber(value) elseif key=="straferight_start" then self.straferight_start = tonumber(value) elseif key=="straferight_end" then self.straferight_end = tonumber(value) else return self.super:SetKey(key,value) end return 1 end function object:GetKey(key,value) if key=="idle_start" then return self.idle_start elseif key=="idle_end" then return self.idle_start elseif key=="walk_start" then return self.walk_start elseif key=="walk_end" then return self.walk_end elseif key=="run_start" then return self.run_start elseif key=="run_end" then return self.run_end elseif key=="jump_start" then return self.jump_start elseif key=="jump_end" then return self.jump_end elseif key=="crouch_start" then return self.crouch_start elseif key=="crouch_end" then return self.crouch_end elseif key=="strafeleft_start" then return self.strafeleft_start elseif key=="strafeleft_end" then return self.strafeleft_end elseif key=="straferight_start" then return self.straferight_start elseif key=="straferight_end" then return self.straferight_end else return self.super:GetKey(key,value) end return value end function object:StartAnimations(movement) object.framestart = object:GetKey(movement .. "_start") return object.framestart end function object:EndAnimations(movement) object.frameend = object:GetKey(movement .. "_end") return object.frameend end function object:LockKeys(model) self.super:LockKeys() end function object:UnlockKeys(model) self.super:UnlockKeys() end function object:UpdateMatrix() end function object:Reset() end function object:SetTarget(target,index) end function object:Collision(entity,position,normal,force,speed) end function object:ReceiveMessage(message,extra) if message=="forward" then --[[ elseif message=="reverse" then elseif message=="mleft" then elseif message=="mright" then elseif message=="tleft" then elseif message=="tright" then elseif message=="crouch" then elseif message=="jump" then elseif message=="attack" then ]]-- else self.super:ReceiveMessage(message,extra) end end function object:Render() object.framestart = object:StartAnimations("idle") object.frameend = object:EndAnimations("idle") if object.frameend ~= nil and object.frameend ~= 0 or object.framestart ~= nil then object.frame = math.fmod(AppTime()/35, object.framestart - object.frameend) + object.framestart Animate(object.model, object.frame, 0.5, 0, true) end end function object:Free(model) self.super:Free() end end function class:Free() self.super:Free() 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...
Rick Posted January 17, 2010 Share Posted January 17, 2010 You are going to kick yourself. Notice anything wrong here? if key=="idle_start" then return self.idle_start elseif key=="idle_end" then return self.idle_start Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted January 17, 2010 Author Share Posted January 17, 2010 lol... oops Hence the reason it crashes. End and start time are both the same. 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...
AggrorJorn Posted January 18, 2010 Share Posted January 18, 2010 This looks realy good VicToMeyZR. I haven't tried it yet (I'm gonna ) but it seems realy nice. Does it handle single animation as well? Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted January 18, 2010 Author Share Posted January 18, 2010 It can. RIght now its only setup for idle animation, so if you never enter anything other than the idle(which can be any frames) then it will only do that animation 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 January 18, 2010 Share Posted January 18, 2010 You know what we should play around with for storing character animations. Instead of storing them in settings to the model which is limiting, we should store them in an xml file OR sqlite file. We could make a setting that points to the xml file/sqlite to use. This would be so much more dynamic. Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted January 18, 2010 Author Share Posted January 18, 2010 oo.. sweet. I like your train of thought. Good idea. 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...
AggrorJorn Posted January 18, 2010 Share Posted January 18, 2010 Its a nice idea. people could create an entire 'animation-collection' for an entire level. They can define new animation by referring to gmf's. The idea of 'level-collections' can also refer to sound, level-information etc. Quote Link to comment Share on other sites More sharing options...
Rick Posted January 18, 2010 Share Posted January 18, 2010 VicToMeyeZR, are you going to pursue this idea then? If so could you do the XML route and I could take the sqlite route. I'd like to have both options for people. If you come up with a structure I'll make a sqlite file that has a table with the same fields. Then in the setkey section we can fill out a lua table that holds all the animation information from the file they selected. Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted January 18, 2010 Author Share Posted January 18, 2010 Yes I will. I already posted the XML lib for use so I will start on the scripting for it. 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 January 19, 2010 Share Posted January 19, 2010 forgive my ignorance but what exactly is the advantage over a .ini ? 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...
Rick Posted January 19, 2010 Share Posted January 19, 2010 xml is just a little more structured and standard than an ini file these days. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 20, 2010 Share Posted January 20, 2010 xml is just a little more structured and standard than an ini file these days. M'kay so no real benefit then, I was wondering why write the XML then load an XML parser in Lua to read it to store the info in the lua properties.. when a .ini would simply fill in the blanks on load, the .ini would simply be something like: idle_start=210 idle_end=234 walk_start=235 walk_end=259 ect ect .... 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...
Rick Posted January 20, 2010 Share Posted January 20, 2010 To be honest when I suggested using an xml file I was more thinking that you could assign an xml file for each instance of the model and it would have the animation information for that instance. I wasn't thinking that they would all share the same names and number of animations. With indie developers getting models from all over the place they most likely won't have the same number of animations at the same frames so each different character model would needs it's own animation information file, which would be custom to that instance of the character object. VicToMeyeZR was thinking slightly differently than I was. In the example he put together then yes using the ini would make sense. In the way I was thinking an ini wouldn't work the same way. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 20, 2010 Share Posted January 20, 2010 I wasn't thinking that they would all share the same names and number of animations. With indie developers getting models from all over the place they most likely won't have the same number of animations at the same frames so each different character model would needs it's own animation information file Which is true, but you'd just write a new .ini file as you would have to write the new animation info in XML .. the outcome remains the same? 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...
Rick Posted January 20, 2010 Share Posted January 20, 2010 You'd have to parse the ini file yourself then though. The way this Thingoid is setup is that it's just one generic Thingoid in the editor. You place it in your scene and it creates a character controller. Via a setting is where you assign what mesh you want to use. That mesh would have it's own animation information which could be different from another mesh. The reason I do characters this way instead of the way Josh was thinking, which would be that you actually place each model into your scene from the tree view on the right in the editor, is because characters all share common code they need to do. So instead of copying and pasting that code into each character model lua file, I have 1 lua file that runs the character code and I select which mesh to assign it to. It's kind of like an object oriented way of thinking. If I was programming this in an OOP language I would make a Character class. That class holds all the code and it has properties. One of the properties would be what mesh to use for this character, and another would be that meshes animation information. The ini file system he has setup will be auto populated for that model. In this case the model that's being used when I drag my character thingoid into the scene is a circle model. The only purpose of it is to allow me to move the position of the controller and the mesh I assinged to it in the editor. The real model being used in the game is the mesh you assign via a property. So given that information you have to parse out a file that has stored data, if it's ini or xml or some other protocol you come up with. Xml is just very common and there are tons of already premade libraries and code out there that allows you to easily parse complex xml files. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 20, 2010 Share Posted January 20, 2010 ok I see, I did not realise it was for a hemorrhoid thingy, so this is for apps predominantly or exclusively written in lua? 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...
Rick Posted January 20, 2010 Share Posted January 20, 2010 Mostly yes. I know VicToMeyeZR started the topic but he's playing off the character thingoid I made and improving on it, and all I'm doing these days is lua based. My goal is to make a bunch of different useful thingoids so a full game can be made. My current platform game that I'm making will be lua based with a possible dll loaded from lua for anything that is very speed sensitive. But ultimately it's ran from lua. Basically my goal is to prove that with some modifications to how some lua stuff is done, it's possible to make an entire game from lua using LE. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 20, 2010 Share Posted January 20, 2010 Are there any concerns (speedwise that is) to using lua for controllers? 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...
Rick Posted January 20, 2010 Share Posted January 20, 2010 I haven't seen any. Speedwise it runs great. The one big catch with doing this, which reminds me I should create a request for this, is that currently bodies that you create via lua code, you have no way of getting a collision function called on them. They will collide and act on physics, but you can't link to a callback on them to do certain things when something collides. An example with this is creating area/volume triggers. I have a thingoid that is just a physics body. You can change the size of it by the settings and it recreates a new physics body when you do, because you can't scale physics bodies and have them work correctly. This works create, because it's much faster to do it in the editor where you can size things up and resize on the fly to create any size body where you want it. The issue is when something hits it, say like the player, there is no way to know that because you can't get a function called in lua. Currently that only works when you drag an actual model into your scene, then that lua classes collision method is called. Quote Link to comment Share on other sites More sharing options...
Niosop Posted January 20, 2010 Share Posted January 20, 2010 Probably not. All they do is call engine code so the only real overhead is the function calling overhead and the binding code. Since it's only run once per frame or physics update and it's not doing any of the heavy lifting itself, then it's probably negligible. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Rick Posted January 20, 2010 Share Posted January 20, 2010 I think people are scared to start using lua because they are so worried about the speed. It's honestly not bad. For me the rapid development I get from seeing my code changes instantly far out weighs the few drops in FPS. Quote Link to comment Share on other sites More sharing options...
Niosop Posted January 20, 2010 Share Posted January 20, 2010 And in the couple cases where it might make an impact you can always convert it over to C++ later once you're sure the functionality won't change. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Rick Posted January 20, 2010 Share Posted January 20, 2010 Exactly. With being able to load dlls from lua, it just opens up so many doors and allows you not to fear the speed issue. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 20, 2010 Share Posted January 20, 2010 Probably not. All they do is call engine code so the only real overhead is the function calling overhead and the binding code. Since it's only run once per frame or physics update and it's not doing any of the heavy lifting itself, then it's probably negligible. ok, makes sense. I think people are scared to start using lua because they are so worried about the speed. It's honestly not bad. For me the rapid development I get from seeing my code changes instantly far out weighs the few drops in FPS. Not really a "fear of it" with me its just I have not gotten around to it yet so am currently trying to get a feel for pro's and con's. 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...
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.