-
Posts
3,946 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by macklebee
-
-
I do not see any vegetation shaders being used in these material files - does that mean you are hand placing these tree models into your scene and not using the vegetation tool? If you are using the vegetation tool available in the Terrain tool options, then I would recommend using vegetation shaders as well or you will get weird artifacts/shadows.
Also, zsort on the leaves' material is enabled - that will affects the shadows that occur on the leaves and maybe related to what you are seeing here? Also you are not using a shadow shader for the leaves' material.
Typical pine leaf material for a model that will be used with the vegetation tool:
//Leadwerks Material File blendmode=0 castshadows=1 zsort=0 cullbackfaces=0 depthtest=1 pickmode=0 depthmask=1 diffuse=0.501960814,0.501960814,0.501960814,1.00000000 specular=0.000000000,0.000000000,0.000000000,0.000000000 alwaysuseshader=0 roughness=0.50000000000000000 mappingscale=1.00000000,1.00000000,1.00000000 drawmode=-1 shader="Shaders/Model/leaves.shader" shader1="Shaders/Model/Shadow/shadow+alphamask.shader" shader3="Shaders/Vegetation/leaves.shader" shader4="Shaders/Vegetation/Shadow/leaves.shader" texture0="./pine-leaf-fresh-diff.tex" texture1="./pine-leaf-fresh-norm.tex"
-
12 hours ago, Josh said:
Note that Lua arrays are 1-based. Don't start with zero.
yep - sorry i forgot to mention that above but I was getting ready to leave for work when i posted
-
table.sort() will sort the table alphabetically.
mitem ={} mitem[1] = "Wood" mitem[2] = "Steel" mitem[3] = "Concrete" mitem[4] = "Rubber" System:Print("Unsorted Table******") for k,v in ipairs(mitem) do System:Print(v) end table.sort(mitem) System:Print("Sorted Table********") for k,v in ipairs(mitem) do System:Print(v) end
will result in the following output:
QuoteUnsorted Table******
Wood
Steel
Concrete
Rubber
Sorted Table********
Concrete
Rubber
Steel
Wood- 1
-
5 hours ago, tipforeveryone said:
yesterday my Leadwerks was still normal, but today, I get this problem with FPS, anyone has any idea about which caused this ?
Sunspots? Deep-state machinations? Chem-trails? hard to say what would cause that... mostly because you don't give any information at all or an example that could be tried. Maybe you need to reboot you computer? Is this a video of the game being ran from the editor? Is this a release version that you are running independent from the editor but you still have alot of other programs running in the background? Is this a debug version? what is the viewrange on your camera? on the vegetation? Asking because it appears the drops occur when the camera is able to view large sections of the vegetation/terrain. But again, just complete guesses...
-
I can't say based on the information why your text is not clearing out properly. Maybe you need to redraw the panel or the label? - not enough info to try to recreate but this simple example seems to work:
window = Window:Create("Label Example",0,0,400,300,Window.Titlebar + Window.Center) context = Context:Create(window) gui = GUI:Create(context) base = gui:GetBase() base:SetScript("Scripts/GUI/panel.lua") text1 = "Center with border and vertical align" text2 = "" widget = Widget:Label(text1,20,20,300,80,base) widget:SetString("align","Center") widget:SetString("valign","Center") widget:SetBool("border",true) toggle = 0 while not window:KeyHit(Key.Escape) do if window:Closed() then return false end if window:KeyHit(Key.Space) then toggle = 1 - toggle if toggle == 1 then widget:SetText(text2) else widget:SetText(text1) end widget:Redraw() end context:Sync() end
As for color - this seems like its a huge class member missing from the Widget class? Not sure why there isn't a way to set the colors of your widgets or text. The label.lua script has no mention of color. The panel.lua script has color being set but its all hardcoded and I haven't been able to change the colors by accessing the apparent color related members. So unless you decide to start rewriting a lot of the scripts, I am not sure you can change the Widget colors inherently - which just seems to be a fairly large omission? Maybe I am missing something.
-
Try using this shader to rotate your images: drawimage_rotating.shader
Example script that shows usage:
window = Window:Create("draw rotating image",0,0,600,400,Window.Titlebar+Window.Center) context = Context:Create(window) imageshader = Shader:Load("Shaders/Drawing/drawimage_rotating.shader") imageshader:SetVec2("pivotposition", Vec2(150.0, 37.5)) --center of image angle = 0 image = Texture:Load("Materials/Developer/leadwerks.tex") while window:KeyDown(Key.Escape)==false do if window:Closed() then break end context:SetColor(1,.3,0) context:Clear() angle = angle +1 defaultshader = context:GetShader() context:SetBlendMode(Blend.Alpha) --Draw Image context:SetColor(1, 1, 1) context:SetShader(imageshader) imageshader:SetFloat("angle", angle) context:DrawImage(image, 150, 150, 300, 75) context:SetShader(defaultshader) context:DrawText(string.format("FPS: %.2f",Time:UPS()), 0 ,10) context:SetBlendMode(Blend.Solid) context:Sync(true) end
Video of this and other similar shaders:
- 3
-
Is the weapon a prefab or a model? Asking because sometimes this doesn't work for prefab parent meshes - only the child mesh. On models, it appears to work all the time. Anyways, this is how you get the name like as shown in the editor when placed in a scene:
entity:GetKeyValue("Name")
-
-
So in your code, you are just constantly creating a shape every cycle of the loop? Seems like that would be something you would want to do in the start code not the loop? thats a lot of shapes being created every second... not to mention the number of surfaces you were making in the first example... Is this your actual code that you are having problems with or just something you are doing to show your problem?
-
Can confirm - same happens if you try to use GetPickMode(). But interestingly enough it appears that if you set the pick mode via the Material Editor it will work as expected. But just from my small test it appears to be a slow process for it to ignore the object based on the material's pick mode setting - seemed to make the program stutter a bit.
-
Maybe try updating the surface after adding all the vertices/triangles and prior to using it in the PolyMesh()?
-
6 minutes ago, Yue said:
I appreciate your answer, and I apologize if my questions bother you since I'm a rookie.
Not a bother - but some of the questions you post could be answered easily by yourself if you learn how to do simple troubleshooting. Think how much farther along you could get in your project if you didn't have to post constantly and wait for someone to tell you the answer, if only you could learn how to start troubleshooting your own code. The link to System:Print() was meant to help you as it appears you are new to programming in general.
- 1
-
12 hours ago, Phodex Games said:
This topic is poorly documented
If you notice those commands are not in the official documentation - ergo, not officially supported which means they can change at any time or be removed. But in any case, you should be able to find button hover appearance changes from various examples over the years here. Basically you could just load other brighter button images to be used when the mouse is hovering or maybe you could try changing the SetColor() value when hovering? But in any case, I suspect you will have to rewrite several parts of the inherent GUI code to take in account your images now. If this is something you want to learn how to do on your own or you just want something that does it for you, you could try Aggror's free gui .
- 1
-
I would assume its due to trying to hide an entity that doesn't exist. Start your indice at 0 and decrement the loop's end value by 1.
for indice = 0, self.Vehiculo:CountChildren() - 1 do llantas[ indice ] = self.Vehiculo:GetChild( indice ) llantas[ indice ]:Hide() end
Also - you should learn to use System:Print() as its a very useful troubleshooting command. Use it to see where your code is failing and what the status of a variable is when the code stops working. It will save yourself some time instead of having to post asking questions on how to troubleshoot your own code.
- 1
-
Why don't you try it yourself and then post your example if you get stuck on something? People are more willing to help if you show that you have put in a little effort on your own. Start with the example here: https://www.leadwerks.com/learn?page=API-Reference_Object_Vehicle_Build and work from there. Go through the different vehicle commands and try to understand them. Also keep in mind that you KNOW that vehicles are not exactly in great working condition right with the latest version.
- 1
-
Not enough info to tell but I suspect this is not a bug. More than likely its an issue with mixing local, global, and/or screenspace positions.
-
Zoom when wanting to zoom in on things far away like with binoculars and fov when wanting to increase/decrease the horizontal field of view like peripheral vision..
-
I can't tell from your post if you have a horizontal compass working or not, which is somewhat independent from finding the angle between a player and a target in relation to the player's direction. If you are asking to get the horizontal compass working, calculate the relative angle, and also make the target show up on the compass as well, then this will be a fairly large discussion. And it's another reason why the techass forum is garbage, if this will be a lengthy discussion about multiple things regarding drawing a hud, calculating the relative angle, etc instead of one just concise question about one facet.
In any case, if you are just wanting to calculate the relative angle, then you have to calculate the angle between the player and the target based on their global positions, determine the Y-rotation of the player, and then subtract the two.
Example script:
Script.player = "" --entity "Player Entity" Script.target = "" --entity "Target Entity" Script.angle = 0 function PerfectAngle(pos1,pos2) local dx, dz dx = pos2.x - pos1.x dz = pos2.z - pos1.z return Math:ATan2(dx,dz) end function NormalizeAngle(angle) if angle <= 0 then return angle + 360 else return angle end end function Script:UpdateWorld() self.perfectangle = PerfectAngle(self.player:GetPosition(true),self.target:GetPosition(true)) self.angle = self.player:GetRotation(true).y - self.perfectangle end function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) context:DrawText(string.format("Angle between Player to Target: %.0f",NormalizeAngle(self.angle)),2,22) context:SetBlendMode(Blend.Solid) end
Place a pivot into a scene and attach this script. Drag the Player and Target entities into the Script's Property dialog and run the game.
- 3
-
-
There is also a way to center text inherent to LE in available parameter settings not in the official documentation, but was posted at one point in the gui development blog,
virtual void DrawText(std::string& text, const int x, const int y, const int width, const int height, const int style = 0);//lua
So in your example, I would set the x and y positions as the upper left hand corner of the circle's image and the width/height as the width and height of the circle.
Example showing drawing text within the center of a rectangle where the text width is changing and the style parameter settings are keeping it centered:
window = Window:Create("example",0,0,400,400) context = Context:Create(window) world = World:Create() light = DirectionalLight:Create() light:SetRotation(45,45,0) camera = Camera:Create() camera:SetPosition(0,0,-3) counter = 1400 toggle = 0 myfont = Font:Load("Fonts/arial.ttf", 36) context:SetFont(myfont) while not window:KeyHit(Key.Escape) do if window:Closed() then return false end if toggle==1 then counter = counter + 10 end if toggle==0 then counter = counter - 10 end if counter>=1400 then toggle = 0 end if counter<=10 then toggle = 1 end Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:SetColor(1,0,0,.5) context:DrawRect(38,30,300,300,1,30) context:DrawText(string.format("%.0f",counter),38,30,300,300,Text.VCenter+Text.Center) context:SetColor(1,1,1,1) context:SetBlendMode(Blend.Solid) context:Sync(true) end
- 1
-
8 minutes ago, Yue said:
Well, I'm telling you that even though it's at zero, the lightning still detects the ground from the cone. I'm confused. I'm confused.
You are doing a World Pick on the global Y-axis from +10 to -10. The pick is returning that it successfully picked something between these two points. The raycast is not from the cone. The raycast starts at the (0,10.5) point in space. The raycast ends at (0,-10,5), If it hits anything, it will return true. You have the cone sitting right where this raycast is occurring. It is hitting the cone. Try reading the documentation and try out the examples. World:Pick()
- 1
-
Have I mentioned how much I dislike the tech *** forum? Fixed the OP's issue, but who knows because if the OP likes the answer, it removes the post from the order of the discussion. ****ing Garbage.
Anyways. your choices for SetPickMode() as found in the documentation:
- 0: pick tests will skip this entity.
- Entity::SpherePick: a sphere test with the entity pick radius will be used.
- Entity::PolygonPick: if the entity is a model or a brush, a precise polygonal pick test will be performed.
- Entity::BoxPick: a box test with the entity pick radius will be used
I'd advise you to RTM. <<-- polite version.
And no, you can't see the "beam". You can draw the "beam" if you wish using DrawLine or creating/scaling a polygon model from the start and end pick points. There are examples of this if you search the forum for "beam"
- 1
-
The pick is working - you just are not confirming if the pick is occurring correctly.
if mundo:Pick(0, 10, 5,0, -10, 5, pis,1.0, true ) then ventana:Closed() end
ventana:Closed() does not close the window, it only checks if the window has been closed. Refer to the documentation: Window:Closed()
I would suggest doing a 'System:Print()' as a way to confirm if the pick was successful. But if you really want to exit the program after the first loop when the pick is successful then change the code to this:
if mundo:Pick(0, 10, 5,0, -10, 5, pis,1.0, true ) then System:Print("Pick Successful") return false end
Edit -- also, unless the user knows exactly what they are doing and what to expect, I would advise you to stay away from giving your pick a radius as its slower and may give unwanted results. I'd advise you to use the precise raycast by using a radius of '0'.
- 2
-
Sets the damping value of a physics body. Damping slows the velocity and omega each frame by a small amount.
Example:
window = Window:Create("Linear Damping Example",0,0,800,600,Window.Titlebar+Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetPosition(0,10,-6) camera:SetRotation(45,0,0) light = DirectionalLight:Create() light:SetRotation(35,35,0) ground = Model:Box(50,1,50) ground:SetPosition(0,-0.5,0) ground:SetColor(0,1,0) shape = Shape:Box(0,0,0, 0,0,0, 50,1,50) ground:SetShape(shape) shape:Release() box = {} for i = 1, 3 do box[i] = Model:Box() box[i]:SetColor(1-0.5*(i-1),-0.5*(i-1),.5) shape = Shape:ConvexHull(box[i]:GetSurface(0)) box[i]:SetShape(shape) box[i]:SetPosition(-8+i*4,1,0) box[i]:SetMass(1) box[i]:SetDamping(1-0.5*(i-1),1.0) end while window:KeyHit(Key.Escape)==false do if window:Closed() then break end if window:KeyHit(Key.Space) then for i = 1, 3 do box[i]:AddForce(0,0,1000,true) end end Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:DrawText("Linear Damping (from left to right): 1, 0.5, 0",2,2) context:DrawText("Press SPACE to apply the same force to all boxes!",2,22) context:DrawText("The higher the damping-value, the faster the box stops.",2,42) context:SetBlendMode(Blend.Solid) context:Sync(true) end
- 1
- 1
Modelling scale for Leadwerks / Maya
in General Discussion
Posted
The default I believe in the editor is in centimeter as far as creating CSG objects, but all LE entity commands that use any positions/distances as a parameter/setting is using meters.