Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Everything posted by Einlander

  1. Does this help? http://www.leadwerks.com/werkspace/topic/13488-simple-per-entity-no-gravity
  2. The gotopoint function returns weather or not you can reach the point, so you have to actually call the command again to start moving
  3. 5. You can create filters/folders. In the entity list right click on a folder and select 'New Filter' and stick them all in the folder
  4. Yeah it takes a while, I bought some stuff yesterday night and it took a few hours.
  5. Can we see the code that you used to make this happen?
  6. I wouldn't trust it too much, there are bugs that make it completely unrecoverable. Rotating a prefab is one of the almost unrecoverable bugs.
  7. For people who are looking for the above link, it was moved here: https://www.gametextures.com/putting-your-texture-in-an-alpha-channel-using-photoshop/
  8. You can use Gimp, Krita, Paint.net, Fire Alpaca and many, many, more free and or open source tools to add an alpha texture. It should be similar to the photoshop method but there are some program specific terms. Photoshop is just a generic term/tool now, the same way Xerox is.
  9. Are you trying to save some settings so it will be the same the next time they start the game, or just do you just want it to save just for that 1 game?
  10. I've been staring at this code for way too long and now I need different brains to look at it. This is the beginnings of a 3rd person character controller. I am now working at adding mouse look features but there seems to be a bug when the camera is at specific angles, notable y45 and y270. At those specific locations the camera glitches out. I will give it another try tomorrow, and no I don't want to create a pivot and anchor the camera to it and spin that --[[ Title: Third Person Controller Author: Einlander Start Date: 1-30-2016 Version: .01 Description: Script to control Player in 3rd person with keyboard and mouse Notes: This script is designed to mimic classical 3rd person game controls: *Look with mouse *Move with WASD *Follow Player as they move ]]-- Script.Cam =nil --entity "Camera" Script.moveSpeed = 2.5 --float "Move Speed" Script.speedMultiplier = 1.5 --float "Run Multiplier" Script.strafeSpeed = 4 --float "Strafe Speed" Script.jumpForce = 8 --float "Jump Force" function Script:Start() self.input={} self.unitangle = Vec3() self.anglemagnitude = nil end --[[ function Script:UpdateWorld() end --]] function Script:UpdatePhysics() local movex=0 local movez=0 self.input[0]=0 self.input[1]=0 local playerMovement = Vec3() -- I learned the boolean shortcuts from my years programming on a Casio Graphing Calculator self.input[1] = self.input[1] + ((window:KeyDown(Key.W) and 1 or 0) - (window:KeyDown(Key.S) and 1 or 0)) self.input[0] = self.input[0] - ((window:KeyDown(Key.A) and 1 or 0) - (window:KeyDown(Key.D) and 1 or 0)) playerMovement.z = self.input[1] * self.moveSpeed -- Strafing playerMovement.x = self.input[0] * self.moveSpeed if self.carryingEntity == nil and window:KeyDown(Key.Shift) then playerMovement.z = playerMovement.z * self.speedMultiplier -- Run while Strafed -- playerMovement.x = playerMovement.x * self.speedMultiplier end local jump = 0 if window:KeyHit(Key.Space) and self:IsAirborne() == 0 then jump = self.jumpForce playerMovement = playerMovement * 1.6 end self.entity:SetInput(0, playerMovement.z, playerMovement.x, jump , false, 1.0, 0.5, true) local startpos = Vec3( self.entity:GetPosition(true).x, self.entity:GetPosition(true).y + 5 , self.entity:GetPosition(true).z -5 ) -- y distance to get above players head, z - distance we want from player local endpos = Vec3() -- rotate the starting position (where the camera is at) around the player position if self.rot == nil then self.rot = 0 end self.rot = self.rot+.5 local finalpos = Vec3() finalpos = self:rotateX3D({startpos},self.entity:GetPosition(true) , 0)[1] finalpos = self:rotatePointY({finalpos},self.entity:GetPosition(true) , self.rot)[1] -- when self.rot ~ 45 or 270 it flips just for that 1 angle -- set camera at the final rotated positon self.Cam:SetPosition(finalpos) -- make camera look at player local lookAt = self:LookAt(self.entity:GetPosition(true)) lookAt.z = 0 -- THIS LINE IS IMPORTANT. DO NOT REMOVE IT, IF YOU DO IT WILL CAUSE A JUMP WHEN THE Z ANGLE CHANGES FROM NEGATIVE TO POSITIVE OR VICE VERSA self.Cam:SetRotation(lookAt,true) end function Script:IsAirborne() return self.entity:GetAirborne() and 1 or 0 end function Script:LookAt(lookAt) --http://www.leadwerks.com/werkspace/topic/10191-short-example-of-mathatan2/page__hl__lookat --http://stackoverflow.com/questions/1251828/calculate-rotations-to-look-at-a-3d-point --http://leadwerks.wikidot.com/wiki:face-entity --// Calculate angle from point A towards point B local tv = lookAt - self.Cam:GetPosition(true) local tRoty = Math:ATan2(tv.x, tv.z) local tRotx = 0 if lookAt.z >= self.Cam:GetPosition(true).z then tRotx = -Math:ATan2(tv.y* Math:Cos(tRoty), tv.z) else tRotx = Math:ATan2(tv.y* Math:Cos(tRoty), -tv.z) end tRotz = Math:ATan2( Math:Cos(tRotx), Math:Sin(tRotx) * Math:Sin(tRoty) ) return Vec3(tRotx,tRoty,tRotz-90) end function Script:Get3dDistance(pointa --[[as vec3--]], pointb--[[as vec3--]]) --[[as float--]] return math.sqrt((pointb.x - pointa.x)^2+ (pointb.y - pointa.y)^2+ (pointb.z - pointa.z)^2) end function Script:Get3dMagnitude(pointa --[[as vec3--]]) --[[as float--]] --http://www.fundza.com/vectors/normalize/ return math.abs(math.sqrt((pointa.x * pointa.x)+ (pointa.y * pointa.y)+ (pointa.z * pointa.z))) end function Script:NormalizeVector(pointa--[[as vec3--]], length--[[as float--]])--[[as vec3--]] --Yes I know leadwerks has these functions built in somewhere, but sometimes you just need to learn what it is you are exactly doing --http://www.fundza.com/vectors/normalize/ pointa.x = pointa.x / math.abs(length) pointa.y = pointa.y / math.abs(length) pointa.z = pointa.z / math.abs(length) return pointa end toRadians = function(degrees) return degrees / 180 * math.pi end function Script:rotatePointY(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local x = origin.x + ( math.cos(toRadians(degrees)) * (point.x - origin.x) - math.sin(toRadians(degrees)) * (point.z - origin.z) ) local z = origin.z + ( math.sin(toRadians(degrees)) * (point.x - origin.x) + math.cos(toRadians(degrees)) * (point.z - origin.z) ) point.x = x point.z = z table.insert(pointsout, point) end return pointsout end function Script:rotatePointZ(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local x = origin.x + ( math.cos(toRadians(degrees)) * (point.x - origin.x) - math.sin(toRadians(degrees)) * (point.y - origin.y) ) local y = origin.y + ( math.sin(toRadians(degrees)) * (point.x - origin.x) + math.cos(toRadians(degrees)) * (point.y - origin.y) ) point.x = x point.y = y table.insert(pointsout, point) end return pointsout end function Script:rotatePointX(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local y = origin.y + ( math.cos(toRadians(degrees)) * (point.y - origin.y) - math.sin(toRadians(degrees)) * (point.z - origin.z) ) local z = origin.z + ( math.sin(toRadians(degrees)) * (point.y - origin.y) + math.cos(toRadians(degrees)) * (point.z - origin.z) ) point.y = y point.z = z table.insert(pointsout, point) end return pointsout end function Script:rotateX3D (points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local y = point.y; local z = point.z; point.y = origin.y + (y- origin.y) * math.cos(toRadians(degrees)) - (z - origin.z) * math.sin(toRadians(degrees)); point.z = origin.z + (z- origin.z) * math.cos(toRadians(degrees)) + (y - origin.y) * math.sin(toRadians(degrees)); table.insert(pointsout, point) end return pointsout end function Script:WrapAngle(angle) local currentrotation = angle if currentrotation.x < 0 then currentrotation.x = 359 - math.mod(currentrotation.x , 359) end if currentrotation.y < 0 then currentrotation.y = math.mod(currentrotation.y , 359) currentrotation.y = 359 - math.abs(currentrotation.y) end if currentrotation.z < 0 then currentrotation.z = 359 - math.mod(currentrotation.z , 359) end currentrotation.x = math.mod(currentrotation.x , 359) currentrotation.y = math.mod(currentrotation.y , 359) currentrotation.z = math.mod(currentrotation.z , 359) return currentrotation end --[[ function Script:Collision(entity, position, normal, speed) end --]] --[[ function Script:Draw() end --]] --[[ function Script:DrawEach(camera) end --]] --This function will be called after the world is rendered, before the screen is refreshed. --Use this to perform any 2D drawing you want the entity to display. function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) local pos = self.Cam:GetRotation(true) local outText = "Actual angle" .. pos.x .. "|" ..pos.y .."|" ..pos.z --local outText = self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).x .."|" .. --self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).y .."|" .. --self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).z context:DrawText(outText,0,150) context:DrawText("Distance:" .. self:Get3dDistance(self.Cam:GetPosition(true) , self.entity:GetPosition(true)),0,165) pos = self.unitangle local outText = "unit angle" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,180) pos = self.Cam:GetPosition(true) local outText = "Cam Position" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,195) pos = self.entity:GetPosition(true) local outText = "Player Position" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,210) end --[[ --This function will be called when the entity is deleted. function Script:Detach() end --]] --[[ --This function will be called when the last instance of this script is deleted. function Script:Cleanup() end --]]
  11. No rigging or animation. The hard surface modeling is good, if you have the skills, which I don't. I use it mostly for painting.
  12. I have a professional version of 3d-coat, tax returns make you reckless....
  13. Take a look at this thread. http://www.leadwerks.com/werkspace/topic/10046-what-3d-modeling-tools-do-you-use-what-do-you-recommend/ These days I use Shade 3d. Though i don't use blender I still tell people to give it a try. Also not on The list is Sweet Home 3d. It is a opensource simple 3d architecture program.
  14. Welcome to the prefab bug club! This one too. http://www.leadwerks.com/werkspace/topic/10208-initial-move-of-a-texture-locked-prefab-shifts-texture/
  15. From what I heard he rage quit his engine and opengex format.
  16. setting #define TERRAIN_LOW_FREQUENCY_BLEND to 1.0 seems to fix it, setting it to 0.0 mad it have a red tint to it. How would I go about reversing the texture on the y axis?
  17. But at the default height of the fps controller, I should not see the texture fade. What if I was painting snow, as I will be. It will draw a second ~*8 scale texture on top which may cause unintended visuals. What if it introduces an additional displacement? Shadmar, I'll try that when I get home.
  18. Now this is getting frustrating. 4 months later this is still around. I started trying to make my winter games entry and discovered that it's still messed up. Anyway, I did some more experiments, other than the texture being backwards, The large normals are from the mipmap when you are far away. Both the diffuse and normal are still showing. If you use a high contrast texture like I use, you can see that some of the lines have 2 colors on them.
  19. Shader tool is not a visual shader creator. You have to manually create the shader. It allows you to edit shaders without having to have to load a game engine.
  20. I kind of need it to update when you change the values. My game uses it. All the materials that use csg's are scaled at 2.5 and I cant create a material and have to save and open the project to view it properly.
  21. Einlander

    sync

    I use vsync so i can gauge what other users may experience. and it makes slowdowns blatantly obvious. It also introduces input lag, and the leadwerks occluder cant keep up with it.
  22. It's not a waste, it's just the initial setup that is a pain. once you have the model loaded and textured (the have a pass-through shader to assist in this) it makes it easier to do things. IN leadwerk you have the engine doing the loading and the rendering for you, in shader tool you have to do that in provided nodes and connect them. Once it's all set up that's where the difference is, in leadwerks you will need to code all uniforms you want to pass in and manually code them in lua. In shader tool you add the uniform and connect a slider to it and edit the input values in real-time. So leadwerks: Easier setup, and tedious to edit. Shader-tool tedious to setup, easy to edit.
  23. I just dont have the patience to make a shader currently. Also leadwerks does some of the heavy lifting. It loads the models, textures and cameras. all you need to do is use the built in shader editor.
×
×
  • Create New...