This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nitrogenfingers's profile picture

A little 3D demo in CC

Started by nitrogenfingers, 16 June 2013 - 11:56 PM
nitrogenfingers #1
Posted 17 June 2013 - 01:56 AM
Don't get excited, this isn't anything terribly fancy, just moving around 3D-translated points:

[media]http://www.youtube.com/watch?v=bWns6yyMtvQ[/media]

Edit: I've also managed to get this going. This is a bit fancier, but not much and still a bit clippy:

[media]http://www.youtube.com/watch?v=Md3hzeZQB3I[/media]

So I posted this awhile back saying 'don't get excited', but everyone did anyway and then I got excited so I kept going and it turns out it is pretty cool, and it's moderately reliable. The engine is capable of taking in a series of vertices the user specifies, and a series of indices that specify a triangle list. That list is turned into a face list, which is culled, sorted, projected and rasterized.

The end result means you can create a 3D model of any shape, convex or concave provided that none of the faces intersect. It will not handle that gracefully.

It still has issues as well. Culling doesn't take projection into account so sometimes faces perpendicular to the camera will either not be visible or slightly clip the nearby shape. The triangle fill isn't pixel perfect either- don't expect that, so if you do a wireframe you'll see a few errant pixels outside. So work to be done but it's a promising start.

If you want to muck around with it yourself I've uploaded to code. You need the following:
- render, the executable, at: http://pastebin.com/pRH1A3Hc
- matrix, an API that calculates the transformations, at: http://pastebin.com/a73J8Ndm
- graphics, an API, at: http://pastebin.com/DTxxgZjc
- vertex, another API that doesn't really do anything at the moment but may one day: http://pastebin.com/237H8vGU

Making your own models is a chore. If you've done it manually in XNA or OpenGL before you can have a go but I really don't recommend it. That TIE fighter took about a half hour. But the code is free for you to play with, as always.

-NF
Edited on 28 June 2013 - 06:46 AM
superaxander #2
Posted 17 June 2013 - 01:58 AM
Nice! Another 3d thing on the forums.
theoriginalbit #3
Posted 17 June 2013 - 02:22 AM
As always brilliant!
GravityScore #4
Posted 17 June 2013 - 07:31 AM
Wow, amazing job nitro!
Jarle212 #5
Posted 17 June 2013 - 07:50 AM
I luve it, was waiting for something like this :D/>
wilcomega #6
Posted 17 June 2013 - 09:02 AM
Amazing. when textures will be avalible iw ill make an FPS :3
diegodan1893 #7
Posted 17 June 2013 - 10:56 AM
Amazing job, Nitro
TheOddByte #8
Posted 17 June 2013 - 01:11 PM
Wow this is absolutely awesome!
Another brilliant thing made by you! :)/>
ShadowedZenith #9
Posted 17 June 2013 - 02:18 PM
Extremely impressive.
Shazz #10
Posted 17 June 2013 - 04:10 PM
Wow, I can actually imagine the 3D cube there.
This is amazing, but that much math makes my eyes bleed! :)/>
InputUsername #11
Posted 17 June 2013 - 04:11 PM
Don't get excited, this isn't anything terribly fancy, just moving around 3D-translated points:

'just'. *cough* awesome *cough*

It's more impressive than anything most of us will ever make. One fine masterpiece, Nitrogenfingers!
lieudusty #12
Posted 17 June 2013 - 04:48 PM
Amazing :)/>
Engineer #13
Posted 17 June 2013 - 06:35 PM
This is really great to see.

First something like 3dmaze (look in the programs section) and now this. I can see that 3d is going to be the next thing the coders are focussing on. I cant speak for myself right there though..

This is really brilliant, and Im getting the impression that you think this isnt awesome. It is, and for matter of fact, this can lead to the 'CC 3d evolution'.

You are really brilliant, but that was hopefully clear already :)/>
nutcase84 #14
Posted 17 June 2013 - 08:16 PM
Awesome!!!!!!
Symmetryc #15
Posted 17 June 2013 - 08:23 PM
Nice! :D/>. Is this based off of Gopher's thing?
SuicidalSTDz #16
Posted 17 June 2013 - 08:24 PM
A god amongst men, nitrogenfingers is he.
nitrogenfingers #17
Posted 17 June 2013 - 10:31 PM
I have to say I'm really surprised how positive everyone has been- to me this felt like a very small step, so it's really cool everyone's so excited about it :)/>

