-
Posts
3,946 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by macklebee
-
The problem with using a CSG cylinder instead of a model is that its origin is at the center and not at the base (or the feet like with a character model). If you look at the SetInput() example, notice that the 'visiblecapsule' cylinder is set as a child to the pivot (which is the actual player) and the cylinder's center is positioned up 1 meter from the ground.
-
Ma-Shell obviously knows his vector math but like the OP, vector math has always been a struggle for me though I can handle 3D geometry fair enough . I have to break vector math down into steps that I can understand and follow, So even though you have an answer already (but past my ability to follow), I decided to take a crack at this. I used multiple references and I will post them with the steps as this was a fun learning experience for me. So the problem was to find pointD given this information: Given: 3 points given are all on the same plane, points A, B, & C The angle between VectorA-B and VectorA-C is equal to angle between VectorA-B and VectorA-D The distance from point A to point D is known Find: point D Assumptions: The three given points are not collinear to allow for determining the plane equation Due to equal angles between vectors, VectorA-MirroredPoint is the reflected vector of VectorA-C across the mirror plane that is along VectorA-B Solution: To reflect a point across the mirror plane, we must first find the plane that the three given points (A,B, and C) are located. Once we have planeABC, then the mirror plane will be orthogonal to that plane and pass through the line or vector AB. Once the mirror plane is determined, then we can mirror the point. And finally determine the point along the line where the fixed length would occur. 1) Find the plane that contains points A, B, and C. Using the 3 points, you can calculate two vectors: 1a) Find the two vectors given the 3 points - A, B, & C. --Finding a 3D line through 2 points --https://www.youtube.com/watch?v=JlRagTNGBF0 Vab = FindVector( pointA, pointB ) --vector AB Vac = FindVector( pointA, pointC ) --vector AC 1b) Get the normal vector to two vectors. --Equation of a Plane Passing Through 3 Points --https://www.youtube.com/watch?v=0qYJfKG-3l8 normalvector = FindNormalOfTwoVectors( Vab, Vac ) 1c) Get the Plane Equation using the normal vector and a point --Note that you can use any of the 3 points above and get same answer. plane = GetPlaneEquation( normalvector, pointA ) 2) To find orthogonal plane for mirror/reflection, we need two vectors and point on the plane -Just like before! --Find the Equation of Plane Containing a Line and Orhtogonal to a Given Plane --https://www.youtube.com/watch?v=aupy5wwAyb8 2a) The normal of planeABC is a vector on the Mirror plane Vn = FindNormalVectorOfPlane(plane) 2b) We want the mirror/reflection plane to also contain vector AB - which we have already found = Vab. Find the normal vector to the two vectors. Mirror_normalvector = FindNormalOfTwoVectors(Vn, Vab) 2c) Now get the Mirrored Plane's Equation using pointA or pointB and its normal vector Mirror_plane = GetPlaneEquation(Mirror_normalvector, pointA) 3) Now that we have the reflection plane that that runs through line AB, lets mirror pointC about it --Find Mirror Image of a Point Reflected on Vector Plane --https://www.youtube.com/watch?v=fvXG-DVx6z0 pointMP = FindMirroredPoint(Mirror_plane, pointC) 4) Find pointD that is Dist_AD from pointA --Finding a point along a line in 3D given 2 points --Used alternative method shown at bottom of page --https://math.stackexchange.com/questions/83404/finding-a-point-along-a-line-in-three-dimensions-given-two-points pointD = FindPointAlongLine(pointA, pointMP, Dist_AD) Scripts: Vector_Plane_PointReflection_Equations.lua contains the functions shown above Vector_Plane_PointReflection_Equations.lua Main.lua contains the example script that shows how to use the functions Main.lua
-
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.
-
Unfortunately this does not work in lua: plane = Plane(p1, p2, p3) but thanks for trying, anyways.
-
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
-
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
-
Importer of FBX models broken into 4.6 Leadwerks
macklebee replied to Yue's topic in General Discussion
Converted to mdl and loaded fine for me. Even looks like a nice box once I added a material and fixed the normals. -
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)
-
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.
-
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.
- 1 reply
-
- 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 reply
-
- 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?
-
This for LE4 or "turbo"?
-
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.
-
Importer of FBX models broken into 4.6 Leadwerks
macklebee replied to Yue's topic in General Discussion
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. -
Importer of FBX models broken into 4.6 Leadwerks
macklebee replied to Yue's topic in General Discussion
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.