Jump to content
Chris Vossen

Leadwerks 3 "How do I ____?" Questions and Answers

Recommended Posts

Hi everyone,

 

I'm Chris Vossen, I wrote the majority of "Darkness Awaits" and have spent way too much time with the documentation. I wanted to open a forum up to answering LE3 user questions about how to do things in Lua or editor.

 

Please don't be bashful! If you have a question chances are there are/will be many others out there with the same question.

Share this post


Link to post

Question: "Isn't there a way to change the size of models by entering their numbers? The viewports show me the sizes, but I seem only to be able to change them using the mouse which is awkward."

 

Yes.

 

- Select your model by clicking on the scene tab

- Now there is a tab that says general and within it there are parameters for scale

 

post-5181-0-82858200-1362176626_thumb.png

 

If you want to scale the model as a whole you can use the model editor:

 

post-5181-0-78927200-1362177289_thumb.png

Share this post


Link to post

Question: "I create a new project using the Project Manager (Lua). I would have expected that I can run the project right away, but it doesn't seem to work. Opening App.lua in the Script Editor and hitting F5/F6 just notifies me that <myproect>.debug.exe couldn't be launched."

 

Answer: Josh is on this right now. I'll post more when he's done.

Share this post


Link to post

Thanks. But that doesn't change the numbers in the graph but rather multiplies them, right? I find that confusing since I can't easily compare the sizes. The scale makes sense for imported models, but when I create a cube I want to directly enter its size.

Share this post


Link to post

Question: "Are there any commands/shortcuts to snap to the grid? Or to align objects? Without that it's pretty hard to construct the scene you want."

 

Answer: You can adjust the grid size via View->Increase Grid Size or View->Decrease Grid Size "short cut key are the brackets '[' and ']' " When you create primitives they will automatically be created according to the grid size.

Share this post


Link to post

Thanks. But that doesn't change the numbers in the graph but rather multiplies them, right? I find that confusing since I can't easily compare the sizes. The scale makes sense for imported models, but when I create a cube I want to directly enter its size.

 

In the editor: You can select the object in the main viewport and their dimensions will appear in the 2d viewports where you can see their dimensions and resize accordingly.

 

or

 

If you are working in code: Box

 

post-5181-0-91443400-1362178074_thumb.png

Share this post


Link to post

I can see no animate command in Leadwerks 3.

How would I animate a character with a walk sequence containing a framebegin value of 1 and a frameend of 40?

Share this post


Link to post

Question: "Why can't I create new primitives directly in the main viewport? I would prefer to drag-n-drop them from the toolbar (giving me e.g. a unit cube) and then resize/reposition them using their property window (or the mouse)."

 

Answer:

If you would prefer to drag and drop a unit cube you could:

 

1. In 2d viewports create a 1x1x1 using the primitive box

 

post-5181-0-23209800-1362178507_thumb.png

 

2. Right click on your box in the scene tab and select "Save as Prefab"

 

post-5181-0-57125700-1362178563_thumb.png

 

3. Name it and save it

 

4. Select your prefab from the asset browser and drag n drop into the main viewport:

 

post-5181-0-53420400-1362178618_thumb.png

Share this post


Link to post

I can see no animate command in Leadwerks 3.

How would I animate a character with a walk sequence containing a framebegin value of 1 and a frameend of 40?

 

The most convenient way of animating a model in lua is to attach the "AnimationManager" script (located at \Scripts\Animation\AnimationManager.lua) then call "SetAnimationSequence"

 

an example of this is in the Player.lua class (which is attached to the barbarian in Darkness awaits) Lines 219 through 235.

 

 

If you don't want to use the animation manager you could call the entity SetAnimationFrame command. Animation commands are grouped together in Entity

Share this post


Link to post

Hi Chris, when executing a project in either debug or release mode a console window opens up before the main application window listing all the assets being loaded etc. Is there a way to suppress the console on a release build?

Share this post


Link to post

Hi, im seeing no "helpers" for lights or cameras in any viewports? Should i be able to?

 

Also rotating the camera or lights is useless as nothing "rotates" to show you the rotation you making.

 

Andy

Share this post


Link to post

Hi Chris

 

In Camera2, self.target is suppose to be the barbarian.

How can I fetch the material from code?

 

local child = self.target:GetChild(1)
local material = child:GetMaterial()

 