I've managed to get a triangle filler implemented, although not very well- it doesn't handle certain angles properly and I have to find some way to deal with the aliasing around the edges which is often horrible. It's locking up from time to time and completely ignoring the bounds I've specified too, so quite a bit to fix with this one.

But for something really hideous you have to see this:
Spoiler

What on earth is that mess of pixels? It's the same cube as above but with all the faces filled in, in no particular order! Depth buffering and face culling is the next job, neither of which hopefully will be too challenging. From there I'll have to come up with some strategy to managed the jagged edges, that I've yet to really sort out.
M4sh3dP0t4t03 #18
Posted 18 June 2013 - 01:14 AM
This is awesome! But how have you learned all the stuff for this?
1lann #19
Posted 18 June 2013 - 01:55 AM
This is awesome! But how have you learned all the stuff for this?
He's like passed/in university :P/>

But yeah, really nice job! :D/>
Mads #20
Posted 18 June 2013 - 03:13 AM
Amazing. when textures will be avalible iw ill make an FPS :3

Implement them yourself. If you cannot do that, you have literally 0 chance of creating a 3D FPS game.
billysback #21
Posted 18 June 2013 - 07:59 AM
what's up with it reflecting back at a very small scale when you send it behind the camera?
this seems like a bug so I thought I might report it :P/>


also, some of your code makes no sense…

local col = world[i].color
is not used, not only is the variable "col" not used but world is never ever given a variable called "color", not until after the loop is finished and world is replaced, at least.

the world.color when set is never used, though I understand why it's there.

also I'm not 100% sure on the usage of this loop

for i,vertex in ipairs(world) do
				    --Applying camera space
				    world[i] = global:apply(vertex)
		    end
I'm kinda tired right now, but surly you could do

		    for i,vertex in ipairs(world) do
				    local vect = global:apply(vertex)
				    local col = vect.color
                    
				    world[i] = graphics.project(vect)
				    --Here until we sort out depth buffering
				    world[i].color = model.colors[i]
				    world[i].dist = distances[i]
		    end
and save it looping through the table once too many times.
I'm not trying to be mean and nit-pick, I was just trying to play around with it and getting confused as hell. Sorry :P/>
SuicidalSTDz #22
Posted 18 June 2013 - 09:16 AM
But how have you learned all the stuff for this?
A god amongst men, nitrogenfingers is he.
I already covered that :)/>

Really nice job man, can't wait till you get all the depth buffering and face culling finished
billysback #23
Posted 18 June 2013 - 07:03 PM
Spoiler

What on earth is that mess of pixels? It's the same cube as above but with all the faces filled in, in no particular order! Depth buffering and face culling is the next job, neither of which hopefully will be too challenging. From there I'll have to come up with some strategy to managed the jagged edges, that I've yet to really sort out.
wow, I just managed to recreate that.
That is impressively messed up though… Mine just looks like a couple of the faces are missing :P/>
I hope you don't mind that I'm working on exactly what you're doing with your code… I just get bored and have no idea about the mathematics behind 3D programming, so I'm unable to make my own engine :(/>

EDIT;
I did it, it renders properly… except my triangle-filling algorithms are terrible so need fixing, I experience randomly appearing holes in my square often.
I don't know if I should share my code, because it's nitro's project… So I won't, but I will share a picture:
Spoiler

EDIT 2;
I fixed my triangle filling code so now everything works like a charm…
but it lags like hell, time to optimize… I still don't know if it's OK that I'm doing this :(/>
I optimized it slightly by only rendering the 3 closest faces of the cube…

EDIT 3;
2 shapes at once! yay!
Spoiler
Kingdaro #24
Posted 18 June 2013 - 08:56 PM
Wonderful, wonderful progress!
nitrogenfingers #25
Posted 18 June 2013 - 09:31 PM
also, some of your code makes no sense…

local col = world[i].color
is not used, not only is the variable "col" not used but world is never ever given a variable called "color", not until after the loop is finished and world is replaced, at least.

[…]

also I'm not 100% sure on the usage of this loop

for i,vertex in ipairs(world) do
					--Applying camera space
					world[i] = global:apply(vertex)
			end
I'm kinda tired right now, but surly you could do

			for i,vertex in ipairs(world) do
					local vect = global:apply(vertex)
					local col = vect.color
					
					world[i] = graphics.project(vect)
					--Here until we sort out depth buffering
					world[i].color = model.colors[i]
					world[i].dist = distances[i]
			end
and save it looping through the table once too many times.

The color code was there because I was doing it as a debug printout to distinguish points. It's legacy code now I've yet to remove.

With regard to the second part, I can't use your function. I separated them into two loops because I need to perform depth buffering on each vertex before applying a projection, as the second you do that you lose your depth information. If you read the project code in the graphics API you'll see it's converting 3D aligned space into 2D screen space, and you can't depth-sort 2D. I hadn't added that function when I uploaded the code.

Your fill looks cool :)/> I don't really mind what you do with my code, wouldnt've shared it if I wasn't happy with people looking at and using it. The maths however I stand by, I'm confident with it and it is solid. The approach you've taken, which sounds like to take the three nearest faces and draw them only is a little different to how it's done with more complex geometry- my approach will be a 'clockwise cull', taking the cross product of each triangle and compare the angle with the camera vector to see whether or not it should be drawn. While it's more computationally expensive, it will work for concave geometry where a simple face filter will not.

