Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Blog Entries posted by Einlander

  1. Einlander
    Restarted my networking framework yet again. This time I gave it a new name 'Hexe'. The old name was 'Overwatch'. It was named long before the Overwatch game came out. It was based off the Half-Life Overwatch. It oversaw the players, ai spawning, contained a secondary path-finding system, but had no networking as it was not native to the LUA side of Leadwerks. 'Hexe' is German for 'witch'. I don't really know why I chose the name but I have the feeling I will be able to put it to good use. Maybe I'll even mix in some Anglish into it.
    This restart occurred because the framework became too cumbersome. I had the entity synchronization working correctly, but it did not differentiate between player and an object in the world. That wasn't really that bad, what made messed it up was that a lobby system and teams were needed and there was no space to squeeze any other components into the mix.
     This rewrite will focus on the player/client and foremost. The components that are currently being written or are complete are:
    The server browser. This was a side project created out of necessity. I did not want to have to hard code the ip every time. Anytime I wanted to test multiple clients I had to change the code depending on which computer was running the server.   PITFALL: Since Leadwerks does not expose the servers local ip address via code, you will need to get it manually from you computer, or use some creative workarounds Network Manager Hexe is split up between a server class and a client class. Both classes use a network manager class that can automatically handle hosting or connecting to a server. The network manager currently handles the handshake and the beginnings of the lobby system. When a client joins it initiates and handles the handshake between the server and client. It also raises events so the server or client can react accordingly if need be. After the handshake is completed, the network manager starts the lobby system The connection handshake. This is was saved from the last version. It makes sure the server and client are using the same protocol version. It will then register the client on the server and give it an incremental number (similar to the source engine) that allows the client state to be manipulated     The Lobbying system: This is completely new. After the handshake is complete, it will send a command launching the lobbying system. The network manager only makes sure that a client is in the servers lobby and nothing more. The client and server manually handle the team creation and player switching on their own.  Teams are not part of the network manager because it would require large amounts of rewrites depending on the type of game being created. When the lobbying system is complete the client input will be added. So far things are going well and maybe soon I wont be staring at console output for feedback.
     
  2. Einlander
    Sorry this is so long and may seem like rambling. I've been working on so many things relating to Leadwerks in game and tool-wise that this doesn't even begin to cover it.
     
    When I started my Halloween contest entry, I had a very simple idea: You have arrived in area/town/location x, you need to get out. As I started to fill in the blanks I realized that this project would never be done before Halloween arrived. I started using Articy:Draft in detail to bring all the overflowing ideas back to manageable levels.
     
    Now what I have most of the plot fleshed out I had to start on something that few of us bother worry/care about: Standards. Most games, at least Source and Unreal, have standard practice dimensions for most things. Doors, windows, walls. floors. Before making one single asset I will need to know what should be the same everywhere and what problems I will run into.
     
    What do we know about Leadwerks?
     
    Leadwerks now uses a cm grid that goes by powers of 2 so you will need to stop thinking in 10's
     
    *these are measure to the ALMOST literal limit. so anything larger is safe
    NavMesh Generation
    *NOTE* There are many edge cases/exceptions to some of these measurements
    Shortest navigable covered area = 213cm
    Smallest navigable squared area = 206cm^2 x,z * edge-case if the centrer of the nav area is (0,0,0) you can get it even smaller [its a bug]
    highest navigable step = 50cm y * there are some edge cases
    narrowest navigable corridor = 116cm
     
    *the character controller is prone to even the slightest floating point error
    *so some of the measurements are adjusted to fall safely short of some
    FPS Limits:
    Shortest navigable covered area: 184cm * no jumping room
    Narrowest corridor = 76cm *lots of Jittering, if you make it 1-6cm smaller you will begin to noclip and the fps player will die
    step height = 57cm
    Slope = 45degrees
    While Crouching toggled
    shortest covered area = 120cm y
    Narrowest corridor =80cm width[adjusted ]*hella floating point issues
    step height = 8 cm *SERIOUSLY!?
    slope angle = 45degrees *FLOATING POINT ISSUES AHOY. You will have issues the further away from origin (0,0,0) you are
    *note if you start from flat ground while crouching and go up a slope while crouching , you will slide back once you stop going forward [bug]
     
    Now that we have learned some things about Leadwerks what do we do with it? Interpret, Extrapolate, Interpolate , and Implement!
     
    I think we have all seen the guidelines that recommend a 256x256cm wall is a perfect fit. Its completely fine if your game doesn't have any jumping in it or it is severely restricted. I know that the player will be climbing over things indoors so 256cm will simply not be enough. The solution I have come up with is 320cm tall walls, with 8cm walls and 8cm ceilings. This gives us a 384cm tall block that fits perfectly in the 128cm^3 grid spacing. Now with a wall that high you can I have set the doors to be 128cm wide and 256cm tall. Because we know the problem Leadwerks has with crouching and step heights we know we need to come up with a solution be it putting ramps (visible or not) in the door or adjust the fps controller by code to check for ledges while crouched.
     
    Keeping the default fpsplayer height of 1.8meters (5foot, 9inches) I have set the counter and tables to be 80cm tall. Windows are 80cm from the floor and have a height of 176cm. The heigt allows you to easily jump out the window while crouched without encountering weird physics behaviour.
     
    With these standards set I can make assets that can be swapped in and out with very little issues.
     
    Nice pretty tabular format :
     

  3. Einlander
    I've been lots of programming, mostly small stuff that when joined together will present the player with a better playing experience. Sadly I don't really have much to actually show currently, but in the coming weeks time provided i should be able to go down my list of to-do's
     
    I DO have a video where I show my new test level that can be used as a playground to test all sorts of scripts and game mechanics. I also talk about what next I plan to implement.
     


    .
  4. Einlander
    Not much to say in this blog post, but I've had a very eventful past 2 days with coding and level design.
     
    First I created a comprehensive test level that allows me to test almost every aspect of what a person would have in an fps. There are is a rifle range, areas to test line of sight / AI evasion, falling deaths and a super short goal oriented map section.
     
    I have also started creating my own FPS controller. This controller is being designed so the controller can relinquish it's control to another entity allowing a ladder entity to take over keyboard input or a turret to control what you see and movement range. This will enable game play similar to other standard engines.
     
    Work has began on companion AI such as you would find on Left 4 Dead 2, all it does so far is follow you. Eventually it will have the ability to find ammo and weapons on it's own, attack enemies independently, manage it's health and heal you and pick you up if you get incapacitated.
     
    Finally I have managed to abstract the key configs away from the fps controller file and into it's own script. I can from anywhere use keybind.forward and not worry about what the actual keys are and just worry about the game logic. The keybind system also is able to save and load from a file. If the file doesn't exist the file will be created.
     
    Spurring all this development is a game idea that I plan to put on the game player. It is based of the Left 4 Dead Custom Map, Questionable Ethics. Stay tuned for more developments.
     
     

  5. Einlander
    While crawling around on the internet I found this video
    the relevant part starts at 3:36. 
    Realtime level updates are something many engines have, but since I'm not using those engines it never was something on the forefront of my mind. After watching the video I wondered how close I could get to implementing something like that in Leadwerks. The solution I came up with is brain-dead simple. I load a level and a camera, and after a time limit reload the level and place the camera where it was.
     


     
    This is video basically shows what I created. If someone was feeling very ambitious they could probably write a script that will reload each model without reloading the level, but I have a feeling it will break many of things.
     
    in game auto update.lua
     
    Image of it in action
     

  6. Einlander
    It's been a while since I last posted an update on my lua based GUI. That was the second time that I have rewrote it. Now I'm on my third rewrite. This time the reason is that I am using the Lua OOP module Averice has made available. My GUI was already object oriented but it was messy to code. Now it looks sensible and has much less code.
     
    I have no pretty images to show but I will detail some of the major structural changes and concepts that i have employed.
     
    I no longer use the require keyword. I use the import command now since it plays better with the lua sandbox and can be used in the workshop games
     
    Window Manager Changes

    If you have followed the development of this gui, you may already know that there is a window manager that controls all the states of the windows. This was so that programmers can have multiple window managers that have different interfaces (think game menu gui, and in-game computer interfaces). Now there a window manager manager (collect all the things!). This allows the programmer to have a system that will manager and update all of the window managers autonomously if they so choose.  
    Drawing

    Before, each component (windows, buttons, etc..), did their own drawing. This was fine for the most part, but this limited me to the Leadwerks line and box command. Now I use 2d polygons to allow me to draw whatever shape I want to. There is an almost negligible performance hit, since it has to process the shape and scan-line draw the image. This will also allow me to use the point in polygon algorithm to select items, creating the possibility of selecting non square objects with the mouse.  
    Abstraction

    Along with changing the drawing, I have abstracted all drawing to a single class. This class contains all the drawing and text commands that the gui uses. This makes the gui more portable and if Leadwerks changes something there will only be one location to change them instead of multiple places.  
    The rewrite should take substantially less time, and with the new class system adding components should be easier and faster.
  7. Einlander
    I've been working on my game tournament entry for a few weeks. I've had to scrap entire levels multiple times but I think I finally have something that i'll be happy with. Now that my work schedule has changed I doubt i'll have much time to work on my game as I would like.
     
    Not much to do but show you the pictures.
    *All models are made by me except for the tree and flowers (they're in the workshop). Textures are from or modified from cgtextures and plaintextures.
     
    I placed them all into an imgur album because uploading them one by one is tedious.
     
    link http://imgur.com/a/XquG3
    The imgur link is annotated.
     










  8. Einlander
    Random Bablings About the Project I'm Working On
     
     
    The Journey Here
    Ever since I bought Leadwerks I have been making the same game. It's games objective has morphed many times since. It started out as a stand clone of a survival mode mod for Left 4 Dead 2. The players would be stuck in a secluded area with no way to escape. Zombies would come in waves and the player would be able to fortify their location. As time went on these locations became bigger and bigger. I started to have levels with multiple city blocks where all the houses were enter-able and complete malls with articulated stores. I even have a screenshot on Steam of an apartment complex where each room was open to the player.
     
    Eventually I got to a point where I has a rather large open world level. At this point I decided it would be better to remove the overarching plot about being rescued and make it a game about world discovery. Instead of building it by hand I decided all buildings and locations would be dynamic. This is where all the real work began.
     
    Starting Small
    What I'm working on is now a cross between multiple games. I wanted to have the open world of Dayz, the gameplay mechanics of Left 4 Dead 2 with its claustrophobic closeness of a metropolitan city, and the world generation of 7 Days to Die.
     
    BUILD ALL THE THINGS!!!! o/
    This was almost my first mistake. I almost started creating the world generator, and building generator at the same time. While at work with the composition book with graphing paper I carry for game ideas I figured out exactly how EVERYTHING interacts in the world. Here I decided I would start and finish the building generator.
     
    BSP Trees
    In order to make a building dynamically one would need to tell the computer how to build it. A template of some sort. One that would adapt to the size of the building. I decided the best way to do this is to define the dimensions of a building and section off each room. To do this I decided to use a bsp tree. I am bad at 2 things when it comes to computers, math and linked lists. Guess what, a bsp tree is almost exactly these 2 things. I ether split a room vertically or horizontally, no diagonals as to preserve my sanity. So far you tell the generator the 2d dimensions of the building. Then you tell it what percent of the floor space you want to claim. After you claim it, you name the floor-space. So far I have this accomplished. I can build the floor and set up the walls. Now what I need to do is make it figure out where doors and windows go, aka portals. Another gotcha that will need to be worked around is since the generator uses percentages you cant have a static width hallway, you would need to tell it something like 1% and it would attempt to use the least amount of space unless the building is HUGE.
     




    These nodes wont split themselves!


    Editing In the Editor
    Not much to say here other than it's hard. It's hard to change something that creates itself.
     
     




    What you see isn't exactly what you get.


     
    Results so far:
     
     
     




    Look at those beautiful rooms.






    This time with shadows.


     
    HUGE GOTCHAS
    It took me way too long to figure this out. Even though all the prefabs being used are instanced, each building isn't. Even if the building is identical en every way since it's being created and not loaded it's different. Each additional building after a certain number causes a devastating fps drop. I debug my game with vsync on to let me see what people with less capable cards are seeing. This sudden fps drop can cause you to watch the engine redraw the world allowing you to see behind walls.
     
     
     
    What I have left:
    Basically EVERYTHING.
    Player State
    Inventotry Managment
    Npc Managment
    Prop/Entity Management
    World State Saving, Streaming, and Moving
    World Generation (streets blocks)
    Building Generation (building styles, building prop spawning)
    Entity view state determination (things behind you are not drawn, things inside buildings aren't drawn)
     
    Useful Links:
    http://lua-users.org/wiki/TableSerialization
    PHP-like print_r
    This has examples of how to print all the contents of a table regardless of how many items it holds nor how deep it is. I used the PHP-like print_r function. If you store all your settings into a table you can use this to print it to a file and then later directly load it.
     
    http://lua-users.org/wiki/CopyTable
    DeepCopy
    Somtimes you want to lua to treat tables BY VALUE instead of BY REFRENCE so by using deepcopy you can clone a table and not have the original table change when you change the copied table
     
    edit:
    http://snippets.luacode.org/?p=snippets/Deep_copy_of_a_Lua_Table_2
    Alternate version of deepcopy. The above version seems to choke on super complex tables with functions in them. HEED ITS LISCENCE (MIT/X11)
  9. Einlander
    Gui's at the moment seem to be all the rage on the Leadwerks forum. We have the recent release of the noesisGUI, Patrik's showing of his gui's progress, and tjheldna's release of tjui and probaly many others. I also decided to try my hand at gui creation.
     
    Coming from a BASIC background (started with qb 1.0), I don't have the proper skills to use a third party gui without malloc errors or segfaulting everything. That, and my game is a lua game. Taking inspiration from Tjhldna's gui I started off making something similar in pure lua.
     
    After 2 days I managed to create a window manager and the windows themselves.
     
    It's a good start but a lot of things still need to be worked out.
     

    !!ANIMATED, CLICK TO VIEW!!
     
     
    Frontfacing code to make the demo:

    function Script:Start() -- Load Module lwgui = require "/scripts/lwgui" --Create Window Manger self.windowmanager = lwgui.WindowManager() --Create Windows self.window1 = lwgui.Window(200,200,300,300,windowcallback) -- window1 callback self.window2 = lwgui.Window(280,200,300,300) self.window3 = lwgui.Window(480,180,300,300) -- make the window see through --self.window.SetTransparancy(100) self.window2.SetTransparancy(100) --self.window3.SetTransparancy(100) --self.window.SetCallback(windowcallback) -- you can manually set a callback self.window1.SetTitle("Einlanders' Leadwerks Gui Window") self.window2.SetTitle("Einlanders' Leadwerks Gui WIndow 2") self.window3.SetTitle("Einlanders' Leadwerks Gui WIndow 2") -- set window color self.window2.SetWindowBodyColor({0,0,255}) self.window3.SetWindowBodyColor({0,30,0}) --Add Window To Window Manager self.windowmanager:AddWindow(self.window2)-- type checked self.windowmanager:AddWindow(self.window1)-- type checked self.windowmanager:AddWindow(self.window3)-- type checked --self.window.testwm() end function Script:UpdateWorld() -- update title self.window1.SetTitle(self.window1.GetX()..":"..self.window1.GetY().." Einlanders' Leadwerks Gui Window:"..self.window1.GetDepth()) self.window2.SetTitle(self.window2.GetX()..":"..self.window2.GetY().." Einlanders' Leadwerks Gui WIndow 2:"..self.window2.GetDepth()) self.window3.SetTitle(self.window3.GetX()..":"..self.window3.GetY().." Einlanders' Leadwerks Gui WIndow 2:"..self.window3.GetDepth()) local window = Window:GetCurrent() -- remove a window if window:KeyHit(Key.Q) then self.windowmanager:RemoveWindow(self.window1)-- type checked self.window1 = nil collectgarbage() end end --This function will be called after the world is rendered, before the screen is refreshed. --Use this to perform any 2D drawing you want the entity to display. function Script:PostRender(context) --process all logic inside the windows and window manager self.windowmanager.Process() -- Render all windows self.windowmanager.Render() end function windowcallback(e) -- window 1 callback System:Print(e[1]) end
  10. Einlander
    Ladders, Some people like them, some people don't. I like them, but I don't like making them. I just spent 9 straight hours after work to get the semblance of a half working ladder. The challenges were mind boggling for my sleep addled brain.
     
    I initially started a few days ago. I wanted ladders for the game I had planned. Specifically with functionality similar to Counterstrike: Source and Left 4 Dead. So being the lazy good dev I am, I went to Youtube to see how people using Unity were accomplishing it. The first immediate thing I noticed was that they all used triggers/colliders to accomplish this goal. They used 3 features of their trigger/collider: OnEnter, OnStay, and OnExit.
     
    I was shown a script where all of the actions were implemented, but I realized from the time I spent making sourcemod scripts that I would need to control every entity that touched my trigger, especially if I ever did multi-player. So I wrote a heavily modified collision trigger. OnEnter was not that hard, all that was is the very first instance that an entity collided with the trigger I call a function once, and add it to a list so it would not be called again. OnStay is just a duplicate of the Collision function in Leadwerks. OnExit was the spawn of satan. On exit tells you when an entity leaves the trigger. Well in Leadwerks when something leaves a trigger it's gone. You can have a list of entites that you populated but since the collision trigger can't tell you whats missing the list becomes useless. So I ended up creating a a list paging system in order to track what entity has left.
     
    So I created 2 lists: old and new
    and a timer : Timetillupdate
     
    When an entity collides for the first time I set it's state to onenter.
    When it collides a second time i change it's state to onstay
     
    when timetillupdate runs out i check the old list against the new. If there is something missing in the new list, i set that entity to onexit. Then i page the new list into the old list, then empty the old
     
    Seems simple enough, but it's my first time doing this, and Leadwerks is my first game engine where I have coded anything of note, so I probably went the long way round, and messed something up, nevertheless it functioned properly.
     
    Now the ladder. After watching about 3 videos on YouTube,
    This one showed that once you enter the trigger, you takeover the controls then transform the player up the ladder, simple enough. In Leadwerks I used translate to move the player up the ladder. It mostly worked, except that the player couldnt get to the top of the platform. After all sorts of unholy buggery I settled for a dirty trick I read a few places. When they enter the ladder zone, turn off the players gravity, when they get off the ladder, turn it back on. This solved my ladder issue for the most part. 
    When I get more time/experience I will fix the ladder so there are no gravity tricks,and the player can be able to stop mid climb and not slide back down. Or I could simply cop out and force people to press the use button to mount the ladder, and press use again to dismount.
     
    Here is the result of my sleepless night:
     


  11. Einlander
    This post was inspired by this forum thread http://www.leadwerks.com/werkspace/topic/8942-keys-customisation-shortcut/ by YouGroove
     
    A little background of how a concocted this solution. I run a bunch of Left 4 Dead 2 servers and I make mods for them using sourcemod. I find myself having to make special keyconfigs when administrating or adding stuff to the levels. In the process you find out that all actions in the source engine are abstracted. So I adapted that to Leadwerks.
     
    When most people program they hard code values for input for thier games. This leads to easy development but later they come up with odd solutions to solve the lack of configuration flexibility.
     
    [Abstraction]
    Some game engines have most everything abstracted away. They refer to animations by name instead of frame range (playercrouch vs playanimtionframes[1,200]) , game events by name instead of number ("hunterpouncebegin" vs action 12345) and player input by name instead of of keycode (player_jump vs Key.Space).
     
    The developer defines all the possible input the player can take and gives them a name. Then they apply a keycode to the name. This method allows them to change the actions value at anytime they choose.
     
    Psudeocode:

    Dim Player_Action_Jump as integer 'Create action Player_Action_Jump = Keys.Space 'assign keycode to action If ME.Keydown = Player_Action_Jump then 'detect if the action was taken Jump() ' do something End If
    Please excuse the vb.net code thats what i'm most use to
     
    So now Applying it to Leadwerks:
     
    [Application]
    We will be using the Fpsplayer.lua script and another script that we create.
     
    First we Figure out what key inputs the script takes, and that would be:
     

    Forward Backwards Strafe Left Strafe Right Jump Flashlight Use Reload Crouch -- this one is comented out but I included it anyway Run
     
    Taking this list of actions we create another script that will hold all the actions and key configs.
     

    Script.L_Forward Script.L_Backwards Script.L_StrafeLeft Script.L_StrafeRight Script.L_Jump Script.L_Flashlight Script.L_Use Script.L_Reload Script.L_Crouch Script.L_Run
     
    The first thing I did was make them all string inputs. But soon I discovered that you couldn't write a shift in an input box, and space would confuse someone. So I made them each a drop down box where you can select the key.
     

    Script.L_Forward =22 --choice "Forward" "UNASSIGNED,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,NUMPAD0,NUMPAD1,NUMPAD2,NUMPAD3,NUMPAD4,NUMPAD5,NUMPAD6,NUMPAD7,NUMPAD8,NUMPAD9,NUMPADPERIOD,NUMPADDIVIDE,NUMPADMULTIPLY,NUMPADSUBTRACT,NUMPADADDITION,BACKSPACE,CAPSLOCK,LCONTROL,DELETE,DOWN,END,ENTER,HOME,INSERT,LEFT,NUMLOCK,PAGEDOWN,PAGEUP,RCONTROL,RIGHT,SHIFT,SPACE,SUBTRACT,TAB,UP,EQUALS,OPENBRACKET,BACKSLASH,SEMICOLON,QUOTES,COMMA,SLASH,PERIOD"
     
    I had to look all the keys up and then write them all down and make sure i didn't misspell any of them. Also I had to remove some keys from the list -- tilda[~] escape [esc] and the windows key --.
     

     
    Now that you have the selectors for the keys you need to assign the keycode to a global action variable.
     
     
    NOTE: lua does not have select case switches
     

    function Script:Start() -- Assign key values to standard movement globals --LW_ stands for Leadwerks or local world LW_Forward =self:AssignKeyFromChoice(self.L_Forward) LW_Backwards =self:AssignKeyFromChoice(self.L_Backwards) LW_StrafeLeft =self:AssignKeyFromChoice(self.L_StrafeLeft) LW_StrafeRight =self:AssignKeyFromChoice(self.L_StrafeRight) LW_Jump =self:AssignKeyFromChoice(self.L_Jump) LW_Flashlight =self:AssignKeyFromChoice(self.L_Flashlight) LW_Use =self:AssignKeyFromChoice(self.L_Use) LW_Reload =self:AssignKeyFromChoice(self.L_Reload) LW_Crouch =self:AssignKeyFromChoice(self.L_Crouch) LW_Run =self:AssignKeyFromChoice(self.L_Run) -- More standard key binds will be added later end function Script:AssignKeyFromChoice(KeyAsChoice) -- Looked it up, Lua DOES NOT have select case if KeyAsChoice ==0 then return 0 end if KeyAsChoice ==1 then return Key.A end if KeyAsChoice ==2 then return Key.B end if KeyAsChoice ==3 then return Key.C end if KeyAsChoice ==4 then return Key.D end if KeyAsChoice ==5 then return Key.E end if KeyAsChoice ==6 then return Key.F end if KeyAsChoice ==7 then return Key.G end if KeyAsChoice ==8 then return Key.H end if KeyAsChoice ==9 then return Key.I end : :Rest of code : end
     
    That's the code that handles user input. Make a pivot in the level then attach the script to it.
     
    Now this part is simple
     
    Go through the fps player script and change all the keycodes to your actions
     

    if self.weapon~=nil then if window:KeyHit(Key.R) then self.weapon:Reload() end end BECOMES: if self.weapon~=nil then if window:KeyHit(LW_Reload) then self.weapon:Reload() end end
     
    And so on.
     
    Now you can change any of the keys to what to what you want at anytime
     
    The only shortcomings is this does not support mouse commands. In a future version I might be able to write an input function that reads both the mouse and keyboard commands.
     
    Edit:
    Here Is this idea in action. The Fps player is modified to look for a variable containing the keycodes, and the other script holds the keycodes and lets you change them
     
    http://www.leadwerks.com/werkspace/files/file/515-key-config-host/
  12. Einlander
    Tonight I did some more modeling and discovered that sandbags and sandbag walls and bunkers are hella hard! Sandbags will either have to wait for a version 2.0 release of the pack or be on hold indefinitely .
     
    I also did some learning for the sake of learning. The topic: Lua JIT. There was a lua jit in Leadwerks 3.0 but I never braved it. In Leadwerks 3.1 it has been advertised that it has a jit compiler. So being the curious person that I am I decided to read up on it. Upon further research I discovered the LuaJIT FFI Extension (http://luajit.org/ext_ffi.html). This allows you to directly call C functions and data structures from lua. This is very useful to me because I'm not as familiar with C/C++ than I would like to be, but would allow me to still use some C functions from relative safety.
     
    Through a bunch of trial and error I was able to successfully load the Enet library into the my game using the luajit commands. I need to do more experimenting to make the loading of the library simpler and make a simple way to sync the entitys in the game.
     
    To the curious more reading: (i'm going to bed soon so i cant go into much detail )
     
    http://luajit.org/extensions.html Learn about the luajit and how to use C commands.
     
    http://wiki.luajit.org/FFI-Bindings List of luajit-bindings HEAD THE NOTE AT THE TOP!
     
    https://github.com/ColonelThirtyTwo/luajit-ffi-enet The luajit Enit Binding
     
    https://github.com/lsalzman/enet The enet repo, if you want to go the easy way, install codeblocks and open the .cbp with it and compile
     
    after you make the dll
    look through this repo for examples https://github.com/arch-jslin/mysandbox/tree/master/lua
     
    follow this example specificaly https://github.com/arch-jslin/mysandbox/blob/master/lua/enet1.lua
     
    Almost most there!
     
    Now i was not able to run that last example as is, i had to do some shortcuts:
     
    I put this all in function App:Start()
     

    local ffi = require 'ffi' local enet = ffi.load[[enet\libenet]]
     
    !!!HERE IS WHERE I HAD PROBLEMS!!!
    i was not able to get this line:
    ffi.cdef( io.open([[enet\ffi_enet.h]]):read('*a')
    to work. so what i did was opened the file, copied everything from ffi_enet.h except for the first return and pasted it between these blocks of code.
     
    it should look like:
     
     

    ffi.cdef[[ static const int ENET_VERSION_MAJOR = 1; static const int ENET_VERSION_MINOR = 3; static const int ENET_VERSION_PATCH = 4; : :the rest of the code : extern size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t); extern size_t enet_protocol_command_size (enet_uint8); ]]
     
     
     

    if enet.enet_initialize() ~= 0 then Debug:Error("An error occurred while initializing ENet.") end local addr = ffi.new("ENetAddress[1]") addr[0].host = enet.ENET_HOST_ANY addr[0].port = 12345 local serv = enet.enet_host_create(addr, 32, 2, 0, 0) if tonumber(ffi.cast("int", serv)) == 0 then Debug:Error("An error occurred while trying to create the host.\n") end
    *io.stderr turns to Debug:Error, and we remove os.exit(1) entierly (if there is an error, check your debug console!)
     
    This will create a host server and the windows firewall thing will popup asking for permission
     

    enet.enet_deinitialize()
     
    This is how you close enet when your game ends. Is there an app:end() that we can use? it would be nice to use for cleanup.
  13. Einlander
    Got off work a few hours ago and decided that tonight would be a good time to have some insomnia. Fueled by caffeine I decided that i should model more assets for people to use. Last time the theme was health items. Avid players of Left 4 Dead 1/2 will notice I modeled my own imaginings of the Left 4 Dead health items and threw in a first aid box .
     




    [modeled and rendered in
    Anim8or]

     
    This time I set the theme as barriers and barricades. I spent a few hours modeling a few items. At the beginning I fought the good fight of low polygon models, but near the end I lost that fight. After loading up Valves Hammer Editor and comparing the poly-count of their models versus mine, I found that their models are easily double the polygon count of any of my models. I will do some more barricades and barriers over the next few days, and on the weekend I will try to do all the textures and upload the pack.
     

    [MOTIVATIONS]


    Some may wonder why I'm doing this anyway. To that i have 2 answers. Firstly, I have no idea what I actually want to do with the Leadwerks Engine. I have a vague idea of what I want to do but then I end up with the issue of not having the proper art assets to populate the level. Second, this is exactly what I would want someone to do for me if I was a complete noob and game making. With enough items a person can essentially play house or lets pretend in the engine. From there they can tell a story with what they created without having to creat absolutly everything. Bonus answer, it makes Leadwerks look good. When people ask if Leadwerks have assets, you can point to the download section and tell them to down load certain packs and they tell their friends to look at what they made and bring more people to the community.
     

    [RANDOM MUSINGS AND INSIGHT]



    Too Long; Don't Read. Seriously TL;DR


     
    An interesting thing that I learned while looking at the Valve models was that most objects that are not not super low poly have a simplified low-poly version of of the model for physics. This is different than what i do. Normally just make a convex shell, mesh physics, or what i did in the last pack: take the model, put it inside a primitive csg that closest fit it's shape.
     
    I started thinking about why this would be. It didn't take very long for me to figure out why this was. The main thing that I realized was that the Source Engine is mainly used for shooters taking place in real life or future settings. We have Counter Strike: 1.6, Source,Go, Team Fortress: 1&2, Half Life: All Episodes, Left 4 Dead 1&2 , Sin Episodes:Emergence and Titanfall. All of them are shooters at the core, regardless of the goals in the game. A few notable exceptions are Portal, and Vindictus. Those are not exactly twitch based games. When you have so many shooter games out for a single engine, and many of them played competitively, every shot counts. And when every shot counts, every collision counts. There are an astonishing many models that have open spaces that you can see through. Since you can see through them you would expect you can shoot through the open areas, and you can leading to the simplified models for collision.
     
    A mesh based physics in Leadwerks would work, but it uses the models mesh as the base and some meshes when you use them as a physics base will noticeably slow down your game. So, unless you do some physics file slight of hand (create a physics file from a low poly mesh, and apply the file to the higher poly version), the method Valve uses is not an easy approach. Thank god for prefabs. If some kind soul (read: someone else, that's not me), does this once, others wouldn't have to. Who knows. Leadwerks 3.1 is still young. Maybe in the future there will be lua/c++ based add-ons that can help automate this process for you.
     
    TL;DR: Be careful when you make physics files or objects for your game. Someone might want to shoot through obvious holes in your model, if they cant, rage quits may ensue.
     
     
    If you read through all this rambling, give yourself a pat on the back, you deserve it! Next post I don't thing I will have as much to say.
  14. Einlander
    I have recently been devoting increasing amounts of my free time prototyping things on Leadwerks. The one thing that i have constantly found sorely lacking is the absence of 3d assets that are ready to drop in and use. Lacking the funds at hand to go buy model packs. I thought I would try my hand at creating some.
     




    Not bad if i do say so myself.


     
    Modeling objects In my opinion is the easiest part of everything. Its the texturing that can be a [insert deity here] [insert explication here] pain. You need to unwrap the model. Then you have to find the textures on the internet or create them yourself. If you find them on the internet or use a tool to make them you have to read the license so sometime in the future someone isn't knocking on your door asking for your paycheck because you ripped them off on accident. Then, you need to get the textures to fit on your uvmap, create your normal/specular/height/displacement/ambient occlusion/self illumination textures, then finally combine them into a material. It's a pain, but someone has to do it. Now i know why model packs cost so much.
     
    ......So my computer blue-screened and lost over HALF of my post, so i will finish the rest in the next blog post
  15. Einlander
    Lets Try Again
    A few months ago I started making a Lua based GUI system. It was going well until life happened. This last week I attempted to add more features to it so I could use it in my Halloween contest entry. Knowing more lua now than I did then I realized how much of a mess it was. I scrapped the gui completely and started over. The following is some technical changes and observations I made as I rewrote it. Hopefully someone on the internet finds it insightful.
     
    The first thing I tackled was the way the window manager handled windows. Previously, the window manager held all the windows and dealt with the window Z order. When moving a window, the old system told which window was on top and and allowed the window to move itself. Now I have the window manager handle moving the window and added the ability to for a window to know if it is focused, and a send window bottom function so if a person is using the top window a new window wouldn't take over.
     
    Another change that was of high importance was how objects were selected. Before all objects were bounding boxes, all objects were square, this limited what could be created with the gui. In it's place all square objects generate a 2d convex polygon and the polygon is used for selection. This change was important because it now allows users to pass polygons for buttons and the gui system will automatically adjust to it. Still to be done is a 2d polygon fill algorithm (I'm wondrously bad at math).
     
    The biggest change was done the last 2 days. I created a text placement system. It has alot of features and a few more to come. The placement system will place text in a bounding box at a location you specify. It will also line wrap, though it doesn't do a word wrap (I'll get to it one of these days...maybe). I also implemented an inline markup system. So far it supports 2 commands:

    ##color:r:g:b## ##linebreak##
     
    There is a ##fontsize:size## command but I have not finished adding the required font handling system. The user can write a string "This Will Show##linebreak##On 3 lines##linebreak####color:255:0:0##This text is Red", and it will draw it in 3 lines and change the color on the last line. You can also change color mid letter.
     
    Performance and Optimizations:
    The old system was hella fast, despite it being held together by duct tape. This one at first was on the slow side. The window movement was slow but I discovered that was due to the window manager looking every update for which window was on top, if it was focused, and if the mouse was down. This was optimized my allowing it to make the assumption that if a window is focused, check to see if it's isbeingdragged property is true and if so continue with the mouse move. The old system the window took control of it'self and released control when it was done.
     
    The text placement engine almost made me punch my monitor. I stared so long at this code I thought I was mad. At first it drew every letter one by one to make sure the color feature worked properly (sudden color changes mid-word) but that was such a performance hit it couldn't be ignored. It could take a game running at 60fps vsync on and bring it down to 30fps. The change that I made was to buffer all the text into a string and blast it out at the end of a line. If there was a color change, I would write all changes to the screen, and start a new string buffer with the new color. This brought the fps back to almost 60fps with windows being displayed in a 3d scene.
     
    Next thing that I will implement are buttons and from there I will implement clickable objects that don't require text input.
     
    For the Curious
    The Gui System is made of 3 parts. the window manager, the window, and what you put in the window. so it would be
     
    Window Manager(contains a collection of) - > Windows (containt a collection of) - > objects (which can contain other objects)
     
    To use the gui system you would use the code:
     

    function Script:Start() self.gui = require "/scripts/gui/simplegui" -- load the gui script
    self.winman = self.gui.windowmanager() -- create the window manager
    self.testwindow = self.gui.window() -- create a window
    self.winman.addwindow(self.testwindow) -- add window to the window manager
    end
    function Script:PostRender(context)
    self.winman.process() -- this can go into update world if you want
    self.winman.render() -- draws everything
    end

     
     
    This code would better be served if it was used in the app.lua so you have one window manager that will survive level loads (useful if you have create a console window or a debug panel).
     
     


    No fancy animated image this time. The button doesn't work yet and the newest creation is the colored text to the left. The top 2 windows are transparent.


     
     
    Well enough of my rambling. It's late, I've spent all day doing laundry, no sleep, and i need to be at work in 5 hours.
×
×
  • Create New...