Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Posts posted by Einlander

  1. Think interpolation, As you get farther from an entity or have a certain amount of entities on screen you reduce the amount of animation steps you actually Process.

     

     

    Look at the Creatures in the background. The animation is in sync but the number of animation frames processed is reduced.

  2. The default character controller is programmed to update on physics instead of on world. This gives it constant motion that is independent of fps. On leadwerks the physics is already time adjusted. Your version will start to misbehave on very high or low fps. This becomes a concern when you have to do something within a set time. If fps is low the time will run out before your done, if its high you will be done before the time runs out.

  3. So I worked on this some more and ran into a few issues and some questions. Can sprites cast shadows? If no then it will cause problems with immersion. For example power lines outside in the day. I would expect those to have shadows. Next is you can't attach joint's to a mesh without bones as far as I know. So since we are generating the rope on the fly this is a no go. Finally slack in a rope. You can define the number of control points and how much slack they have from the next point. This is done by offsetting the control points by the slack amount on the z axis. This is a recipe for disaster.

     

    My solution that I'm going explore something that I found n some unity forums. They simply create a mesh with vertexes at each joint location and deform it to match the joints location as it moves.

     

    I have some family business to attend to so the next presentation may take a while.

    • Upvote 1
  4. Here's what a night of no sleep accomplishes.

     

    So this is an almost complete dynamic rope creation system. You create 2 pivots, one start, one end. You attach this script to the start and drop the end entity on the end point box. It will then string joints between the 2 points. You can set the amount of slack there is in the rope.

     

    To make it hang from the ceiling like a gymnasium rope or a broken power-line, just add mass to 1 of the ends.

     

    There is a debug mode that will show the actual pivot/joint locations. The start is green and the end is blue. The rope goes from black to red as it reaches the end.

     

    WHAT NEEDS TO BE DONE:

    Sprites need to be added to make it look like an actual rope. The rope is invisible when not in debug mode so not much use yet...

     

     

    
     
    --[[
    Dynamic Rope Alpha
    By Einlander
    Description: Creates a rope between 2 points
    Instructions: Create 2 pivots, attach this script to the start, and drop the end on the End point box, adjust settings and go.
    
    TODO: Add sprites to actually draw the rope.
    ]]--
    
    Script.EndEntity = nil -- entity "End Point"
    Script.Sections = 8 -- int "Sections"
    Script.Mass = 5 -- float "Mass"
    Script.Slack = 0 -- float "Slack"
    Script.Debug = false -- bool "Debug Mode"
    Script.Info = 0 --choice "Info" "Dynamic Rope Alpha,VERSION .01, By Einlander"
    
    
    function Script:Start()
    	if self.EndEntity == nil then
    		Debug:Error("End Point Entity Empty")
    	end
    	if self.Sections < 2 then
    		Debug:Error("Sections must be 2 or greater")
    	end
    	
    	-- Create boxes at start and finish
    	if self.Debug == true then
    		self.startpoint = Model:Sphere(3,self.entity)
    		self.startpoint:SetScale(.1,.1,.1)
    		self.startpoint:SetColor(0,1,0)
    
    		self.endpoint = Model:Box(self.EndEntity)
    		self.endpoint:SetScale(.1,.1,.1)
    		self.endpoint:SetColor(0,0,1)
    	else
    		self.startpoint = Pivot:Create(self.entity)
    		self.endpoint = Pivot:Create(self.EndEntity)
    	end
    
    	start1 = self.entity:GetPosition(true)
    	end1 = self.EndEntity:GetPosition(true)
    
    	-- place midpoints
    	local i
    	self.midpoints = {}
    	local midpoint = self.entity
    	table.insert(self.midpoints, midpoint)
    	self.joints= {}
    
    	for i = 1, self.Sections do
    		if self.Debug == true then
    			print(i/self.Sections)
    		end
    	-- Math formula from
    	--http://stackoverflow.com/questions/2886092/finding-coordinates-of-a-point-between-two-points
    	--https://archive.is/ME00H [ archive just in case]
    		result = Vec3()
    		result.x = (start1.x + (i/(self.Sections)) *(end1.x - start1.x))
    		result.y = (start1.y + (i/(self.Sections)) *(end1.y - start1.y))
    		if (i~= self.Sections) then
    			if self:IsEven(i) == true then
    				result.y = result.y + self.Slack
    			else
    				result.y = result.y + (self.Slack * -1 )
    			end
    		end
    
    		result.z = (start1.z + (i/(self.Sections)) *(end1.z - start1.z))
    		if self.Debug == true then
    			local midpoint = Model:Box()
    			midpoint:SetScale(.1,.1,.1)
    			midpoint:SetColor((i/(self.Sections)),0,0)
    			midpoint:SetPosition((result),true)
    			midpoint:SetMass(self.Mass)
    			table.insert(self.midpoints, midpoint)
    		else
    			local midpoint = Pivot:Create()
    			midpoint:SetPosition((result),true)
    			midpoint:SetMass(self.Mass)
    			table.insert(self.midpoints, midpoint)
    		end
    	end
    	local midpoint2 = self.EndEntity
    	table.insert(self.midpoints, midpoint2)
    
    	--set joint physics
    
    	--start anchor
    	local temppos = self.midpoints[1]:GetPosition(true)
    	local tempjoint = Joint:Ball(temppos.x,temppos.y,temppos.z,self.midpoints[2] ,self.midpoints[1])
    	tempjoint:DisableLimits()
    	table.insert(self.joints, tempjoint)
    	--middle points
    	for i = 2, #self.midpoints do
    		local temppos = self.midpoints[i-1]:GetPosition(true)
    		local tempjoint = Joint:Ball(temppos.x,temppos.y,temppos.z, self.midpoints, self.midpoints[i-1])
    		tempjoint:DisableLimits()
    		table.insert(self.joints, tempjoint)
    	end
    	--end anchor
    	local temppos = self.midpoints[#self.midpoints]:GetPosition(true)
    	local tempjoint = Joint:Ball(temppos.x,temppos.y,temppos.z, self.midpoints[#self.midpoints],self.midpoints[#self.midpoints])
    	tempjoint:DisableLimits()
    	table.insert(self.joints, tempjoint)
    end
     
    function Script:IsEven(number)
    	if (number % 2 == 0) then
    		return true
    	end
    	return false
    end

     

     

    Q3XzScA.png

    • Upvote 3
  5. You simply can not use a regular dll for lua. It must be built for lua http://lua-users.org/wiki/CreatingBinaryExtensionModules and http://lua-users.org/wiki/CreatingBinaryExtensionModules . If you really want to use a dll, there are probably ways to do it, but all of them are non trivial. I recommend luajit because leadwerks supports that. http://luajit.org/ext_ffi_tutorial.html

     

    Quick and dirty:

     

    
    

    local ffi = require( 'ffi' )

    ffi.cdef [[

    int GetSystemMetrics(int test);

    ]]

    local user32 = ffi.load(ffi.os == "Windows" and "user32" )

    error("Screen Dimensions " .. tostring(user32.GetSystemMetrics(0)) .. "x" .. tostring(user32.GetSystemMetrics(1)))

     

    You will be searching through header files.

  6. I want to take a physics file and apply it to another model. I would request it be added to the Model editors physics menu option.

     

    My use case scenario:

     

    I have a open box. Players can place objects into it. NOW is where everthing goes to hell. The player now should be able to carry this box. Polymesh is out of the running because those cant move, all of the other options other decomposition makes closed shells, and decomposition cant handle concave shapes well. You can no longer save csg as a physics shape. This leaves a handmade shape. You can add physics shapes to the model in a 3d editor but in game this will remove your ability to interact with the entity. So you have to be able to create a physics shape externally. This is no longer possible in the current incarnation of Leadwerks. To solve this I have to do an end run around the ENTIRE phyics system to do a simple task.

     

    Current process:

    Create mesh fbx, export.

    Create physics fbx, export (these are 2 separate ).

    In Leadwerks load the physics fbx.

    Open explorer window and find the collision phy.

    Rename collision phy to the mesh phy

     

    This use to be in Leadwerks, it's in the legacy options but there needs to be a way to do this in the new beta and going forward. The engine should not be removing features, it should be refining them. Things it doesn't need should be hid in a menu option because someone somewhere was using it .

    • Upvote 1
  7. My biggest problem is the massive fps drop that Leadwerks has. One more day runs at a good 4 - 15 fps on my computer, my game was RUTHLESSLY optimized so that the lights wouldn't kill the fps. Any time I want to add a light, I have to think do I really want that there. There can never be more than 4 lights on, and the Directional light will cripple my game play, YET I can run Dying Light at 60fps, all Source games except Cs:Go in excess of 100 FPS. There are some optimizations to be had. If we could work on the engines rendering above all else, I would be happy.

     

    -A Frustrated AMD R9 270x 4gb Crossfire user.

    • Upvote 2
  8. At the top of Script:UpdatePhysics() add

     

    self.entity:AddForce(0,10,0)
    

     

    This will make you float as if gravity was reversed. Play with it to get the right number for your game. Using the mass generally works fine.

     

    For your jumping you will need to do a bit more work. You have to make sure that you are touching the ceiling (raycast up to make sure it's there), you need to cancel the airborne check, you need to set the jumpforce to -1 and manually push the player.

     

    self.entity:AddForce(0,(mass * jumpforce ) *-1,0)
    

    This is a good place to start.

     

    Also, you may want to rotate the camera on the z axis by 180, and reverse the mouse look controls (multiplying the result by -1 usually reverses it.)

     

    Now the hard part. Your arms and weapons need to be rotated too. Also if you are able to carry things

     

    Start with walking

    Then Jumping.

    Carrying seems to work fine.

    Then weapons and arms.

  9. It might help if you asked the question in the other thread so people can see exactly what you are trying to do. So let me try to understand. You want to specify a start and end point. Then you want to have joints automatically generated in between?

     

    So wouldn't you specify the start point and then end point, then divide the distance between them by the number of ball joints you need. The first ball joint would be the child of the start point, the second would be the child of the first and parent of the third and so on. when you get to the last one you assign that to be the parent of the end point.

     

    I would do some pseudo -code, but I haven't slept in a while....

    • Upvote 1
×
×
  • Create New...