The other bug you reported is because there is no culling, which I'm diligently working on now. Hoping to have an update soon, though I said that yesterday :P/>

Edit: one thing though,
also, some of your code makes no sense…
[…]
I'm not trying to be mean and nit-pick, I was just trying to play around with it and getting confused as hell. Sorry :P/>

It's not so much that, but if you don't understand how the code works, it seems a bit unfair to take debug operations or unimplemented features you don't understand and call them nonsensical…
billysback #26
Posted 19 June 2013 - 04:14 AM
sorry, maybe I worded what I was saying a little harshly;
I was just getting a tad confused about some things, to be honest most of your code was astoundingly clear to follow, especially with your comments…
It made me feel bad about my code, it feels like coding without comments is a selfish way of coding :P/>

also, I understand that the way I'm doing it is far less mathematical than a "good" approach to drawing faces, but instead of going and finding out ways of drawing the faces which are showing I figured that CC can only just about handle drawing a few simple cubes which move about, I was skeptical of whether it could handle more advanced shapes that well…

and I never doubted your maths, from what I could understand of it it seemed solid and it obviously worked fine when running, though I have little to no idea about what most of the maths is doing, other than what variables it's producing…
ExE Boss #27
Posted 24 June 2013 - 03:27 PM
Can't wait for this to support NPaintPro images
Bubba #28
Posted 24 June 2013 - 10:46 PM
Awesome looking stuff Nitro. This really caught my eye as I've been looking into 3D graphics quite a bit recently and have found that I really like the whole idea of it. Because of that, I did a bit of searching and bought a book - "Essential Mathematics for Games & Interactive Applications" by James M. Van Verth/Lars M. Bishop. Now I don't expect you to be familiar with it, but I can say that I'm having difficulty learning from the book. One thing that programmers love to do is over-complicate their code and language with terms they've picked up. A lot of it has to do with calculus, which I won't take until next year, and it's been somewhat driving me nuts.

Do you have any books and/or papers you'd recommend to get started with some of the concepts that are integral to 3D and transformation/translation/rendering of vectors/points? That's the part I'm really interested in - the rest will come later when I'm taking Calculus and, after that, some actual Computer Science courses. I've looked through your code and everything makes perfect sense to me. I love trig/trig ratios which are obviously an essential part of 3D mathematics and I do consider myself to be somewhat proficient in them. But the book rarely, if ever, explains what's actually going on in a way that I can understand with my as of yet limited math education. Any progress that I make comes with about a hundred different questions.

Maybe I'll have to wait for college to really get into this, but if you've got any recommendations as to where I can get started I would be forever grateful :)/>

Thanks,

~Bubba

Edit: One thing I should note is that I'm not looking for the really basic stuff. I've found this website and it all makes perfect sense. In fact, I skipped a lot of it because it just seems so… obvious. But that didn't really give me any pointers as to how I'd going about applying perspective/view to points, just how the actual points are manipulated in 3D space. I suppose what I'm really looking for is how to go about converting 3D to 2D.
nitrogenfingers #29
Posted 24 June 2013 - 11:26 PM
I'm sorry for the slow updates on this, I've been faffing with the code a bit, but trying to have something done and ready as soon as possible (once work quietens down a bit).

