-
Posts
3,946 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by macklebee
-
-
Unfortunately this does not work in lua:
plane = Plane(p1, p2, p3)
but thanks for trying, anyways.
- 1
-
Going through the documentation and I am trying to understand how the Plane functions work: https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Plane
You don't have the ability to define the plane via something like Plane:Create() so how can you perform Plane:DistanceToPoint(), Plane:GetNormal(), etc?
And then you also have Transform:Plane() that actually has an example to try but the program fails because the transformed plane comes back as nil?
Did this work at one time and it was removed or was a work in progress that never got completed?
-
As far as I can tell - no. But if you figure it out - please share
-
Use context:Sync() to "flip" the image drawn on a buffer over to the context... or it used to be something like that in the old days when you had gbuffers... but it still appears to work.
example:
window = Window:Create("Splash",0,0,800,600,Window.Center+Window.Titlebar) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetPosition(0,0,-3) light = DirectionalLight:Create() light:SetRotation(35,35,0) box = Model:Box() splash = Texture:Load("Materials/Developer/leadwerks.tex") context:SetBlendMode(Blend.Alpha) context:DrawImage(splash,0,0,context:GetWidth(),context:GetHeight()) context:Sync(true) Time:Delay(2000) camera:SetClearColor(1,0.5,0) while window:KeyDown(Key.Escape)==false do if window:Closed() then break end box:Turn(Time:GetSpeed()*0.5,Time:GetSpeed()*0.5,0) Time:Update() world:Update() world:Render() context:Sync(true) end
- 1
-
I have not ever been successful to get individual bones to manually move while using the "new" PlayAnimation() command, but if you use the older, original command for animation, SetAnimationFrame(), you can rotate individual bones while playing animations.
example:
window = Window:Create("Example", 0, 0, 800, 600, Window.Titlebar+Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetPosition(0,.8,-1.8) light = DirectionalLight:Create() light:SetRotation(35,35,0) player = Model:Load("Models/characters/crawler/crawler.mdl") frame = 0 blend = 1 sequence = "Run" Head = player:FindChild("Bip01 Head") Rot = Head:GetRotation(false) while not window:KeyHit(Key.Escape) do if window:Closed() then return false end player:SetAnimationFrame(frame,blend,sequence,true) frame = frame + Time:GetSpeed()/2.5 if window:KeyDown(Key.Left) then Rot.y = Rot.y - 1 end if window:KeyDown(Key.Right) then Rot.y = Rot.y + 1 end if window:KeyDown(Key.Up) then Rot.z = Rot.z - 1 end if window:KeyDown(Key.Down) then Rot.z = Rot.z + 1 end Rot.y = math.max(Rot.y, -45) Rot.y = math.min(Rot.y, 45) Rot.z = math.max(Rot.z, -120) Rot.z = math.min(Rot.z, -40) Head:SetRotation(Rot.x, Rot.y, Rot.z, false) Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:DrawText("Press Arrow Keys to Move Head",2,2) context:DrawText("Rot: "..Rot:ToString(),2,22) context:SetBlendMode(Blend.Solid) context:Sync(true) end
- 2
- 1
- 1
-
Converted to mdl and loaded fine for me. Even looks like a nice box once I added a material and fixed the normals.
- 1
-
Try running this program instead of the standard main.lua:
rescounter = System:CountGraphicsModes() System:Print(rescounter) resolutions = {} for i = 0, rescounter-1 do resolutions[i] = System:GetGraphicsMode(i) System:Print("Resolution "..i..": "..resolutions[i].x.." x "..resolutions[i].y) end window = Window:Create("Supported Resolutions", 0,0,resolutions[rescounter-1].x,resolutions[rescounter-1].y,Window.Fullscreen) context = Context:Create(window) while window:KeyDown(Key.Escape)==false do context:SetColor(0,0,0) context:Clear() context:SetBlendMode(Blend.Alpha) for i = 0, rescounter - 1 do context:SetColor(1,0,0) context:DrawRect(0,0,resolutions[i].x, resolutions[i].y,1) context:SetColor(1,1,1) context:DrawText(resolutions[i].x.." x "..resolutions[i].y, resolutions[i].x-75, resolutions[i].y-15) end context:SetBlendMode(Blend.Solid) context:Sync(true) end
It should fill up your entire screen and show all the possible resolutions. If it doesn't then i would say you have something else not related to LE affecting your resolutions/screen sizes... like maybe that Nvidia app I see at the bottom of your screen?
-
Works fine for me. 'Window is null' error would imply that there was an issue creating the Window. Try running the project's executable from windows explorer and see if it fails. Offhand it looks like you are having graphic card issues but hard to say since you never give enough information for anyone to do anything other than guess.. Perhaps you should try rebooting your PC?
worse case, try to hardcode the window creation:
window=Window:Create("example",0,0,1024,768,Window.Fullscreen)
-
Quote
It sound sweet, then please help me with a simple fomula or steps to archive my calculation
I don't know how simple it will be but I will try tomorrow after work if someone does not help you before then. I needed to go to bed two hours ago.
- 1
-
I couldn't tell from your original post's screenshot that you were running the program from the editor. Apparently when ran from the editor, it will set the devmode property to 1 at runtime no matter what the configuration file has for the setting. So either run the program from the executable itself from windows explorer, hardcode it in the main.lua script, or just place this line in the beginning of your main.lua script:
System:SetProperty("devmode","0")
-
Should be possible as it gives the orientation of the plane.
-
Take a look at the picture to see the problem.
Think of the line between Red and Blue as a rotating shaft. Think of the green line of known length at known angle as a fixed limb coming off Blue. As the Red/Blue shaft rotates, the Black dot could be anywhere along the red circular path and still hold true to the information that has been provided.
-
I don't think you have given us enough information to determine how the plane is oriented in 3d space to figure it out. We would need alpha broken down into orthographic components at the very least.
-
It works just fine. The system property "devmode" is probably set to "1" inside your project's configuration file located typically here:
C:\Users\<UserName>\AppData\Local\<ProjectName>\<ProjectName>.cfg
-
Spiderpig is asking about the clarification of angle alpha in relation to what plane it is on. Is that angle value based on an orthographic view (looking down from top) or is the angle along the plane that would exist if the 3 points were on different vertical points in 3D space. Assuming that we are looking at the triangle above in the XZ plane and the Y axis is going into the screen. If its the latter, i don't think we have enough information about what determines the orientation of the plane between the 3 points.
-
Just for giggles...
local window = Window:Create("Collision Type Response",0,0,400,300,Window.Titlebar+Window.Center) local context = Context:Create(window) local gui = GUI:Create(context) local base = gui:GetBase() base:SetScript("Scripts/GUI/Panel.lua") function AddingItems(widget,table) for n=1,#table do widget:AddItem(table[n], n==1) end end types = {"PROP","SCENE","CHARACTER","TRIGGER","DEBRIS","PROJECTILE","LINEOFSIGHT"} response = {{1,1,1,4,1,1,0},{1,1,1,0,0,1,1},{1,1,1,4,0,1,0},{4,0,4,0,0,0,0}, {1,0,0,0,0,0,0},{1,1,1,0,0,0,0},{0,1,0,0,0,0,0}} choicebox1 = Widget:ChoiceBox(20,120,170,60,base) choicebox2 = Widget:ChoiceBox(190,60,170,60,base) answer = Widget:Label("COLLIDE",190,120,170,60,base) answer:SetString("align","Center") answer:SetString("valign","Center") answer:SetBool("border",true) AddingItems(choicebox1,types) AddingItems(choicebox2,types) while not window:KeyHit(Key.Escape) do if window:Closed() then return false end while EventQueue:Peek() do local event = EventQueue:Wait() if event.source == choicebox1 or event.source == choicebox2 then local answervalue = response[choicebox1:GetSelectedItem()+1][choicebox2:GetSelectedItem()+1] if answervalue == 0 then answer:SetText("NONE") end if answervalue == 1 then answer:SetText("COLLIDE") end if answervalue == 4 then answer:SetText("TRIGGER") end end end context:Sync() end
I never realized before writing this up that you have no way of getting the current response set for the collision types... for the life of me, I could have sworn it was possible - but no. If there was a Collision:GetResponse(type,type) to go with the undocumented Collision:SetResponse(type,type,response), this little example program would be more accurate/trustworthy. As it stands right now, you have to trust that the table that its based upon is correct and will never change.
- 2
-
Put your mouse cursor over on the inner wall of the right side of the application and you should see a resize arrow - when you do, left-click/hold and drag to the left and you should see the Objects/Assets/Scene/Terrain panel.
- 1
-
16 hours ago, thehankinator said:
It'd be handy if Vec4 had a division operator for converting colors defined in 0-255 to 0-1
Just curious, but what do you have that is defining colors in 0-255? The editor does when you use the color picker but those values are converted to the 0-1 scale. Everything in LE now except for the color picker itself (which I suspect is due to the OS), specifically uses 0-1, so what are you doing/using that would require that specifically where you couldn't just make a simple function to handle it?
-
Appears they are missing looking at the class members available for Vec3 versus Vec2 & Vec4:
Vec3 Vec4 Vec2 .add .add missing members .div .eq .eq .mul .mul .sub
Don't know for sure if related but it appears to be. The '.div' member is missing for Vec4, but since the '.mul' member exists you can make Case3 work by multiplying the Vec4() with (1/255).
Would be nice if the other two vector classes were given the same abilities.
-
The model is extremely small. Open the model in the Model Editor and click Tools-->Resize. Scale the model up by 1,000% and then save. Do this twice as the Model Editor will only allow you to scale at the maximum of 1,000%. Drag the newly scaled model into the scene.
- 1
- 1
-
Without the file in question, we can only guess at what you are doing wrong. But I am willing to guess that the scale of the model is the problem. So either the model is gigantic or the model is extremely small.
- 1
-
The GetAngle() returns the rotation of the 2D plane set from SetAngle() apparently. If you rotate your sprite with SetAngle(), it doesn't change the angle of a sprite in billboard mode in reference to the camera - it changes the rotation of the 2D plane around its center.
And it appears that the sprites' rotation in relation to the camera does not have anything to do with the sprite's 3D rotation - I assume since its probably a shader controlling the rotation?
-
Not sure if i follow exactly what you are asking for, but here is a simple example of a listbox and a button. When the button is pressed, it will delete the selected item from the table used to create the items in the listbox.
local window = Window:Create("example",0,0,400,300,Window.Titlebar+Window.Center) local context = Context:Create(window) local gui = GUI:Create(context) local base = gui:GetBase() base:SetScript("Scripts/GUI/Panel.lua") mitem ={} table.insert(mitem,"Wood") table.insert(mitem,"Steel") table.insert(mitem,"Concrete") table.insert(mitem,"Rubber") table.sort(mitem) button1 = Widget:Button("Delete",240,20,100,40,base) listbox1 = Widget:ListBox(20,20,200,100,base) function AddStuffToList(mytable,widget) widget:ClearItems() System:Print(#mytable) if #mytable > 0 then for n = 1, #mytable do widget:AddItem(mitem[n], n==1) end end widget:Redraw() end AddStuffToList(mitem,listbox1) while not window:KeyHit(Key.Escape) do if window:Closed() then return false end while EventQueue:Peek() do local event = EventQueue:Wait() if event.source == button1 then if listbox1:GetSelectedItem()~=-1 then table.remove(mitem,listbox1:GetSelectedItem()+1) AddStuffToList(mitem,listbox1) end end end context:Sync() end
-
Perhaps this is related to this problem posted here:
But also there were some possible problems with the material files being used. Can you post the bullethole decal's material file and screenshot of the texture's settings?
Transform:Plane() and Plane functions
in Leadwerks Engine Bug Reports
Posted
Transform Plane's lua example in the documentation causes an error and fails the program due to the transformed plane returning as nil. I assume its related to also the inability to use the Plane functions in lua as there is no way to define a plane.
This code:
--Create a window window = Window:Create() context = Context:Create(window) world = World:Create() local camera = Camera:Create() camera:Move(0,0,-3) local light = DirectionalLight:Create() light:SetRotation(35,35,0) --Create a model model = Model:Box() model:SetColor(0.0,0.0,1.0) model:SetPosition(3,0,0) while true do if window:Closed() or window:KeyHit(Key.Escape) then return false end Time:Update() world:Update() world:Render() --We're going to transform the plane (1,0,0,0) from global space to the model's local space --Because the model is positioned at (3,0,0) the plane will be at (1,0,0,3) in local space (relative to the model). local p = Transform:Plane(1,0,0,0,nil,model) context:SetBlendMode(Blend.Alpha) context:DrawText(p:ToString(),2,2) context:SetBlendMode(Blend.Solid) context:Sync() end
will error with "attempt to call method 'ToString' (a nil value)" implying the tranformed plane was not returned.