Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Posts posted by Einlander

  1. I would like something like Context::DrawPoly( {table of Vec2()} )

     

    While doing the 2d drawing, I found that using a scanline fill will IMMENSELY cripple the engine. if you scan-line draw (line by line) 3 squares on screen, you can see an fps drop from 200fps down to 40. and about 7fps if you use debug.

     

    This would help reduce the amount of code needed for gui libraries, and help raise the fps count.

    • Upvote 1
  2. My mind doesn't do curves, humans, animals or plants. Been practicing for years. Ask me to model anything not alive and I can do it in my sleep. Some people just aren't good at it, that's why there are special job positions for them at game studios.

    • Upvote 1
  3. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextsetscale-r728

     

    I wanted to scale my GUI using the setscale command and found some of the drawing commands do not function correctly.

     

    The drawrect command works properly.

     

    The plot command does not scale at all.

     

    The line command does not work properly in straight lines horizontally or vertically, but it does diagonally.

     

    Hear is code to test and explain:

     

    --This function will be called once when the program starts
    function App:Start()
    
    --Initialize Steamworks (optional)
    --Steamworks:Initialize()
    
    --Set the application title
    self.title="MyGame"
    
    --Create a window
    local windowstyle = window.Titlebar
    if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end
    self.window=Window:Create(self.title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle)
    
    --Create the graphics context
    self.context=Context:Create(self.window,0)
    if self.context==nil then return false end
    
    return true
    end
    
    --This is our main program loop and will be called continuously until the program ends
    function App:Loop()
    
    --If window has been closed, end the program
    if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end
    
    
    --Update the app timing
    Time:Update()
    
    
    self.context:SetScale(2,2) -- everything should be twice as big
    
    self.context:SetColor(self:rgbatovec4scalar({255,255,255},255))
    self.context:DrawRect(0,0,200,200) -- This is the size the line squares should be at
    
    
    self.context:SetColor(self:rgbatovec4scalar({100,100,100},255))
    for y = 1 , 200 do -- this should make a solid square, not rectangle
    self.context:DrawLine(5, y , 205, y ) -- draw square at an offset so you can see its dimensions in a relative manner
    end
    
    self.context:SetColor(self:rgbatovec4scalar({80,100,100},10))
    
    for x = 5 , 205 do -- this should make a solid square also
    self.context:DrawLine(x, 5 , x, 205 ) -- draw square at an offset so you can see its dimensions in a relative manner
    end
    
    self.context:SetColor(self:rgbatovec4scalar({255,0,0},255))
    self.context:DrawLine(0,0,200,200) -- the line is off from actuall 0,0 by a few pixels but it is the size
    
    self.context:SetColor(self:rgbatovec4scalar({0,255,0},255))
    self.context:Plot(200,200) -- this should actually be at the edge of the white box but its at real cordinates 100,100
    
    --Refresh the screen
    self.context:Sync(true)
    
    --Returning true tells the main program to keep looping
    return true
    end
    
    function App:rgbatovec4scalar(rgb,a)
    return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256)
    end

     

    As long as this is does not function as intended, my gui will have to be put on the backburner.

  4. While coding my lua GUI I found that I needed to be able to fill many 2d polygons. After looking at quite a few algorithms (I am very bad at math), I found one created in lua and felt that I needed to share.

     

    It was converted from the Corona lua which was in turn converted from PSP lua. I have modified it to work without change in Leadwerks

     

    See here for examples on how it works: http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/

     

    function rgbatovec4scalar(rgb,a)
    return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256)
    end
    
    function paintPoly(poly, xoffset, yoffset, rgba)
    -- [url="http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/"]http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/[/url]
    local math_floor = math.floor
    local math_min = math.min
    local math_max = math.max
    local polyGroup = {}
    
    local n = table.getn(poly)
    
    local minY = poly[1].y
    local maxY = poly[1].y
    
    for i = 2, n do
    	minY = math_min(minY, poly[i].y)
    	maxY = math_max(maxY, poly[i].y)
    end
    
    for y = minY, maxY do
    
    	local ints = {}
    	local int = 0
    	local last = n
    
    	for i = 1, n do
    		local y1 = poly[last].y
    		local y2 = poly[i].y
    		if y1 < y2 then
    			local x1 = poly[last].x
    			local x2 = poly[i].x
    			if (y >= y1) and (y < y2) then
    				int = int + 1
    				ints[int] = math_floor((y - y1) * (x2 - x1) / (y2 - y1) + x1)
    			end
    		elseif y1 > y2 then
    			local x1 = poly[last].x
    			local x2 = poly[i].x
    			if (y >= y2) and (y < y1) then
    				int = int + 1
    				ints[int] = math_floor((y - y2) * (x1 - x2) / (y1 - y2) + x2)
    			end
    		end
    		last = i
    	end
    
    	local i = 1
    	while i < int do
    polyfillcontex = Context:GetCurrent()
    polyfillcontex:SetColor(rgbatovec4scalar(rgba,rgba[4]))
    polyfillcontex:DrawLine(ints[i] + xoffset, y + yoffset, ints[i + 1] + xoffset, y + yoffset)
    		i = i + 2
    	end
    end
    
    return polyGroup
    end
    

    • Upvote 1
  5. Um, Tesseract does have GI. It's in the video on the site and in the text under the video.

     

    "The new rendering features include fully dynamic omnidirectional shadows, global illumination, HDR lighting, deferred shading, morphological/temporal/multisample anti-aliasing, and much more."

     

    PBR is still new so very few engines have it.

  6. In the Leadwerks editor it use to have the bottom console visible by default or hidden if you hide it. Now its always hidden when you load the editor regardless of what you set it at previously.

     

    Many times I start the editor and load my map and miss all the red text telling me things are potentially wrong.

     

    I would request an option or the ability to keep the position of the editor console constant between sessions.

  7. root mass to 0 and object mass to .1. The engine still exhibits drag/friction with no gravity. Things set in motion eventually stop, you may seg fault or run out of space before it does though. You can check this out by making in a flat surface to walk on, a prop with weight, and the fps creator. Set the gravity to 0 and walk into a movable object. it will move and eventually stop. You can walk off your walking surface and you will not fall off. Oddly you can still walk around without ground.

×
×
  • Create New...