Maybe I'll have to wait for college to really get into this, but if you've got any recommendations as to where I can get started I would be forever grateful :)/>

I actually don't know where I first learnt how to actually make what I made in this demo- I realized the other week that I actually could make it, and set about doing so. 3D graphics and rendering is largely just linear algebra and geometry, I use little-no calculus in most of my graphics work, and it purely revolves around the idea of performing transformations on matrices. I know I first encountered this in my third year of university, but I had never so much as tried it before, and I have friends who started much earlier so it should be within reach if you've got strong maths skills.

The core idea is simply about converting points between existing spaces, which in turn are just transformations applied based on a general set of formulas and matrices recognized to work. The matrix API I included in the package includes standards for rotations, scales and translations and these are identical to those you'd find in textbooks or built-in to other game development libraries. The link you posted isn't so much about 3D rendering as it is about the underlying principles of linear algebra, and you will need to know those back to front.

My reference is (Akenine-Moller et al.) Real-Time Rendering though it's much more advanced and there are plenty of internet resources that are equally suitable for computercraft at least. I'm afraid to say I don't think there's any easy way to get into it, because it's not easy, so I'm not sure how much advice I can give you. Best of luck all the same :)/>

Edit: I've just looked up the textbook you mentioned and it looks very good- covers the material you'll need to know methodically. A more general text on linear algebra may be more appropriate if you don't understand the concept of affine transformations and matrix spaces well, but I don't think I could recommend a better text. If you're struggling to understand something specific in it, send me a PM and I'll talk you through it.
Edited on 24 June 2013 - 09:31 PM
Bubba #30
Posted 24 June 2013 - 11:45 PM
-snip-

Awesome, thanks for the advice! The main reason I struggle with the book I mentioned is because I've never been taught a good number of the symbols/words used in it, and I assumed they were part of a later math education such as Calculus (or perhaps my teachers have failed me in that area). I'm hardly a math genius, but I'm capable enough to handle the equations they've given me once I dissect the actual meaning of it all.

If I get stuck on anything I'll be sure to PM you. Thanks for the offer!
nitrogenfingers #31
Posted 27 June 2013 - 03:27 AM
This has been a very slow update, and it's not even close to release ready yet. The actual maths behind all this is really simple but what's killing me is trying to make it look good in CC. If anyone has a pixel-perfect triangle fill method they're happy with, send it my way. I've tried about 6 now and all have serious artefacting (still haven't gone baycentric- things aren't that dire yet). This one is a flat bottom/top fill, which often irritatingly leaves a gap between the top and bottom triangle, resulting in scan-lines on the model. I'll try to go from a continuous to a discrete model to fix this when I have more time, but I think a lot of this also has to do with the size of the models. On a large monitor you could probably get a much better output than a standard computercraft terminal.

This is my best attempt so far, and it took me a long while to get that screenshot:



What's cool about this? Well it uses depth-sorting and culling to draw and hide appropriate faces. This approach will work with both convex and concave shapes, which is really nice. What's less nice is for this cube at least without a modelling tool or a model generation algorithm you have to enter your primitive indexes yourself (and they have to be clockwise), which is extremely annoying. I eventually got this cube showing up but it's not something I expect end users to tolerate.

Theoretically though, any shape of model can now be drawn and should render somewhat correctly if you ignore artefacting. You can drawn multiple models and that should work if you depth-sort those as well.

What this system cannot handle is intersecting faces. I'm not using clipping because as bad as artefacting is with rasterization, it'll be 10 times worse if I try and implement Sutherland-Hodgman. It's poor practice to have crossing faces anyway so I'm of two minds if I'll bother to implement this.

I'm disappointed the actual new thing I've added to this thread took about 30 minutes to make but the past week has been mucking with rasterization and trying to make it cooperate with CC, the part that's supposed to be easy. I'll try to have more pictures soon, for those (if any) who are following the post :)/>

Edit: This is a far more representative picture of the issues the current rasterizer has:



