-
Posts
141 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by GorzenDev
-
[SOLVED]World:Pick problem against model with multiple surfaces.
GorzenDev replied to GorzenDev's topic in Programming
I have combined all my model surfaces into 1 surface and pick still returns prop collision. I have checked every single entity in my scene and made sure none have a Collision:Prop. I even went all the way and attached a script with pickmode(0) to every single brush and even all the skeleton bones. It still returns the same result. This is an impossible situation there is no way pick should return collision on something with collisiontype prop since there simple is nothing having that collision type in my scene. "Frustration starts to build" Nobody had similar problems and have an idea what could be wrong? -
I am working on a third person controller with 'over the shoulder view', all thats left to do is camera collision/occlusion. I do a world:pick from the camera's lookat target back to the camera, then check distance etc. But the problem is my pick hits the character, or so it says. I know this sounds like a noob problem and it may as well be for all i know. I set pickmode and collisiontype in the modelscript. self.entity:SetPickMode(0, true) self.entity:SetCollisionType(Collision.None, true) During picking i print some stuff. local distance = -1.0 local pickInfo = PickInfo() if world:Pick(p0, p1, pickInfo, 0, true) then System:Print("camera occluded by: "..pickInfo.entity:GetClassName()) System:Print("name: "..pickInfo.entity:GetKeyValue("name")) System:Print("collisiontype: "..pickInfo.entity:GetCollisionType()) distance = p0:DistanceToPoint(pickInfo.position) end The weird thing is the print results. I checked and collisiontype 1 = Collision:Prop. How is it possible my model has collisiontype 1 ? Could it be because my model has multiple surfaces ? Anybody has an idea?
-
thank you very much for pointing me in the right direction. my apologies for posting this in the bug reports i realize this should have been posted in programming
-
Creating a new project through the editor and compiling that straight away results in the same error. somehow it has a problem with Leadwerks.lib(Face.obj) ??? I have not changed anything.
-
After all these new little updates i no longer can compile any c++ project. gives error: this a new project with all my codes commented out to make sure its not me. this problem persist using 4.5 and even beta. grabbing an older project and trying to compile, results in the same compile error.
-
Oculus Rift vs. HTC Vive: Which is the one true VR headset?
GorzenDev commented on Josh's blog entry in Development Blog
very informative. now i actually have doubts about ordering the htc vive -
my Kaspersky doesnt find any virus in steam or leadwerks so might be a false positive.
-
if you are using vs2017 and have heap profiling enabled it will drop your fps significant
-
Does clamp get a proper result when negative values are used? Since in that case the self.maxZoom would be the smallest value of the 2. maiby flip them around ? During optimisation i did at one point use clamp but got a bad result so reverted it back and never looked at it again.
-
FYI the z index of mouseposition is cumulative. To get proper values you could do something like: local oldWheelPos = 0.0 if self.currentMousePos ~= nil then oldWheelPos = self.currentMousePos.z end self.currentMousePos = window:GetMousePosition() self.currentMousePos.x = Math:Round(self.currentMousePos.x) self.currentMousePos.y = Math:Round(self.currentMousePos.y) local newWheelPos = (self.currentMousePos.z - oldWheelPos) * 0.1 if newWheelPos > 0.0 or newWheelPos < 0.0 then self.curZoom = self.curZoom + newWheelPos if self.curZoom < self.maxZoom then self.curZoom = self.maxZoom elseif self.curZoom > self.minZoom then self.curZoom = self.minZoom end end
-
2 more weeks and my HTC VIVE will arrive i cant wait to start playing with VR development.
-
like aggrorjorn said. but also take a look in menu.lua you can also take a look at my blog its C++ but very similar to how you would use lua.
-
i hope i understand your problem correctly. But as i see it, you would have to manually set the color back to its original color.
-
i am not sure to be honest i have never tried assigning a function pointer to a widget. i usually just check event.source against a widget pointer and call a specific class function corresponding to that widget.
-
as far as i know that is the only way.
-
I hope you find it usefull
-
There is a problem with the default TextArea.lua widget script. Your game will crash when you click on an empty TextArea. Fix: look for the Function "Script:GetCaretCoord(caret)" after: local text = self.lines[self.currentline]--self.widget:GetText() add: if text == nil then return 0 end More will be added when/if discovered...
-
Remember that a widget's behaviour is dictated by the script that is attached to it. Well its that simple just use a custom script for your widget and your done. I will show you how to create a simple ColorLabel. First copy the default Label.lua script and rename it to Colorlabel.lua Now lets make some changes in your Colorlabel.lua so open it up. We will add 2 variables to the script called bordercolor and textcolor they will be of type Vec4(). Script.bordercolor = Vec4(0.2,0.2,0.2,1) Script.textcolor = Vec4(0.7,0.7,0.7,1) Now lets change the draw function to use our color variables. function Script:Draw(x,y,width,height) local gui = self.widget:GetGUI() local pos = self.widget:GetPosition(true) local sz = self.widget:GetSize(true) local scale = gui:GetScale() local text = self.widget:GetText() local indent=4 if self.border==true then --set border color gui:SetColor(self.bordercolor.r, self.bordercolor.g, self.bordercolor.b, self.bordercolor.a) gui:DrawRect(pos.x,pos.y,sz.width,sz.height,1) end --set text color gui:SetColor(self.textcolor.r,self.textcolor.g,self.textcolor.b,self.textcolor.a) if text~="" then local style=0 if self.align=="Left" then style = Text.Left end if self.align=="Center" then style = Text.Center end if self.align=="Right" then style = Text.Right end if self.valign=="Center" then style = style + Text.VCenter end if self.wordwrap==true then style = style + Text.WordWrap end if self.border==true then gui:DrawText(text,pos.x+scale*indent,pos.y+scale*indent,sz.width-scale*indent*2,sz.height-scale*indent*2,style) else gui:DrawText(text,pos.x,pos.y,sz.width,sz.height,style) end end end Now lets change the label in our UI_Interface class to use our custom script. Theres 2 ways to set a widget's script as i hinted earlier. //option 1 label = Widget::Label("label", guiScale * 15, guiScale * 15, guiScale *80, guiScale * 20, panel); label->SetScript("Scripts/GUI/Colorlabel.lua"); //option 2 label = Widget::Create("label", guiScale * 15, guiScale * 15, guiScale * 80, guiScale * 20, panel, "Scripts/GUI/Colorlabel.lua"); Offcourse option 1 is quite silly when you have option 2 but it works. Now lets set the text color for our newly created custom widget. label->SetObject("textcolor", new Vec4(1.0, 0.0, 0.0, 1.0)); Notice the undocumented SetObject() function which basicly sets variables of type Leadwerks::Object. Theres not much more i can say about custom widgets other than, "Your imagination is the limit". This concludes the tutorial part. I hope it is of some use to anybody.
-
i am currently creating a tutorial blog where i try to explain as much as i can of what i found out playing with this system. to be honest it all sounds more complex than it actually is. the widget system gives you almost unlimited freedom as to what a GUI element does and how it reacts.
-
a widget's functionality is always dictated by a lua script even if you dont use lua the widget does. for example a Widget::Button() always uses the script "Scripts/GUI/Button.lua" unless you link it to a custom script. so to say it plainly a widget always uses a lua script.
-
Previously we created a custom class and a basic GUI. Now its time to add some basic widgets to our class and show how to use them. Lets start with a simple Panel that has a Label, a TextField and a Button. // UI_Interface.h Widget* panel = NULL; Widget* label = NULL; Widget* textField = NULL; Widget* button = NULL; // UI_Interface.cpp //create gui //.... // //panel = Widget::Panel(guiScale * 100, guiScale * 100, guiScale * 300, guiScale * 80, gui->GetBase()); panel = Widget::Create("", guiScale * 100, guiScale * 100, guiScale * 300, guiScale * 80, gui->GetBase(), "Scripts/GUI/Panel.lua"); //children of panel label = Widget::Label("label", guiScale * 15, guiScale * 15, guiScale *80, guiScale * 20, panel); textField= Widget::TextField("text", guiScale * 15, guiScale * 35, guiScale * 150, guiScale * 20, panel); button = Widget::Button("button", guiScale * 175, guiScale * 10, guiScale * 80, guiScale * 20, panel); btn_Fun = Widget::Button("Fun", guiScale * 175, guiScale * 35, guiScale * 80, guiScale * 20, panel); Forget about btn_Fun for now You probably noticed that Widget::Create() is used for the panel. I did this to show you that any widget can be created by referencing the lua script path. Even your own custom widgets, but we will come to that later. Dont forget to release your widgets. //UI_Interface.cpp UI_Interface::~UI_Interface() { btn_Fun->Release(); button->Release(); textField->Release(); label->Release(); panel->Release(); gui->Release(); } Now lets add some functionality. Lets say we want to show our textField input in our label. // UI_Interface.cpp bool UI_Interface::ProcessEvent(Event event) { if (event.id == Event::WidgetAction) { if (event.source == button) { string text = textField->GetText(); label->SetText(text); return true; } } // return false; } Now we know how to create and catch widget events. But what about those extra widget functions? Lets delve into that now. A widget's behaviour is represented by a lua script, much like how a entity has a script attached or like the c++ Actor class even. It has callbacks to script functions like mouseDown(), mouseUp(), Draw() etc. Checkout any script in the GUI folder for examples. Lets take the Label for example, Open the file "Scripts/GUI/Label.lua". You can see it has no real functionality other then just draw the widget Text. But there's more to it. Lets look at the draw function for Label.lua: function Script:Draw(x,y,width,height) local gui = self.widget:GetGUI() local pos = self.widget:GetPosition(true) local sz = self.widget:GetSize(true) local scale = gui:GetScale() local text = self.widget:GetText() local indent=4 gui:SetColor(0.7,0.7,0.7) if self.border==true then gui:DrawRect(pos.x,pos.y,sz.width,sz.height,1) end if text~="" then local style=0 if self.align=="Left" then style = Text.Left end if self.align=="Center" then style = Text.Center end if self.align=="Right" then style = Text.Right end if self.valign=="Center" then style = style + Text.VCenter end if self.wordwrap==true then style = style + Text.WordWrap end if self.border==true then gui:DrawText(text,pos.x+scale*indent,pos.y+scale*indent,sz.width-scale*indent*2,sz.height-scale*indent*2,style) else gui:DrawText(text,pos.x,pos.y,sz.width,sz.height,style) end end end There are some variables used like self.border, self.align, self.valign and self.wordwrap. Any variable used in a widget script can be Set/Get. You can find most of these in the Documentation for Widget, although not all are documented like SetObject() and GetObject(). So to set our label style we would do something like this: label = Widget::Label("label", guiScale * 15, guiScale * 15, guiScale *80, guiScale * 20, panel); label->SetString("align", "Left"); //align horizontal label->SetString("valign", "Center"); //align vertical label->SetBool("wordwrap", false); //wordwrap label->SetBool("border", true); //show border Noticed we used SetString for a string variable and SetBool for a boolean variable. The first argument is always the variable name used in the widget script. Lets give you another example to make it a bit more clear. Open the file "Scripts/GUI/Button.lua" and look at the Draw function. Did you notice the variable "self.style" being used to dictate what type of button this is? Interesting right Do you remember our btn_Fun? Lets set our bnt_Fun's style to a checkbox and see what happens. btn_Fun = Widget::Button("Fun", guiScale * 175, guiScale * 35, guiScale * 80, guiScale * 20, panel); btn_Fun->SetString("style", "Checkbox"); And add some functionality. if (event.source == btn_Fun) { if (btn_Fun->GetState()) label->SetText("enabled"); else label->SetText("disabled"); return true; } By now your UI_Interface class should look something like this. UI_Interface.h #pragma once #include "Leadwerks.h" //Forward declare class App; using namespace Leadwerks; class UI_Interface { private: App* app = NULL; // GUI* gui = NULL; // Widget* panel = NULL; Widget* label = NULL; Widget* textField = NULL; Widget* button = NULL; Widget* btn_Fun = NULL; public: UI_Interface(); UI_Interface(App* pApp); ~UI_Interface(); void Process(); bool ProcessEvent(Event event); }; UI_Interface.cpp #include "UI_Interface.h" //Forward declares #include "App.h" UI_Interface::UI_Interface() {} UI_Interface::UI_Interface(App* pApp) { app = pApp; // //create gui gui = GUI::Create(app->context); float guiScale = gui->GetScale(); gui->GetBase()->SetScript("Scripts/GUI/Panel.lua"); //make the base gui invisible if you want //gui->GetBase()->SetObject("backgroundcolor", new Vec4(0, 0, 0, 0)); // panel = Widget::Panel(guiScale * 100, guiScale * 100, guiScale * 300, guiScale * 80, gui->GetBase()); panel = Widget::Create("", guiScale * 100, guiScale * 100, guiScale * 300, guiScale * 80, gui->GetBase(), "Scripts/GUI/Panel.lua"); // label = Widget::Label("label", guiScale * 15, guiScale * 15, guiScale *80, guiScale * 20, panel); label->SetString("align", "Left"); //align horizontal label->SetString("valign", "Center"); //align vertical label->SetBool("wordwrap", false); //wordwrap label->SetBool("border", true); //show border // textField = Widget::TextField("text", guiScale * 15, guiScale * 35, guiScale * 150, guiScale * 20, panel); button = Widget::Button("button", guiScale * 175, guiScale * 10, guiScale * 80, guiScale * 20, panel); // btn_Fun = Widget::Button("Fun", guiScale * 175, guiScale * 35, guiScale * 80, guiScale * 20, panel); btn_Fun->SetString("style", "Checkbox"); } UI_Interface::~UI_Interface() { btn_Fun->Release(); button->Release(); textField->Release(); label->Release(); panel->Release(); gui->Release(); } void UI_Interface::Process() { while (EventQueue::Peek()) { Event event = EventQueue::Wait(); ProcessEvent(event); } } bool UI_Interface::ProcessEvent(Event event) { if (event.id == Event::WidgetSelect) { //list type widgets } // if (event.id == Event::WidgetAction) { if (event.source == button) { string text = textField->GetText(); label->SetText(text); return true; } else if (event.source == btn_Fun) { if (btn_Fun->GetState()) label->SetText("enabled"); else label->SetText("disabled"); return true; } } // return false; } Next blog entry we will be focusing on custom widgets
-
Bare with me im not a very good story teller . I will not be focusing on basic leadwerks usage and assume the reader knows a thing or 2 about leadwerks. So lets start with the basics, Create a window and context. bool App::Start() { window = Leadwerks::Window::Create("GUI Tutorial", 0, 0, 1024, 768); context = Leadwerks::Context::Create(window); return true; } bool App::Loop() { if (window->Closed() || window->KeyHit(Key::Escape)) return false; return true; } Now i personally like to use classes for my GUI so thats what we are gonna do. Create a new class called "UI_Interface". UI_Interface.h #pragma once #include "Leadwerks.h" //Forward declare class App; using namespace Leadwerks; class UI_Interface { private: App* app = NULL; // GUI* gui = NULL; public: UI_Interface(); UI_Interface(App* pApp); ~UI_Interface(); void Process(); bool ProcessEvent(Event event); }; UI_Interface.cpp #include "UI_Interface.h" //Forward declares #include "App.h" UI_Interface::UI_Interface() {} UI_Interface::UI_Interface(App* pApp) { } UI_Interface::~UI_Interface() { } void UI_Interface::Process() { while (EventQueue::Peek()) { Event event = EventQueue::Wait(); ProcessEvent(event); } } bool UI_Interface::ProcessEvent(Event event) { if (event.id == Event::WidgetSelect) { } // if (event.id == Event::WidgetAction) { } // return false; } now that we have a interface class lets first make sure it is created and called in your main function or app. App.h #pragma once #include "Leadwerks.h" #include "UI_Interface.h" #undef GetFileType using namespace Leadwerks; class App { public: Leadwerks::Window* window; Context* context; World* world; Camera* camera; UI_Interface* ui_Interface = NULL; App(); virtual ~App(); bool Start(); bool Loop(); }; App.cpp #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete ui_Interface; delete world; delete window; } bool App::Start() { window = Leadwerks::Window::Create("GUI Tutorial", 0, 0, 1024, 768); context = Leadwerks::Context::Create(window); //create GUI ui_Interface = new UI_Interface(this); return true; } bool App::Loop() { if (window->Closed() || window->KeyHit(Key::Escape)) { return false; } context->SetColor(0.0, 0.0, 0.0); context->Clear(); // ui_Interface->Process(); // Time::Update(); // //world->Update(); // //world->Render(); // context->Sync(); return true; } Now lets create the GUI in the UI_Interface class. UI_Interface::UI_Interface(App* pApp) { app = pApp; // //create gui gui = GUI::Create(app->context); float guiScale = gui->GetScale(); gui->GetBase()->SetScript("Scripts/GUI/Panel.lua"); //make the base gui invisible if you want //gui->GetBase()->SetObject("backgroundcolor", new Vec4(0, 0, 0, 0)); } This will result in a window with a panel as background. Next blog entry we will be focusing on adding widgets to the GUI.
-
your code creates a textarea which is differant from a textfield. a textarea is always multiline. a textfield is just one line. setlayout works as supposed to just dont forget widget->Redraw() after setting layout. also like josh said the basewidget needs a panel script. if you dont want a visible panel you can always use SetObject('backgroundcolor', new Vec4(0,0,0,0)); to make it transparant.
-
honestly looking at the vanilla TextArea.lua it looks like it should support what you want. try something like below. (not tested it) function Script:AddText(text) self.updateslidersneeded=true local morelines = text:split("\n") local gui=self.widget:GetGUI() local n for n=1,#morelines do self.lines[#self.lines+1] = morelines[n] self.linewidth[#self.lines] = gui:GetTextWidth(morelines[n]) self.maxlinewidth = math.max(self.maxlinewidth,self.linewidth[#self.lines]) end --try something like this self:MouseWheel(#morelines) end
-
i feel nostalgic looking at this :D. get a huge quake/unreal vibe.