seem to return the shadow material, but using GetChild(0) gives me nothing. Also self.target:GetMaterial() return nil.

is there a way to fetch the material this way from the barbarian?

 

Using to create a behind wall effect (x-ray shader) but I need the material to set the shader dynamicly :)

Not even sure I'm doing it right.

Share this post


Link to post

Hi Chris, when executing a project in either debug or release mode a console window opens up before the main application window listing all the assets being loaded etc. Is there a way to suppress the console on a release build?

 

Okay I haven't tested this but I believe there are currently 2 steps to accomplish this:

 

1. Make sure you can compile for visual studios

 

Compiling with Visual Studio

 

 

2. Change the linker subsystem property to Windows

 

Project->Properties->Linker->System->SubSystem

 

post-5181-0-07823100-1362180180_thumb.png

Share this post


Link to post

Hi, im seeing no "helpers" for lights or cameras in any viewports? Should i be able to?

 

Andy

 

Copy the Icons folder from Darkness Awaits/Materials, Camera should be around.

Share this post


Link to post

I just added the icons folder in the project templates directory, so any new project you create will include them. biggrin.png

 

We only have icons for the lights right now. We didn't have time to produce any for other entities, and I couldn't find any that looked consistent.

Share this post


Link to post

Hi Chris

 

In Camera2, self.target is suppose to be the barbarian.

How can I fetch the material from code?

 

local child = self.target:GetChild(1)
local material = child:GetMaterial()

 

seem to return the shadow material, but using GetChild(0) gives me nothing. Also self.target:GetMaterial() return nil.

is there a way to fetch the material this way from the barbarian?

 

Using to create a behind wall effect (x-ray shader) but I need the material to set the shader dynamicly smile.png

Not even sure I'm doing it right.

 

Models in Leadwerks 3 are basically the same as a Mesh in Leadwerks 2. A model can have one or more surfaces. In this case, the material you are looking for is applied to the model surface, so it will be something like this:

local child = self.target:GetChild(1)
local surface = child:GetSurface(0)
local material = surface:GetMaterial()

 

Since GetChild() returns an entity, and GetSurface() is a Model class command, you might need to cast the entity object to a model:

http://www.leadwerks...ng-with-lua-r57

 

Note that all indexes in Leadwerks 3 begin with 0, so 0 is the first entity or surface, 1 is the second, etc.

Share this post


Link to post

Models in Leadwerks 3 are basically the same as a Mesh in Leadwerks 2. A model can have one or more surfaces. In this case, the material you are looking for is applied to the model surface, so it will be something like this:

local child = self.target:GetChild(1)
local surface = child:GetSurface(0)
local material = surface:GetMaterial()

 

Since GetChild() returns an entity, and GetSurface() is a Model class command, you might need to cast the entity object to a model:

http://www.leadwerks...ng-with-lua-r57

 

Note that all indexes in Leadwerks 3 begin with 0, so 0 is the first entity or surface, 1 is the second, etc.

 

The lua example in Model::GetSurface might help as well.

Share this post


Link to post

Models in Leadwerks 3 are basically the same as a Mesh in Leadwerks 2. A model can have one or more surfaces. In this case, the material you are looking for is applied to the model surface, so it will be something like this:

local child = self.target:GetChild(1)
local surface = child:GetSurface(0)
local material = surface:GetMaterial()

 

Since GetChild() returns an entity, and GetSurface() is a Model class command, you might need to cast the entity object to a model:

http://www.leadwerks...ng-with-lua-r57

 

Note that all indexes in Leadwerks 3 begin with 0, so 0 is the first entity or surface, 1 is the second, etc.

 

That works, thanks guys.. (my first shader in le3) :

 

    surface = self.target:GetSurface(0)
   initmat = surface:GetMaterial()

 

Share this post


Link to post

Hi, I'm getting the following error in lua; 'attempt to index global 'Map' (a nil value). sad.png

 

function App:Start()

--Set the application title
self.title="MyGame"

--Create a window
self.window=Window:Create(self.title,0,0,1024,768,Window.Titlebar+Window.Center+8)
--self.window:HideMouse()

--Create the graphics context
self.context=Context:Create(self.window,0)
if self.context==nil then return false end

--Create a world
self.world=World:Create()

--Load a map
return Map:Load("Maps\start.map")
end

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...