Notice the gap between two faces on the cube corner, the space the rasterizer leaves when drawing between the top and bottom triangles on the rightmost orange face, the clipping inconsistency between the purple and light blue faces, and the distortion of the shape near the edge of the orange and yellow faces caused by the gap between the two. I'm not going to go too hard on myself because it's a 15x15 pixel cube- that's smaller than the average mouse cursor, but they're problems I'd like to fix.
billysback #32
Posted 27 June 2013 - 08:12 AM
if all you're looking for is a method to fill triangles at three points on the screen, then you can try the api I made when I was playing with this,
no doubt it's probably far less efficient than other methods you've tried but it works fine :P/>

here's my triapi:
http://pastebin.com/b1tA5e5r

usage for filling a triangle would be:

--getTriangle() returns a table containing the points of a hollow triangle
--fillTriangle() fills this triangle and returns a similar table
--drawShape() handles these "shape" tables and draws them with the background colour, text colour and text you define.
drawShape(fillTriangle(getTriangle({x1, y1}, {x2, y2}, {x3, y3})), colors.red, colors.black, " ")

--there is also a fillSquare method which to draw would simply be:
drawShape(fillSquare({x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}), colors.red, colors.black, " ")

--xn and yn are the x coordinates of the the point n, e.g. point one is {x1,y1} where x1 is the x coordinate of point 1 and
--y is the y cooridinate point point 2
--in fillSquare the points must be in order around the square, the order doesn't matter as long as a point is not followed
--by an opposite point.
--so:
fillSquare({1,1},{1,2},{2,2},{2,1}) --is valid
fillSquare({1,1}{1,2}{2,1},{2,2} --is NOT valid
--because triangles only have 3 points this doesn't matter
nitrogenfingers #33
Posted 28 June 2013 - 08:48 AM
Yay! Triangle rasterization finally working! Check this out:

[media]http://www.youtube.com/watch?v=Md3hzeZQB3I[/media]

Yeah man. 3D TIE Fighters in CC. The future is now :)/>

Seriously though it was a pain to make. I need to find a better way of making models. Either a modelling tool or procedural generation, and I can tell you which of the two I'd rather do!
wilcomega #34
Posted 28 June 2013 - 09:28 AM
Amazing work agian, cant wait for more! :)/>
ikke009 #35
Posted 28 June 2013 - 10:14 AM
Amazing work :D/> I loved the tie fighter
Julgodis #36
Posted 29 June 2013 - 01:05 PM
After seeing your first video, I realized that i could probably make my own version of this. And I could,
it took time but was worth it :P/>

Here is my 3D cube:



My render does use both ModelView and Projection Matrix so i have all cool things like FOV, AspectRatio
and more..
Here is my triangle fill algorithm: http://joshbeam.com/..._rasterization/

Here is the same 3D cube but in wireframe:


I did more then just render a model i did an API so "every one" can use it
the API implantation is design to be to be as much as OpenGL as possible.

Here is an example:

-- This code render a quad on the screen

gl:matrixMode('PROJECTION')
gl:loadIdentity()
gl:perspective(60, WIDTH/HEIGHT, 0, 100)

gl:matrixMode('MODELVIEW')
gl:loadIdentity()

gl:scale(scale)
gl:rotate(rotateX,  1,  0,  0)
gl:rotate(rotateY,  0,  1,  0)
gl:rotate(rotateZ,  0,  0,  1)
gl:translate3(translate)
gl:_begin('TRIANGLES')
gl:color(graphics.colors.red)
gl:vertex3(vector.new(-1.0, -1.0, 1.0))

gl:color(graphics.colors.red)
gl:vertex3(vector.new(1.0,  1.0,  1.0))

gl:color(graphics.colors.red)
gl:vertex3(vector.new(-1.0, 1.0,  1.0))

gl:color(graphics.colors.green)
gl:vertex3(vector.new(1.0,  -1.0, 1.0))

gl:color(graphics.colors.green)
gl:vertex3(vector.new(1.0,  1.0,  1.0))

gl:color(graphics.colors.green)
gl:vertex3(vector.new(-1.0, -1.0, 1.0))

gl:_end()


The API is not available yet but will be soon :rolleyes:/>
Good job and thank you for the idea Nitrogenfingers
Jarle212 #37
Posted 29 June 2013 - 02:23 PM
Awsome, can't wait to make a doom replica(maybe) out of this :D/>
jesusthekiller #38
Posted 30 June 2013 - 02:32 PM
First something like 3dmaze

