3d Graphics (no Java3D)
I was just wondering how many are there that are doing "un-javalike" programming? What I mean is 3d graphics, gaming, generally anything that is more suitable for something like C++. I'm especially interested in java 3d engines and demo effects. I don't want any code or help, I just wish to know what you have done and if it there has been difficulties with some issues.
[387 byte] By [
Kayaman] at [2007-9-26 3:05:25]

I am doing 2D and 3D graphics with java, as a hobby... Some months ago I had a go with a simple triangle engine with gouraud shading but it didn't really work out.
Peter Walser's 100% Java idx3d (source available!) is really educating, and so is tinyptc from gaffer (for faster blits). Also the java section of cfxweb may blow your mind...
Has anyone tried the gl4java package (OpenGL for Java)?
It's a hobby for me too (more fun that servlets at work). What was the problem with your engine? It couldn't have possibly been too slow, since I've seen amazing environment/texture mapping, gouraud/phong/whatever shading.
You can write to me directly: Jussi.Marttila@iobox.com
Any of you, who wish to discuss 3d in java (the hard coded version)
Count me in! http://blake.prohosting.com/ragnvald/";-)Ragnvald BarthSoftware engineerrbb@rubicon.no
No, it was not slow... I just got too busy with the matriculation examination / baccalaureat / what ever - thingy ("ylioppilaskoe" in Finnish) :)
and then I got a full-time job as a programmer...
Here's what I got done: http://joni.raketti.net/graphics/gouraud.html
It's a z-buffered, gouraud shaded body with 2500 triangles calculated from a parametric equation with no hidden surface removal. (I also have two klein-bottles and other nice mathematical surfaces there -- code that produces them is just commented out.)
The graphics *is* jerky and I think I now know why - thanks to a couple of articles at cfxweb. I was planning to start a new project under the name kinos (a *real* project, not just a hardly designed set of utility classes) that supports pluggable renderers, pluggable object types, pluggable, well, just about anything pluggable :). An engine that can do everything from simple wire-frame models to ray tracing and even radiosity... and do it all in 100% pure Java!
But I'm afraid that it will have to wait until next year when I'm supposed to begin my studies at the Oulu university (maths, if you're interested). Too bad, I already had a name figured out for that project...
> http://blake.prohosting.com/ragnvald/Hey! That's pretty cool! How did you do that? Do you use the painter's algorithm and the standard graphics class or .. ?Btw: we are probably getting enough people here to found a demo group. Anyone interested?
A java demo group, that would be a first I believe :)
Too bad they don't have a 100% java compo at the Assembly. Jsalonen, your gouraud shaded thingie was cool, I was impressed with several facts (not using hidden plane removal, z-buffering etc.) So you're going to study maths? I have the option (got an L in ylioppilaskoe) but I still think I'll go to hut.fi of course I'm going to army in january so I have time to think about it. But ****...I have to work with some stupid servlets when I'd rather be doing 3d at home ;) well back to sweeping out nullpointers (it's not my code originally)
> A java demo group, that would be a first I believe :)
No, I'm afraid not... Have you seen komplex, digital nerds, fuzzion, sumea, equinox, infuse, etc.?
http://www.komplex.org/
http://dn.planet-d.net/
http://www.fuzzion.org/
http://savage.planet-d.net/
http://www.sumea.com/
http://equinox.planet-d.net/java/index.html
http://www.infuse.org/
> But ****...I have to work with some stupid servlets
> when I'd rather be doing 3d at home ;)
Same thing here... but I have to work with PHP. Talking about ease of debugging... MRRRRR!!!! If you miss one semicolon or $-sign the page just wont parse and you'll never know why.
> of course I'm going to army in january so I have time
> to think about it.
You too?!! Where? I'm going to Vekarajärvi. That's why I can begin my studies only next year :(
Yes actually I know of those groups (especially equinox, I often chat with keops from equinox). But they basically don't create their demos for competitions, or what do I know, anyways.
I'm going to isosaari, you know the island off Santahamina. Well, no coding for 6 months it seems...
A java demo group wouldn't be such a horrible idea, I'm sure there are plenty of good coders and such. Maybe asm '02 will see a java entry too. Did you go to asm '01 btw?
I had a friend enter a flash compo, came in third...he was so happy...:)
Well, back to servlets.
hi jsalonen
Cool thing. I noticed you set the statusbar text every nanosecond. just comment out that line, and see if it gets any smoother.
My little flight simulator is something I did a few years ago (my way of studying math). Ist just an applet with some calls to g.setColor() and g.fillPolygon() in the paint method. Did it all from scratch using pure awt and mathemathics.
My tequnique is to use matrix transformations between the different coordinate systems, (model, world, view and screen coordinates) sort all the polyhedrons (insertion sort is the fastest sort algorithm) and paint all polygons that is "facing towards the camra". I also did some vector angel calculations to set the light on every polygon acording to the angel between the surface of the polygon and the direction of the light.
Tryed to make a new version, but I have a problem with the transformation from view cordinates to screen coordinates. (I am just deviding on the z value) but that only works if the z value of all the verices of the polyhedron are positive (i.e. the entire polyhedron is in front of you) if half of the polyheron is behind you I have a problem...
Regards
"3d
Ragnvald
Yep, that's a clipping problem (being in the middle of an object). It's impressive though and fun too. I've been playing it at work ;)
I know a lot of theory of 3d but I don't have much experience in actual code (done persp. projection, basic rotation etc.) mostly because after I come home from work, I'm not too keen on sitting in front of my comp. working on my 3dengine. Anyway, what jsalonen said about the demo group, If you have any ideas on anything would you please inform me. I'm an ex-assembly coder and there's nothing in the whole wide world that I enjoy more than optimizing code ;)
I think I put my email address earlier, but here goes again.
Jussi.Marttila@iobox.com
If you have questions, suggestions or just want to release your anger on someone, contact me.
Anyone knows the solution to my 3d problem?
How to translate a point from vcs (view coordinate system) to scs (screen coordinate system)?
I have a point in the vcs given by x,y,z values.
I want a point at the screen.
I tried:
screenX = 400 * vcs.x/vcs.z;
screenY = 400 * vcs.y/vcs.z;
And it works just fine as long as vcs.z is >0
But for a polygon at your side, partly visible, some vertex of the polygon might have a negative (or zero) vcs.z value.
And then I am not able to paint that polygon.
I also tried using the distance from the camera to the point as the divisor:
ScreenX = 400 * vcs.x / Math.sqrt(vcs.x * vcs.x + vcs.y* vcs.y +vcs.z * vcs.z);
But that gives a very fisheye like view of the world...
Anybody has an idea for a solution?
That problem is usually ignored in demo engines since it's not very likely to collide to things -- if (z < nearZ) dont_render_this_triangle... Anyway, the real graphics libraries usually handle this case by cutting the triangle in half and re-triangulating the possibly resulting quadrilateral.
This is done already in world coordinate system since it's less expensive to transform the clipping planes (all six of them) to wcs than letting many invisible triangles pass through the world -> view transformation.
See http://www.xs4all.nl/~smit/clip.htm, flipCode, faqsys, gamasutra, google, and other general graphics sites for more info...
You could check the z - are you translating everything before rendering so that the positive z is in front of the user? (the z axis is their line of sight)
If so, set a near number and ignore the triangle completely if all 3 vertices are under it. You could also set the origin to actually be behind the user somewhere, so that all the dividing works well, and still just ignore the triangles when they get behind a certain range.
You got me right spaceman!
The z axis is the line of sight, and at the z axis cuts right through your pupil at z=0. Positive z is in front of you, negative z is behind you. I have read a litle bit about cliping, and z-buffering and stuff, but I am still searching for a simple solution. What I do (by the moment) is to ignore the polygon compleatly when the z value of any vertex is <= 0.
http://blake.prohosting.com/ragnvald/
And basically it works just fine. For an "open landscape world" thats good enough. The problem is that for a "cave" its not good enough. In a cave you will quite often have a wall at your side where some polygons that should definitly be visible have vertex(es) with negative z values.
";-)
Ragnvald Barth
Software engineer