
thehankinator
Members-
Posts
436 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by thehankinator
-
I am using the models from the Humble Bundle, the bird in specific, just to figure out the process of how I would get them into LE.
-
I am able to open the model itself but the model doesn't contain the animations, those are in a separate .ma file.
-
The animations are in .ma format, anyone know how to convert that into something useful?
-
Hidden cameras do not render a scene. If you hide the player player camera and show your cutscene camera there may not be a need to use the render target.
-
Try calling Follow() only once. I think the intended use is to call Follow() to start the following, then only call it again if you change what the entity is following.
-
I've had the same problem with Follow(), I can't remember what I had done to fix it... or if I fixed it at all. Two things stick out in my mind, 1) What does Follow() do when the player is suddenly unreachable? Like if they jumped onto a platform that the navmesh doesn't connect to. 2) Is your script continuously calling Follow()? It'd be nice if the Navigation API had a function like IsFollowing() so that you could detect when the path failed for some reason.
-
I am pretty sure GetDistance() only takes into account the position of the 2 entities, ignores everything else. I think under the hood GetDistance is doing the same thing as: (entity1:GetPosition(true) - entity2:GetPosition(true)):Length()
-
This is with the game(MyGame.exe) not the editor.
-
Usually pegged at 60fps on my system, couple drops but those were pretty rare. Win 10, R9 380, Driver version 16.3.2
-
I was trying to run a LE game("MyGame" with no modifications to start.map, NOT the editor) through gDebugger and I saw a bunch of errors concerning the function pointers for various functions. The error indicates that the function pointers are being setup for context #1 but not updated for context 2-4. There is a post with a pretty good explanation for what's going on and when it's important(below). gDebugger crashes when building up the shader program which is weird, but be related to the function pointers. Should be fixed regardless. gDebugger and MyGame.exe log below. Also, why are 4 contexts created(first 3 destroyed)? This issue may go away if only one was created. http://stackoverflow.com/questions/9663262/resetting-opengl-extension-pointers-in-windows-api Thread Created: 9964 DLL Loaded: C:\Windows\SysWOW64\ntdll.dll DLL Loaded: C:\Windows\SysWOW64\kernel32.dll DLL Loaded: C:\Windows\SysWOW64\KernelBase.dll Thread Created: 9388 Thread Created: 10420 DLL Loaded: C:\Windows\SysWOW64\ws2_32.dll Thread Created: 472 DLL Loaded: C:\Users\username\Documents\Leadwerks\Projects\MyGame\steam_api.dll DLL Loaded: C:\Windows\SysWOW64\sechost.dll DLL Loaded: C:\Users\username\Documents\Leadwerks\Projects\MyGame\lua51.dll DLL Loaded: C:\Windows\SysWOW64\advapi32.dll DLL Loaded: C:\Windows\SysWOW64\OpenAL32.dll DLL Loaded: C:\Windows\SysWOW64\rpcrt4.dll DLL Loaded: C:\Windows\SysWOW64\msvcrt.dll DLL Loaded: C:\Windows\SysWOW64\msvcr100.dll DLL Loaded: C:\Windows\SysWOW64\sspicli.dll DLL Loaded: C:\Windows\SysWOW64\shell32.dll DLL Loaded: C:\Windows\SysWOW64\cryptbase.dll DLL Loaded: C:\Windows\SysWOW64\windows.storage.dll DLL Loaded: C:\Windows\SysWOW64\bcryptprimitives.dll DLL Loaded: C:\Windows\SysWOW64\combase.dll DLL Loaded: C:\Windows\SysWOW64\nsi.dll DLL Loaded: C:\Windows\SysWOW64\shlwapi.dll DLL Loaded: C:\Windows\SysWOW64\psapi.dll DLL Loaded: C:\Windows\SysWOW64\winmm.dll DLL Loaded: C:\Windows\SysWOW64\user32.dll DLL Loaded: C:\Windows\SysWOW64\gdi32.dll DLL Loaded: C:\Program Files\AMD\AMD gDEBugger\spies\opengl32.dll DLL Loaded: C:\Windows\SysWOW64\kernel.appcore.dll DLL Loaded: C:\Windows\SysWOW64\winmmbase.dll DLL Loaded: C:\Windows\SysWOW64\winmmbase.dll DLL Loaded: C:\Windows\SysWOW64\SHCore.dll DLL Loaded: C:\Windows\SysWOW64\ole32.dll DLL Loaded: C:\Windows\SysWOW64\cfgmgr32.dll DLL Loaded: C:\Windows\SysWOW64\powrprof.dll DLL Loaded: C:\Windows\SysWOW64\profapi.dll DLL Loaded: C:\Windows\SysWOW64\ddraw.dll DLL Unloaded: C:\Windows\SysWOW64\winmmbase.dll DLL Loaded: C:\Program Files\AMD\AMD gDEBugger\GRBaseTools.dll DLL Loaded: C:\Program Files\AMD\AMD gDEBugger\GROSWrappers.dll DLL Loaded: C:\Windows\SysWOW64\oleaut32.dll DLL Loaded: C:\Program Files\AMD\AMD gDEBugger\GRApiClasses.dll DLL Loaded: C:\Program Files\AMD\AMD gDEBugger\GRSpiesUtilities.dll DLL Loaded: C:\Windows\SysWOW64\msvcp100.dll DLL Loaded: C:\Windows\SysWOW64\devobj.dll DLL Loaded: C:\Windows\SysWOW64\dciman32.dll DLL Loaded: C:\Windows\SysWOW64\version.dll DLL Loaded: C:\Windows\SysWOW64\dbghelp.dll DLL Loaded: C:\Windows\SysWOW64\imm32.dll DLL Loaded: C:\Windows\SysWOW64\msctf.dll API Connection Established: gDEBugger Servers Manager Thread Created: 10464 Process Run Started Thread Created: 10444 Thread Terminated: 10444 DLL Loaded: C:\Windows\SysWOW64\mswsock.dll DLL Loaded: C:\Program Files (x86)\Steam\steamclient.dll DLL Loaded: C:\Windows\SysWOW64\crypt32.dll DLL Loaded: C:\Windows\SysWOW64\msasn1.dll DLL Loaded: C:\Windows\SysWOW64\imagehlp.dll DLL Loaded: C:\Windows\SysWOW64\setupapi.dll DLL Loaded: C:\Windows\SysWOW64\IPHLPAPI.DLL DLL Loaded: C:\Program Files (x86)\Steam\tier0_s.dll DLL Loaded: C:\Windows\SysWOW64\winnsi.dll DLL Loaded: C:\Program Files (x86)\Steam\vstdlib_s.dll DLL Loaded: C:\Windows\SysWOW64\secur32.dll DLL Loaded: C:\Windows\SysWOW64\cryptsp.dll DLL Loaded: C:\Windows\SysWOW64\bcrypt.dll DLL Loaded: C:\Windows\SysWOW64\rsaenh.dll DLL Loaded: C:\Program Files (x86)\Steam\Steam.dll DLL Loaded: C:\Program Files (x86)\Steam\Steam2.dll Thread Created: 7524 Thread Terminated: 7524 Thread Created: 6964 DLL Loaded: C:\Windows\SysWOW64\dbgcore.dll DLL Loaded: C:\Program Files (x86)\Steam\CSERHelper.dll Thread Terminated: 6964 DLL Loaded: C:\Program Files (x86)\Steam\GameOverlayRenderer.dll DLL Loaded: C:\Windows\SysWOW64\uxtheme.dll DLL Loaded: C:\Windows\SysWOW64\dwmapi.dll DLL Loaded: C:\Windows\SysWOW64\opengl32.dll DLL Loaded: C:\Windows\SysWOW64\glu32.dll API Connection Established: gDEBugger OpenGL Server Debug String: gDEBugger OpenGL Server was initialized DLL Loaded: C:\Windows\SysWOW64\atiglpxx.dll DLL Loaded: C:\Windows\SysWOW64\atioglxx.dll DLL Loaded: C:\Windows\SysWOW64\atiadlxy.dll DLL Loaded: C:\Windows\SysWOW64\userenv.dll DLL Loaded: C:\Windows\SysWOW64\propsys.dll DLL Loaded: C:\Windows\SysWOW64\wtsapi32.dll DLL Loaded: C:\Windows\SysWOW64\wintrust.dll DLL Loaded: C:\Windows\SysWOW64\atigktxx.dll DLL Unloaded: C:\Windows\SysWOW64\atigktxx.dll DLL Loaded: C:\Windows\SysWOW64\atigktxx.dll OpenGL Render Context 1 Created OpenGL Render Context 2 Created Debug String: Detected error: The debugged process asked for an extension function pointer (glBindFramebuffer) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenBuffers) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenVertexArrays) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindVertexArray) from one render context, but called this function pointer in another render context (context #2) Checking for memory leaks - Context 1 deleted No memory leaks were found OpenGL Render Context 1 Deleted Debug String: Detected error: The debugged process asked for an extension function pointer (wglChoosePixelFormatARB) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (wglCreateContextAttribsARB) from one render context, but called this function pointer in another render context (context #2) OpenGL Render Context 3 Created Debug String: Detected error: The debugged process asked for an extension function pointer (glBindFramebuffer) from one render context, but called this function pointer in another render context (context #3) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenBuffers) from one render context, but called this function pointer in another render context (context #3) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenVertexArrays) from one render context, but called this function pointer in another render context (context #3) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindVertexArray) from one render context, but called this function pointer in another render context (context #3) Debug String: Detected error: The debugged process asked for an extension function pointer (glDeleteVertexArrays) from one render context, but called this function pointer in another render context (context #3) OpenGL Render Context 3 Deleted Debug String: Detected error: The debugged process asked for an extension function pointer (glBindBuffer) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (glBufferData) from one render context, but called this function pointer in another render context (context #2) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindBufferBase) from one render context, but called this function pointer in another render context (context #2) Thread Created: 10736 Thread Created: 11436 Debug String: Detected error: The debugged process asked for an extension function pointer (glDeleteBuffers) from one render context, but called this function pointer in another render context (context #2) OpenGL Render Context 4 Created Debug String: Detected error: The debugged process asked for an extension function pointer (glBindFramebuffer) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenBuffers) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glGenVertexArrays) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindVertexArray) from one render context, but called this function pointer in another render context (context #4) DLL Loaded: C:\Windows\SysWOW64\clbcatq.dll DLL Loaded: C:\Windows\SysWOW64\MMDevAPI.dll DLL Loaded: C:\Windows\SysWOW64\AudioSes.dll DLL Loaded: C:\Windows\SysWOW64\WinTypes.dll Thread Created: 10404 Thread Created: 7552 Debug String: Detected error: The debugged process asked for an extension function pointer (glActiveTexture) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glCreateShader) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glShaderSource) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glCompileShader) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glGetShaderiv) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glCreateProgram) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindFragDataLocation) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glBindAttribLocation) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glAttachShader) from one render context, but called this function pointer in another render context (context #4) Debug String: Detected error: The debugged process asked for an extension function pointer (glLinkProgram) from one render context, but called this function pointer in another render context (context #4) Second Chance Exception Thread Created: 4864 Thread Created: 11580 Initializing Lua... Warning: Lua sandboxing disabled. Executing file "C:/Users/username/Documents/Leadwerks/Projects/MyGame/Scripts/Error.lua" Executing file "C:/Users/username/Documents/Leadwerks/Projects/MyGame/Scripts/Main.lua" Setting breakpad minidump AppID = 480 Steam_SetMinidumpSteamID: Caching Steam ID: 76561197964459319 [API loaded no] Initializing OpenGL4 graphics driver... OpenGL version 451 GLSL version 450 Device: AMD Radeon (TM) R9 380 Series Loading map "C:/Users/username/Documents/Leadwerks/Projects/MyGame/Maps/start.map"... Loading material "C:/Users/username/Documents/Leadwerks/Projects/MyGame/materials/developer/orangegrid.mat"... Loading shader "C:/Users/username/Documents/Leadwerks/Projects/MyGame/shaders/model/diffuse.shader"...
-
I agree with Rick, learn Lua first. Even if you needed to mod the engine, a lot of your game will likely still be scripted in Lua so it is a great place to start. Personally, I've not come up with anything I needed to mod the engine for. Also working with Lua, you will learn a lot about how the engine works before diving head first into the C++.
-
When I did this for one of my games I used Collision.LineOfSight in the Pick() and set all the environment to Scene. Also, I would pass true to both GetPosition() calls, if they don't share the same parent they could be in different coordinate space.
- 3 replies
-
- 1
-
-
- Third Person
- Pick
-
(and 2 more)
Tagged with:
-
For anchor mode I don't think it'd be too hard to do that. Not sure if it'd make sense to have that feature on absolute or autoscale mode.. I'll need to think about it for a while.
-
If the group is 1024x767 units in measure, 512 is the center of the x axis so when the group is stretched out to the current resolution, it's in the middle. When you change the group to 1919x1079 units in measure the center is now around 960 of the x axis not 512, so it is on the left. When autoscale is used, the widget's position and dimensions are relative to the group's dimension. Does that make sense?
-
I got to thinking more about it and I've never liked the default_width or default_height so I decided that if a group is going to scale it's widgets it should know it's size so it can scale up when the widget is added to it. I think this should make it more clear what's actually going on. I've updated the documentation to reflect these changes. I've probably got a couple copy/paste errors somewhere so if anyone spots something weird, please let me know. I've pushed the update to steam. I've still not looked at why the positioning was wrong is different aspect ratios. Probably wont get a chance to look at that till tonight or tomorrow.
-
Hey Rick, Thanks for looking at this. I completely forgot about anchoring, luckily I was add it in by adding a mode to the CreateGroup function. Also it allowed me to add a mode for what I am calling Autoscale. This will eliminate the ridiculous amount of Rel2Abs() calls since in autoscale they will be done by the group when they widget is added to it. I just thought of a problem and that is if the same widget gets added to two different groups, that could be a problem but also not a terrible limitation so I'll leave it in for now. I'll have to take a look at why scaling/positioning are off at some of these different ratios. The result of this change (which I'll be pushing to the workshop momentarily) is that CreateGroup now has a lot more arguments. The additional arguments are only for anchoring, as mode defaults to THUI.AUTOSCALE. To Anchor a group of widgets you would do something like the pause menu below. All the contents of the JUSTIFY table within THUI are now directly in THUI, so that could be code breaking if anyone is actually using this yet. self.group = THUI:CreateGroup("pause_menu", self, THUI.ANCHOR, THUI.LEFT, THUI.MIDDLE, 200, 200) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32)) local title = THUI.Label:Create(100, 0, 0, 0, "Paused!", THUI.CENTER, THUI.TOP) title.font = title_font local button1 = THUI.Button:Create(0, 50, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(0, 150, 200, 50, "Exit") exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton)
-
Reference: This is where the majority if interesting text goes. If something up above doesn't make sense, it might be made clear in this section. THUI constants THUI.ABSOLUTE THUI.AUTOSCALE THUI.ANCHOR These values are using when creating a widget group, they will dictate the behavior of how the size and dimensions of the widgets will be modified (if at all) when added to the group. THUI.LEFT --x axis THUI.CENTER --x axis THUI.RIGHT --x axis THUI.MIDDLE --y axis THUI.TOP --y axis THUI.BOTTOM -- y axis This is used for defining how a widget is positioned via the justify flags. properties THUI.default_fg_color --Foreground color used by widgets THUI.default_bg_color --Background color used by widgets THUI.default_inactive_color --Inactive color used by widgets THUI.default_hover_color --Color used by widgets when mouse is hovering over them THUI.default_mouse_down_color --Color used by widgets when mouse is hovering over them and the left mouse button is down functions THUI:Initialize() Initializes THUI variables. Required for use. THUI:CreateGroup(name, data, mode, anchorx, anchory, width, height) name=the name of the group, this is the name you will use when you want to show this group data=this is any data you want to be able to retrieve from the group at a later time (usually with LookUpByName()) mode=this can be THUI.AUTOSCALE, THUI.ABSOLUTE, or THUI.ANCHOR. THUI.AUTOSCALE will stretch all widgets in relation to the width and height specified. THUI.ABSOLUTE will make no adjustments to the widgets dimensions. THUI.ANCHOR will utilize anchorx, anchory, width and height parameters to move the widgets to the position specified. anchorx=THUI.LEFT, THUI.CENTER, THUI.RIGHT used by THUI.AUTOSCALE anchory=THUI.MIDDLE, THUI.TOP, THUI.BOTTOM used by THUI.AUTOSCALE width=width of the widget group, this is used by THUI.AUTOSCALE and THUI.ANCHOR height=height of the widget group, this is used by THUI.AUTOSCALE and THUI.ANCHOR return=group table This function creates a group to add widgets to. THUI:Show(name) name=group or name of group If name is group, it will be shown. If name is a string, all groups with matching name will be shown. THUI:Hide() name=group or name of group If name is group, it will be hidden. If name is a string, all groups with matching name will be hidden. THUI:Update() This function should be called from Main.lua every iteration. It will redraw any widgets and also fire off any callbacks that are ready to be fired THUI:PauseGame(pause) pause=true will pause, false will resume Convenience function for pausing and resuming the game when Main.lua has required changes (see Main.lua in examples directory) THUI:GamePaused() Returns true if game is paused, false if not paused. THUI:GetFont(path, size) path=Path of the font size=Size of the font Returns a font from cache THUI:MouseOverUI() Returns true if the mouse is hovering over a widget, false otherwise THUI:Callback(func, tbl, arg) func=function to callback tbl=table the function exists in, can be nil if func is a global function arg=arg that should be used when calling the function, can be nil This function creates a callback that is used by buttons to do a task. Group properties group.update --function callback called every frame when group is active functions group:Add(widget) widget=widget to add to the group Adds a specified widget to the group. At this time the widget's position and dimensions are finalized depending on the group's mode. Label properties label.text --Text to be displayed label.font_path --Path to the font label.font_size --Font size label.img --Texture to be drawn instead of text functions THUI.Label:Create(x, y, width, height, text, justify_x, justify_y) x=x position y=y position width=width, required when img property is set height=height, required when img property set justify_x=can be THUI.LEFT, THUI.CENTER or THUI.RIGHT justify_y=can be THUI.MIDDLE, THUI.TOP, or THUI.BOTTOM return=label table Button properties button.text --Text to be displayed button.font_path --Path to the font button.font_size --Font size button.active --This flag determines if the button is enabled or not. button.visible --Hides or shows the button button.click --Function callback for when button is clicked button.fg_color --color used in idle state button.bg_color --background color button.hover_color --mouse hovering over widget button.mouse_down_color --mouse hovering and mouse button down button.inactive_color --active flag false Colors used to draw the button when not themed with textures. button.img_mouseup --idle state button.img_hover --mouse hovering over widget button.img_mouse_down --mouse hovering and mouse button down button.img_inactive --active flag false Textures to be rendered for different states of the button. functions THUI.Button:Create(x, y, width, height, text, justify_x, justify_y) x=x position y=y position width=width height=height justify_x=can be THUI.LEFT, THUI.CENTER or THUI.RIGHT justify_y=can be THUI.MIDDLE, THUI.TOP, or THUI.BOTTOM return=button table Checkbox properties checkbox.active --This flag determines if the checkbox is enabled or not. checkbox.checked --Set to true if box is checked inactive_color --active flag false mouse_down_color --mouse hovering and mouse button down hover_color --mouse hovering over widget fg_color --color used in idle state bg_color --background color Colors used to draw the checkbox when not themed with textures. checkbox.img_inactive --active flag false checkbox.img_mouse_down --mouse hovering and mouse button down checkbox.img_hover --mouse hovering over widget checkbox.img_mouseup --idle state checkbox.img_checked_inactive --active flag false while checked checkbox.img_checked_mouse_down --mouse hovering and mouse button down while checked checkbox.img_checked_hover --mouse hovering over widget while checked checkbox.img_checked_mouseup --idle state while checked Textures to be rendered for different states of the checkbox. functions THUI.CheckBox:Create(x, y, width, height, justify_x, justify_y) x=x position y=y position width=width height=height justify_x=can be THUI.LEFT, THUI.CENTER or THUI.RIGHT justify_y=can be THUI.MIDDLE, THUI.TOP, or THUI.BOTTOM return=checkbox table Combobox The combobox isn't really a widget on it's own. It's a combination of 2 buttons and a label. properties combo.left_button --left button table, see button reference combo.right_button --right button table, see button reference combo.selected --The currently selected item in the list of values functions THUI.ComboBox:Create(x, y, width, height, values, selected, justify_x, justify_y) x=x position y=y position width=width height=height values=table of possible values that can be selected selected=the index of the default value to be selected justify_x=can be THUI.LEFT, THUI.CENTER or THUI.RIGHT justify_y=can be THUI.MIDDLE, THUI.TOP, or THUI.BOTTOM return=combobox table
-
The Hankinator's UI library http://steamcommunity.com/sharedfiles/filedetails/?id=653673604 This is a rudimentary GUI library with the goal of simplicity but with flexibility. Only basic widgets are included, Label, Button, Checkbox and Combobox. This should satisfy the majority of GUI needs but if you come up with a good case to include others let me know. All widgets can be themed with images for beautification. THUI is built around groups of GUI elements. Every group has a name, this name is used to activate (make visible) when you need it to. Only one group can be active at a time. THUI contains helper functions so that you can ensure the GUI will scale and look similar on different resolutions. The easiest way to layout a menu system is to create a script for each group, then apply the scripts to pivots in your level. If you wish to design it so, you can use the flow graph to control how the user navigates between groups. It is fairly straight forward to create your own widgets that don't look so bland. To kick things off, I am going to start with required changes to Main.lua, a simple example, pause screen, journal, and finally the API reference. When I was thinking about this post, I was thinking I'd have more to say about each example but now that I've gotten to it, the ideas are gone. Please ask if things need additional clarification. I've put a lot of thought into the design of this library so that it could be used in the majority of use cases but if I have forgotten something obvious, please let me know! I publish updates to steam as I see fit but any development occurs on github first: https://github.com/airbrett/THUI Main.lua modifications: It should be pretty trivial to make the same modifications to App.lua but I like Main.lua best and I don't want to spend time talking about App.lua. There is an example Main.lua in the examples directory with all these changes. 1) First thing is first, import THUI at the top of the file and initialize some variables import "Addons/THUI/THUI.lua" paused = false exit_game = false 2) Immediately after the context is created, initialize THUI THUI:Initialize() 3) Change the while loop not to exit when we hit escape, this is for our pause menu example while not exit_game do 4) Next we need to change the program flow to only update the time and the world when the game isn't paused. if not paused then --Update the app timing Time:Update() --Update the world world:Update() end 5) Immediately after world:Render(), we need to update THUI THUI:Update() Simple example: This is a simple example of how to build a simple GUI screen with a label and a button. self.group = THUI:CreateGroup("hello_world", self, THUI.AUTOSCALE, 0, 0, 1023, 767) local title = THUI.Label:Create(512, 50, 0, 0, "Hello World!", THUI.JUSTIFY.CENTER, THUI.JUSTIFY.MIDDLE) title.font_size = 24 local button1 = THUI.Button:Create(512, 300, 200, 50, "A button") self.group:Add(title) self.group:Add(button1) Pause screen example: This script will pause the game when the user hits the escape key. This example is utilizing the ANCHOR functionality to position all widgets to the left middle of the screen. It is pretty straight forward but the interesting parts we do in this order: 1) We create the group 2) Create a label for the title 3) Create a Resume button 4) Set the click callback for the resume button 5) Create an Exit button 6) Set the click callback for the exit button 7) Add all the widgets to the group import "Addons/THUI/THUI.lua" function Script:Start() self.group = THUI:CreateGroup("pause_menu", self, THUI.AUTOSCALE, nil, nil, 1023, 767) self.group.update = THUI:Callback(self.UpdateUI, self, nil) local title = THUI.Label:Create(512, 50, 0, 0, "Paused!", THUI.CENTER, THUI.MIDDLE) title.font_size = 24 local width = 200 local button1 = THUI.Button:Create(512, 300, width, 50, "Resume", THUI.CENTER, THUI.MIDDLE) button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(512, 400, width, 50, "Exit", THUI.CENTER, THUI.MIDDLE) exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) end function Script:ResumeButtonclicked(button) self:HideMenu() end function Script:ExitButtonclicked(button) exit_game = true end function Script:UpdateWorld() if window:KeyHit(Key.Escape) then if not paused then self:ShowMenu() end end end function Script:UpdateUI(group, arg) if window:KeyHit(Key.Escape) then if paused then self:HideMenu() end end end function Script:ShowMenu() THUI:PauseGame(true) THUI:Show("pause_menu") end function Script:HideMenu() THUI:PauseGame(false) THUI:Hide("pause_menu") --FPSPlayer.lua measures the distance from the middle of the screen to figure out how much --the player is trying to look so we need to reset it when the user is done with the UI local context = Context:GetCurrent() Window:GetCurrent():SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2)) end Journal example: This is a little bit more complicated. But the first thing we need to do is create the journal menu itself. This is pretty simple but I will leave it to you to make the fancy things . In this script I create 10 buttons, each button is created with the active flag false so that it is greyed out. When the player picks up a journal entry, the button will be set to active and they can click on the button to view the entry. The Journal Entry script should be put on the object itself, like a piece of paper, cassette tape, or whatever. Journal script: import "Addons/THUI/THUI.lua" function Script:Start() Journal = self --global that entries can use to add themselves self.pg = THUI:CreateGroup("journal", self, THUI.AUTOSCALE, nil, nil, 1023, 767) local title = THUI.Label:Create(512, 50, 0, 0, "Journal", THUI.CENTER, THUI.MIDDLE) title.font_size = 24 local button1 = THUI.Button:Create(50, 700, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) self.pg:Add(title) self.pg:Add(button1) self.entries = {} self.entry_buttons = {} for i=1, 10 do local b = THUI.Button:Create(512, 45 + 55 * i, 200, 50, "????", THUI.CENTER, THUI.MIDDLE) b.active = false b.click = THUI:Callback(self.EntryButtonclicked, self, i) self.pg:Add(b) self.entry_buttons[i] = b end self.journal_entry = THUI:CreateGroup("journal_entry", self) end function Script:UpdateWorld() if window:KeyHit(Key.J) then if not THUI:GamePaused() then THUI:PauseGame(true) THUI:Show(self.pg) end end end function Script:EntryButtonclicked(button, index) THUI:Hide("journal") THUI:Show(self.entries[index].grp.name) end function Script:ResumeButtonclicked(button) THUI:PauseGame(false) THUI:Hide(self.pg) --FPSPlayer.lua measures the distance from the middle of the screen to figure out how much --the player is trying to look so we need to reset it when the user is done with the UI local context = Context:GetCurrent() Window:GetCurrent():SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2)) end function Script:AddJounalEntry(entry) self.entries[entry.index] = entry local b = self.entry_buttons[entry.index] b.active = true b.text = entry.title end Journal entry script: import "Addons/THUI/THUI.lua" Script.index = 3 Script.title = "Entry 3" function Script:Start() local text = { "Day 45", "", "I have earned the Germans' trust.", "They still do not realize I am a bear." } self.grp = THUI:CreateGroup("entry1", self, THUI.AUTOSCALE, nil, nil, 1023, 767) local label = THUI.Label:Create(512, 10, 0, 0, self.title, THUI.CENTER, THUI.MIDDLE) label.font_size = 24 self.grp:Add(label) local y = 150 local leading = label.font:GetHeight() * 1.3 for i=0, #text do label = THUI.Label:Create(512, y, 0, 0, text[i], THUI.CENTER, THUI.MIDDLE) label.font_size = 24 self.grp:Add(label) y = y + leading end local journal_button = THUI.Button:Create(100, 700, 200, 50, "Journal") journal_button.click = THUI:Callback(self.JournalButtonclick, self, nil) self.grp:Add(journal_button) end function Script:Use() Journal:AddJounalEntry(self) THUI:Show("entry1") THUI:PauseGame(true) self.entity:Hide() end function Script:JournalButtonclick(button, arg) THUI:Hide("entry1") THUI:Show("journal") end
-
The way I handled this was anytime I calculated a the point I wanted on the screen I used a ratio. Using your 1920x1080 display as the "target", the value of battL is 1920/2 - 775 = 185. Now to find the ratio 185/1920 = 0.0963541666666667. Take that ratio, and use that to calculate battL. local battL = context:GetWidth() * 0.0963541666666667 The result for 1024x768 would now be 98.6666666666667. You could round the ratio to make it easier on your eyes but what it is still hard to visualize where that point is on the screen. What I didn't do but might make it easier to use this method is to define a resolution that all the development and code would be in relation to. Lets say we pick 1024x768, we could create a function that would figure out the ratio then convert the points to whatever resolution is actually being run. function ConvertX(x) return context:GetWidth() * x / 1024 --TODO change this to our standard resolution width end function ConvertY(y) return context:GetHeight() * y / 768 --TODO change this to our standard resolution height end Now your code would look like: local battL = ConvertX(98) This would auto scale and stuff. Gets awkward with fonts but the same idea can work.
- 4 replies
-
- resolution
- 2d drawing
-
(and 1 more)
Tagged with:
-
You basically have that in Blender today with the Leadwerks exporter.
-
2 years is a long time, I hope you can find some place that you can be happy at sooner. While we're all voting to where you should go, I love the mountain states, I don't ever want to leave
-
It would be nice if there was a multisampling option in addition to the resolution option. I am suggesting this primarily because anyone affected by this wont be able to play much of anything unless the author set the MSAA to greater than 1(water would still be messed up, it's pretty unlikely they would set the reflection camera MSAA to above 1 unless they used the workaround in the bug report thread). I realize this might be viewed as a hack but something has to be done, slimwaffle reported the bug over 6 months ago.
-
According to UU3D's website, it will read Farcry/Crysis files (.CGF and .CAF) and this page says that those are the file extensions that Cryengine uses. Looks like a real possibility you could convert it with UU3D. There has to be some free assets for Cryengine I could try UU3D on, anyone got a link?
-
In App.cpp, I think it would be a good idea to create globals in lua for window, world and context. Not having these globals breaks any script that uses them which is very possible since these global variables are available in the stock Main.lua and also in LEX Main.lua when in sandbox mode. A work around is to adding a few lines in the LEX Main.lua but I think the right change is modifying App.cpp. app = App:Create(title, backgroundmap) app:SetStartMap(startmap) world=World:GetCurrent() window=Window:GetCurrent() context=Context:GetCurrent()
-
Stupid back button, lost everything. The easiest way would be to create a trigger zone with a script that takes an entity as a property (this is the object you are checking for, don't use a pivot) do a world:pick from the camera to a point some distance in front of the camera and check if it is the object you are looking for. Disclaimer: I didn't even try to run this code so there could be syntax/logical errors but the concept should work. Script.object = nil --entity function Script:Collision(entity, position, normal, speed) --todo add guards to ensure we only try this with the player local p0 = entity:GetPosition(true) local p1 = Transform:Point(0,0,20,entity.script.camera,nil)--change 20 to whatever max distance you want it to trigger with local pickInfo = PickInfo() if world:Pick(p0, p1, pickInfo, 0, true, Collision.LineOfSight) then if pickInfo.entity == self.object then --do something scary --hide to prevent triggering twice end end end Another way: Get the difference between the camera's position and the object, get the rotation of the camera then get the dot product(Vec3:Dot()) of the two. Might get awkward but you could use a pivot.