You saw it :D/>

EDIT: 400th post! Yay!
Pinkishu #39
Posted 30 June 2013 - 03:32 PM
Amazing. when textures will be avalible iw ill make an FPS :3

Implement them yourself. If you cannot do that, you have literally 0 chance of creating a 3D FPS game.

How does that make any sense? You don't have to know how the graphics engine you use works internally in order to make a game with it.
billysback #40
Posted 30 June 2013 - 04:51 PM
Amazing. when textures will be avalible iw ill make an FPS :3

Implement them yourself. If you cannot do that, you have literally 0 chance of creating a 3D FPS game.

How does that make any sense? You don't have to know how the graphics engine you use works internally in order to make a game with it.
I think he's implying that the programming/mathematical capabilities required to make textures work with this are less than they are to make a FPS game;
nitro did most of the hard work for us so adding basic shape-filling function in to his code is relatively simple, I somewhat agree that if you can't manage that I doubt you could manage an FPS game, especially in as harsh an environment as CC, where simply moving one of these cubes with the current code(s) causes at least some frame rate issues…

he wasn't asking him to make the graphics engine, he was asking him to make just part of it, probably one of the more simpler parts, though the way nitro did it screws that idea over…

whatever… I'll stop talking now
nitrogenfingers #41
Posted 01 July 2013 - 12:16 AM
I'm more than a little confused… if you don't mind my asking what have I screwed over?

I haven't written any API's to make working with the renderer easy, though I don't think it'd be hard to apply movement and rotation to your own models. I'm inclined to agree with pinkishu on this, that you don't really need to understand the underlying maths to be able to render and use your own models, and you don't need typically to understand how an engine is implemented to use it- that's just common sense.

But this isn't an engine; it's really just a glorified point transformer. As billysback says, the code is non-optimal and expensive to perform real-time (though I haven't tested it on a slower machine yet). I haven't implemented functions like ray-intersects-triangle or point unprojection that you'd need for interactive 3D, so I guess it'd be hard to make any heavy-duty 3D game at the moment. It also lacks clipping, so while it can handle a few models on screen (all I ever intended to do), I doubt large environments are possible.

I genuinely do not understand how implementing projected texture mapping would help in writing an FPS, any more than learning to knit a lampshade with your feet would help. The skill sets do not intersect, and the comment comes off sounding silly, and arbitrarily elitist.
billysback #42
Posted 01 July 2013 - 06:13 AM
Nitro, I was saying that in my eyes the triangle filling implementation was rather simple, but when you described some of the methods you used I realized how very wrong I was >.<

I wasn't insulting anyone or anything :P/>

but I was just rambling, I thought that both comments where rather harsh but that the second one seemed to be utterly disregarding the first one; I was trying to make them see the sense (or at least the sense I read) behind the first comment, as they asked how it makes any sense…
Pharap #43
Posted 08 July 2013 - 01:48 AM
Ah Matrices, my constant foe.
I can use them, but damned if I know how they work.
I must admit though, seeing source like that for a Matrix implementation will probably help me understand them when I can be bothered to read through it and not completely distracted as usual.

Guessing by graphics you either haven't got round to doing projection matrices or you're not going to use matrices to handle projection.

Closest I've ever come to anything like this was when I made a depth-sorting algorithm using Linq.
Yes I know that's not what Linq is for, but it worked, even if it was only a depth-sorting algorithm.

No, wait, I tell a lie, I did make a circle-drawing algorithm for the CC computers.

It's a shame that CC didn't support more colours. Even if you could only use 8-16 colours onscreen at a time, it would still open up the possibility of basic shaders like Phong shading and such. In fact 16 shades of greyscale would be better for shaders than the current setup.

Anyway, I'll stop my rambling now.

Very good work, I hope this project lives on.
TheOddByte #44
Posted 09 July 2013 - 06:52 AM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>

Also, Are you going to try to make circles next?
Like earth or something :3
M4sh3dP0t4t03 #45
Posted 09 July 2013 - 09:27 AM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>

Also, Are you going to try to make circles next?
Like earth or something :3
Circles in games are often just lots of triangels
ShadowedZenith #46
Posted 09 July 2013 - 09:33 AM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>

Also, Are you going to try to make circles next?
Like earth or something :3
Circles in games are often just lots of triangels

Models in general in games are often just a lot of polygons :P/>. They can either be triangles or quads, and sometimes (pretty rarely, it seems?) they use voxels instead of the classic polygon.
Pharap #47
Posted 09 July 2013 - 02:06 PM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>

Also, Are you going to try to make circles next?
Like earth or something :3

Most 3D games don't actually use circles, they just make stuff with polygons, circles would be more of a 2D thing.
I do however know of a few algorithms for making 2D circles if you want to know some.
nitrogenfingers #48
Posted 10 July 2013 - 07:27 PM
Also, Are you going to try to make circles next?
Like earth or something :3

I am indeed planning to try making planets- this I'll do by producing a UV Sphere , which you can think of as a sphere segmented into square faces.

The one example I know of making 3D circles or at least curvature is by Bezier lines. I may actually give this a go- no idea how it'll turn out in CC of all things but it may be cool. After all, it looked great in this game:

Pharap #49
Posted 10 July 2013 - 10:28 PM
I am indeed planning to try making planets- this I'll do by producing a UV Sphere , which you can think of as a sphere segmented into square faces.

The one example I know of making 3D circles or at least curvature is by Bezier lines. I may actually give this a go- no idea how it'll turn out in CC of all things but it may be cool. After all, it looked great in this game:

Keep this up and we'll all be writing .obj importers.

Of course bezier curves open up the possibility of motion curves, though at this rate I doubt the CC computers will be able to keep up.
ds84182 #50
Posted 11 July 2013 - 03:53 PM
So, I kinda did some stuff (gamax92 and I) and now I have this running on CCLights2.

http://www.youtube.com/watch?v=8c8WeurOXRk
nitrogenfingers #51
Posted 11 July 2013 - 07:31 PM
Wow that looks surprisingly smooth! Nice stuff :)/> Have to clean up those clipping issues though.
Pharap #52
Posted 11 July 2013 - 11:04 PM
Unfortunately I doubt it will run that smooth in minecraft.
Good to see something as complex as a tie fighter can be achieved.

