32DGE engine

Ive been working on a 3d game engine written in pure java and I have a version Im happy to show.
current support:
basic shapes such as squares
drawing vertexs
functional camera
3d line renderer
infinate 3d plane
Full bitmap texture support
future support:
More complex shapes such as tetrahedrons
optimising rendering algorithms and determining weather and object is behind the camera (working on currently)
support for a map array to store blocks

The updated code will happily render 4000 cubes (no line removing algorithms for things like behind block) at 30 fps when the camera is focusing on a few a constant 200 fps can be expected
here is the picture!
http://gyazo.com/d40e865eb0bace45c9c47fb70f529729

a wall of 2000 blocks (using a slightly more optimised code) at 50 fps

More progress to come in the future!

#######update!#######
So I have been considering merging my old 2DGE project some of you might remember. However they will both be rewritten from scratch ( on the 3DGE just optimisation will occur) This will be released as a full graphics engine sometime in the future quite far in the future as I have a large amount of school work.

Also a quick note, I have finalised the algorithm for rendering textures on the side of object (it will support custom image sizes in the future) For now its 32 by 32 for simplicity. More features such as a cameracontroller and an actual release will come soon when basic support for cubes and face rendering only if visible.

LATEST UPDATE: TEXTURES!

fully supporting all size textures I would like to thank this genius over here ----> http://www.java-gaming.org/index.php?topic=25271.0 Of course the code isnt perfect when implemented in mass so im doing some optimisations but I was struggling to understand it until I saw that so big thanks.

Welp time for the pics!

With a few more frame tests I have massive improvements. the ability to render 500,000 textured and scaled triangles at 10 fps.

This is really cool! ;D
Are you using any engines to make it, JOGL or LWJGL?
In the distant future will there be physics?

Nope pure java no external engines. Possibly its mainly just a graphics test

Thats really sick. How do you plan for objects to no longer be rendered once they get behind the camera?

Honestly I have no clue I need something that could figure this out it would be a real help.

I was going to to say, if you’re using OpenGL, 2000 x 4 = 8000, and 8000 vertices isn’t that much when rendering, and 50 FPS seems kind of low. Come to think of it, that seems a little low for Java2D, also. What kind of rendering are you using? A bufferedImage or are you literally calling drawSquare in the Java graphics library?

using a buffered image here is the rendering algorithm I use. This is unoptimised code like seriously unoptimised


public void drawline(int x, int y, int xx, int yy) {

		double grad = Math.atan2(xx - x, yy - y);
		double cx = x;
		double cy = y;
		double dist = Math.sqrt((Math.abs(xx - x)) * (Math.abs(xx - x))
				+ (Math.abs(yy - y)) * (Math.abs(yy - y)));
		double nx = Math.sin(grad);
		double ny = Math.cos(grad);
		for (int i = 0; i < dist; i++) {
			cx = (i*nx)+x;
			cy = (i*ny)+y;
			if (cx < core.WIDTH && cy < core.HEIGHT) {
				if (cx > 0 && cy > 0) {
					core.screen.map[(int) cx][(int) cy] = 0xFF00FF;
				}
			}
		}

	}

	public void drawnet(vertex v1, vertex v2, vertex v3, vertex v4, Camera c) {
		vertex[] v = new vertex[4];
		Positionalobject[] po = new Positionalobject[4];
		for (int i = 0; i < 4; i++) {
			po[i] = new Positionalobject();
		}
		v[0] = v1;
		v[1] = v2;
		v[2] = v3;
		v[3] = v4;
		for (int i = 0; i < 4; i++) {
			double tx = v[i].x - c.x;
			double ty = v[i].y - c.y;
			double tz = v[i].z - c.z;
			if (tz < 500) {
				double sinex = Math.sin(c.rotx);
				double cosx = Math.cos(c.rotx);
				double cosy = Math.cos(c.roty);
				double siny = Math.sin(c.roty);
				double dx = 0;
				double my = 0;
				double mz = 0;
				double dz = 0;
				dx = tz * siny + tx * cosy;
				dz = tz * cosy - tx * siny;
				my = ty * cosx - dz * sinex;
				mz = dz * sinex + dz * cosx;
				
				double nx = (dx) * (scalex / mz) + (core.WIDTH / 2);
				double ny = (my) * (scaley / mz) + (core.HEIGHT / 2);
				nx = (scalex * dx / mz) + (core.WIDTH / 2);
				ny = (scaley * my / mz) + (core.HEIGHT / 2);
				double mmz = ((mz-c.z)+(nx-c.x));
				po[i].x = nx;
				po[i].y = ny;
				po[i].z = mmz;
			
			}

		}
		if (po[0].x < core.WIDTH && po[0].y < core.HEIGHT && po[0].x > 0
				&& po[0].y > 0) {
			drawline((int) po[0].x, (int) po[0].y, (int) po[1].x, (int) po[1].y);
			drawline((int) po[1].x, (int) po[1].y, (int) po[2].x, (int) po[2].y);
			drawline((int) po[2].x, (int) po[2].y, (int) po[3].x, (int) po[3].y);
			drawline((int) po[3].x, (int) po[3].y, (int) po[0].x, (int) po[0].y);
		}
	}

edit just to note its not 8000 verticies its 22000 lines. as its not faces im drawing its full cube nets so rougly 16000 verticies.

This is amazing! Are you modelling this after lwjgl, with matrices and such?

Ah good old 3d math ::slight_smile: gotta love it! This is pretty cool. can I ask where exactly you got the math from?

The only question I have is where did you get those fancy Eclipse colors? :stuck_out_tongue:

HAh go onto youtube and look for something like darkmoon eclipse color. vanzeeban did one. To be honest I have never really used an external library. The math is from a site called gamdev.net.

Im thinking of upgrading the renderer though so instead of rendering as full shapes or lines I do sides this will allow facing comparison alot like minecrafts render technique. If a tile is facing another tile directly it is not drawn vice versa.

Quick test: in eclipse it seems 4000 blocks or rather 48000 lines is 30 fps :smiley:

Amazing piece of work!

Discussion about greedy meshing, You might be interested

"To be honest I have never really used an external library. "
I havent ever either. I like doing things myself.

Sorry its not 48000 lines it 96000 this is because it overlaps when drawing faces at the moment. Also I tested this on a computer with only standard intel graphics, double buffering and a core2duo (the cheaper range of them) I got 25fps as average for 96000 lines.

Also I have evaluated the use of the two mesh rendering techniques I came up with. the 1st choice which is to render lines across would be more efficient as its not rotating every single pixel in the shape.

Thanks for that link im going to try out a few methods including some more abstract ones that draw immediately.

Just a quick update: Finally supporting x and y axis rotation along with starting rendering of faces still trying to find a fast algorithm for that but lots of playing with it :slight_smile:

Sweet! When is the texture update coming? :point:

When I can finally get my head around the line algorithm :D.