• Do not use Works in Progress as a way of avoiding the releases system! Works in Progress can be used for sharing early betas and for getting suggestions for improvement. Releases of finished content are not allowed in this forum! If you would like to submit a finished addon, click here for instructions on how to do so.

Ors' Random Whims

Status
Not open for further replies.

Ors

Custom User Title
I think I need a thread for my projects in case I'll do them as much as I've planned to do. (Extremely unlikely) I was a little bored and wanted to do some stuff with Lua.

I recently tried some graphical things with OpenGL, and I thought why not drawing triangles and stuff in Lua as well. I haven't also seen easy RGB colors in SRB2's Lua before. Here are two things I'd like to show in action: A function that draws triangles, and a function that converts RGB-values to SRB2's Palette.

This is what the drawing function looks like:
Code:
//The main Drawing function
local function DrawScene(v, p)
	// Setting up points for a triangle
	local p1 = vec2(100 + cos(20000000*leveltime)*100/FRACUNIT, 0)
	local p2 = vec2(160, 50+sin(15000000*leveltime)*50/FRACUNIT)
	local p3 = vec2(50+sin(10000000*leveltime)*50/FRACUNIT, 160)
	// RGB color for the triangle
	local r = sin(20000000*leveltime)
	local g = sin(-20000000*leveltime)
	local b = sin(20000000*leveltime)
	// Draw the triangle (point1, point2, point3, color, drawer)
	DrawTriangle2D(p1, p2, p3, ColorToPalette(vec3(r, g, b)), v)
	// Draw the gradient color thing pixel by pixel
	// Demonstrating the function that converts RGB values to palette colors
	for i = 0, 31
		for j = 0, 31
			r = i*FRACUNIT/32
			g = j*FRACUNIT/32
			b = FixedMul(r,g)
			v.drawFill(100+i, 50+j, 1, 1, ColorToPalette(vec3(r, g, b)))
		end
	end
end

And here's the result:
BewitchedDeafeningKillerwhale-size_restricted.gif
 
Last edited:
Soo...

Sonic R-obo Blast 2 when?
When someone makes as optimized and fast Lua than the original SRB2's code =P

Anyway, a little progress has been made. Rotation matrices rotate the cubes, the world when camera rotates, and the player and its movements. Projection is done by dividing xy-coordinates by z (or yz by x, conversion is done in the calculations). After that we check if we can draw a triangle. If its points aren't behind the player and its points' projection's determinant is greater than 0, we can.
CornyBrightAmericanpainthorse-size_restricted.gif


(Btw, the models are drawn in the right order. There's no depth comparison at the moment)

EDIT:
Let's actually show the cubes from another direction for lulz =P
SpiritedOblongHippopotamus-size_restricted.gif
 
Last edited:
This is pretty interesting so far. I wonder what you're doing will all this...?
 
This is pretty interesting so far. I wonder what you're doing will all this...?

Nice question. So far, this has been made just for the fun of doing it. Maybe there'll be some application for this later.
 
That's amazing. I wish I understood how to program 3D space using only 2D coordinates.
 
When someone makes as optimized and fast Lua than the original SRB2's code =P

Anyway, a little progress has been made. Rotation matrices rotate the cubes, the world when camera rotates, and the player and its movements. Projection is done by dividing xy-coordinates by z (or yz by x, conversion is done in the calculations). After that we check if we can draw a triangle. If its points aren't behind the player and its points' projection's determinant is greater than 0, we can.
CornyBrightAmericanpainthorse-size_restricted.gif


(Btw, the models are drawn in the right order. There's no depth comparison at the moment)

EDIT:
Let's actually show the cubes from another direction for lulz =P
SpiritedOblongHippopotamus-size_restricted.gif
Holy assbiscuits!
That REALLY gives me a PS1 vibe!
 
My gosh, this is incredible. I tried to do something like this once but the wireframe alone was horribly inefficient. What kind of framerates are you getting? Do you plan to add any sort of primitive lighting or texture mapping?
 
My gosh, this is incredible. I tried to do something like this once but the wireframe alone was horribly inefficient. What kind of framerates are you getting? Do you plan to add any sort of primitive lighting or texture mapping?

The FPS depends on how many faces you have to draw and how big part of the screen the shapes take. Right now the limit for me is ~150 faces before you can see the frames dropping clearly. I have thought about lighting, and very basic lighting could be reasonably fast. Texture mapping is out of question though. Now the triangles and quadrilaterals are drawn line by line in single color except of pixel by pixel. With textures that would be more complicated. Maybe someone else can try if they have ideas for execution and power in their computers.

Edit: You mentioned wireframes. Don't give up on that.
CrispAcrobaticAmericanpainthorse-size_restricted.gif
 
Last edited:
This is very reminiscent of the Chaotix special stages. I'm curious if that could be replicated using these tricks.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top