Even if this won't run smoothly enough in minecraft for a game, 3D animations are certainly possible.
An update of 'a long time ago' perhaps?
gamax92 #53
Posted 12 July 2013 - 01:55 AM
Even at super resolution, it does run smoothly and at a full 20fps. I did my initial port in actual minecraft and it ran pretty good. There are still a few issues (atleast when i gave ds84182 the code) to be worked out but so far it looks pretty nice.
Pharap #54
Posted 14 July 2013 - 01:47 AM
Even at super resolution, it does run smoothly and at a full 20fps. I did my initial port in actual minecraft and it ran pretty good. There are still a few issues (atleast when i gave ds84182 the code) to be worked out but so far it looks pretty nice.

Hopefully a graphics-speed enhancing system I'm working on will help speed things up.
The system is a bit hit and miss because of what it does, but generally it results in a speed increase.
Technically it's finished, but I'm a tiny bit reluctant to release the source and the forums won't accept bytecode, so until then I'm in live-lock.

Do you have a copy of the source for your benchmark test?
I'd like to see what FPS I manage to get out to see if my system can be of any use.
Antelux #55
Posted 19 July 2013 - 11:39 PM
One Word: Epic.

Great Job :)/>
Fifi #56
Posted 21 July 2013 - 06:43 AM
It's extremly nice that you've done it using Vanilla ComputerCraft. :D/> Do you have any calculations of FPS achieved during the real time rendering?
ElectricOverride #57
Posted 16 August 2013 - 02:14 AM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>/>

Also, Are you going to try to make circles next?
Like earth or something :3
Dont you mean spheres?

Also, Are you going to try to make circles next?
Like earth or something :3

I am indeed planning to try making planets- this I'll do by producing a UV Sphere , which you can think of as a sphere segmented into square faces.

The one example I know of making 3D circles or at least curvature is by Bezier lines. I may actually give this a go- no idea how it'll turn out in CC of all things but it may be cool. After all, it looked great in this game:

What game is that?
theoriginalbit #58
Posted 16 August 2013 - 02:25 AM
What game is that?
Reverse Google Image search returned "Frontier Elite 2"
Jarle212 #59
Posted 17 August 2013 - 05:21 PM
Great work nitro!
Just saw your new video and I was simply amazed! :)/>/>

Also, Are you going to try to make circles next?
Like earth or something :3
Dont you mean spheres?

Also, Are you going to try to make circles next?
Like earth or something :3

I am indeed planning to try making planets- this I'll do by producing a UV Sphere , which you can think of as a sphere segmented into square faces.

The one example I know of making 3D circles or at least curvature is by Bezier lines. I may actually give this a go- no idea how it'll turn out in CC of all things but it may be cool. After all, it looked great in this game:

What game is that?

Probably circles and not spheres. Think 2D images would be better than a polygon sphere
Ki7654 #60
Posted 26 September 2013 - 03:30 AM
One word. WOW!
Nasso #61
Posted 14 June 2015 - 03:43 PM
I saw your 3D demo, it's awesome ! But how do you convert 3D vector (x, y, z) to 2D screen coordinates (x, y) ? I know how to do transform with a matrix, but how to display 3D vectors on screen ? Thanks!
CrazedProgrammer #62
Posted 14 June 2015 - 09:36 PM
I saw your 3D demo, it's awesome ! But how do you convert 3D vector (x, y, z) to 2D screen coordinates (x, y) ? I know how to do transform with a matrix, but how to display 3D vectors on screen ? Thanks!
The basic idea is how bigger the z, how further it is into the screen.
The calculations are:
cx = x / z
cy = y / z
nitrogenfingers #63
Posted 16 June 2015 - 12:04 PM
There are a few different methods. I just do a simple shearing calculation to make it 'look' like it's in perspective because it's cheap and works for simple applications, but isn't recommended for more complex scenarios. A better approach is to use what's called a 'projection matrix', which modifies the points according the aperture and lens width of your camera.

My cheap little method is in the 'render' source code file. You can find equations for orthographic and perspective matrices to get your vectors into projected space here: http://www.codinglabs.net/article_world_view_projection_matrix.aspx
jerimo #64
Posted 16 June 2015 - 04:40 PM
Haven't read the code, but seeing as it was written quite a while I'm guessing it simply writes to the screen? I've heard of the term blitting to be much quicker, maybe if an upgrade is made it would be capable of doing more than rendering a cube or two?
nitrogenfingers #65
Posted 17 June 2015 - 03:09 AM
Yeah it uses term.write as everything does (or did). Blitting may well speed the program up, but the issue with this engine at least was not so much speed but a few deficiencies in implementation like the inability to properly render intersecting faces, culling that doesn't take projection into account, long inner frustrum length and so on. I think other programs have been developed or are in development that will overcome these issues, and though I keep intending to go back and update this code, I haven't yet managed.
jerimo #66
Posted 17 June 2015 - 05:54 AM
Yeah it uses term.write as everything does (or did). Blitting may well speed the program up, but the issue with this engine at least was not so much speed but a few deficiencies in implementation like the inability to properly render intersecting faces, culling that doesn't take projection into account, long inner frustrum length and so on. I think other programs have been developed or are in development that will overcome these issues, and though I keep intending to go back and update this code, I haven't yet managed.
Ah, alright. Well best of luck then!

Side note: you are he reason I got into CC, so thanks for that!
Nasso #67
Posted 18 June 2015 - 01:53 PM
You MUST create a real 3D engine ! NitroGEngine !
Edited on 24 June 2015 - 08:19 AM
omitspace #68
Posted 23 November 2015 - 03:30 PM
There are a few different methods. I just do a simple shearing calculation to make it 'look' like it's in perspective because it's cheap and works for simple applications, but isn't recommended for more complex scenarios. A better approach is to use what's called a 'projection matrix', which modifies the points according the aperture and lens width of your camera.

My cheap little method is in the 'render' source code file. You can find equations for orthographic and perspective matrices to get your vectors into projected space here: http://www.codinglabs.net/article_world_view_projection_matrix.aspx

How come you perform your matrix translations as

1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
x, y, z, 1
instead of

1, 0, 0, x
0, 1, 0, y
0, 0, 1, z
0, 0, 0, 1
like Coding Labs does in the link you mentioned?
What would the difference be between these two formats?
Edited on 23 November 2015 - 04:46 PM