help needed, show you screenshots
please comment me with my work. any harsh or praising or helping words would be much appreciated. thank you
http://xucsg.buildtolearn.net/screenshots/Journal1.html
try here
Reading your small blurb at the bottom, I really feel you should try and learn either OpenGL or DirectX. Being able to do what you did without them is impressive, but you'll be solving all the problems that many others have already solved.
One example is your polygon sort problem. Actually hardware has a Z-buffer for that, and it's built in, and fast. You seem to have enough programming and math background, that learning one of these API's should be relativley simple to do. In a month or two, you should be able to re-create that system, and made it 1000% better.
Still I'm impressed you did that without an API of any sort.
One example is your polygon sort problem. Actually hardware has a Z-buffer for that, and it's built in, and fast. You seem to have enough programming and math background, that learning one of these API's should be relativley simple to do. In a month or two, you should be able to re-create that system, and made it 1000% better.
Still I'm impressed you did that without an API of any sort.
thanks for that. right now, i'm developing the game system. another problem is that i've only got a month left, and i have three other programming projects. =< if i have time, i would really study openGL. right now, i think i'll get on with it.
thanks for the reply.
thanks for the reply.
Actually, I'd kind of disagree with the idea of learning a 3D API. You'll learn much more without using one.
Incidentally, use the mergesort algorithm to sort your polygons - it's a little slower in the quicksort's best case (in order) but doesn't have quicksort's worst case (takes longer than bubble sort due to being more complicated).
You might like to take a quick look at Java3D. It's Java, it's a scenegraph (camera here, light here, planet here, moon here, moon rotates around planet, run, ooh pretty.). It's hardware accelerated (via OpenGL [the creators really make their preference to OpenGL clear] or DirectX. Whether you use OpenGL or DirectX is completely up to the Java3D runtime you install, and is transparent to your application.). It's cross platform. You can import 3D models (export is near impossible). It's pretty cool and reasonably easy to use. I'm not entirely sure it really has a future though.
What you've got is impressive. What you need to do is finish.
If it's a school rather than a university, I'm impressed that they don't think Computing stops with MS Access.
Incidentally, use the mergesort algorithm to sort your polygons - it's a little slower in the quicksort's best case (in order) but doesn't have quicksort's worst case (takes longer than bubble sort due to being more complicated).
You might like to take a quick look at Java3D. It's Java, it's a scenegraph (camera here, light here, planet here, moon here, moon rotates around planet, run, ooh pretty.). It's hardware accelerated (via OpenGL [the creators really make their preference to OpenGL clear] or DirectX. Whether you use OpenGL or DirectX is completely up to the Java3D runtime you install, and is transparent to your application.). It's cross platform. You can import 3D models (export is near impossible). It's pretty cool and reasonably easy to use. I'm not entirely sure it really has a future though.
What you've got is impressive. What you need to do is finish.
If it's a school rather than a university, I'm impressed that they don't think Computing stops with MS Access.
Writing your own 3D rasterizer is cool and everything, but it's not very practical for a finished product. If you're interested in learning all of the math then go ahead and continue it, but I would suggest finding a Java OpenGL wrapper you like and learning that as well.
so what is openGL really like? with VC++, i don't quite get it. I'm confused with what kind of objects are passed in it (parameters), is it just a collection of functions or objects... the reason why i made my own is that i can be flexible with it because i understand how it works.
may be with a little study, i can get on with it. plus there's not much resources concerning java using openGL. it's still in its underground state. more people are still using c++.
if you don't mind, i would like to talk about my stuff. maybe by then, you could give some suggestions.
i have these basic objects that make up my system.
Vector3D //an x,y,z values holder
Vertex //holder of three vectors (local, world, aligned)
Matrix //basic scaling, translating, rotating
Edge //holds two ints, each int is an index to the array
//of vertices. As you can see with the wireframe.
Triangle //holds three ints, each is an index to the array of
//edges
Object3D //holds the array of vertices, edges, triangles
//also holds vectors for scaling, position(translate)
//and rotation
Camera //holds three vectors for zooming, camera position
//and camera rotation
This is basically it. The rendering is as follows. I only need one matrix for the whole procedure. It's basically straightforward.
-get identity matrix
-scale matrix with the object's scaling vector
-translate matrix with the object's position vector
-rotate matrix with the object's rotation vector
-get the world coordinates of each vertex by transforming the local vectors using the current matrix
So I now have world coordinates. Next is the aligned. Same procedure, only that I will use the camera vectors this time.
-get identity matrix
-scale matrix with the camera's zooming vector
-translate matrix with the camera's position vector
-rotate matrix with the camera's rotation vector
-get the aligned coordinates of each vertex by transforming the world vectors using the current matrix
Then I will have to get the array of 2D projection points of each aligned vertex using the basic equations, x = v.x / v.z and y = v.y / v.z. Basically, the ints that each edge hold would also refer to the same index in the array of 2D points. Same is true with each triangle ( triangle -> edge -> vertex ). All i have to do then is to get three distinct points from the triangle. Once i got the three points, i'll get z - deth. This is then where i'll have to sort the triangles using quick sort. Apply shading to its color. Then I'll draw it with a simple function in Java, g.drawPolygon( { p1.x, p2.x, p3.x }, { p1.y, p2.y, p3.y } );.
That's all there is to it. Of course there's some lacking stuff like texture mapping, clipping, many others... But if you can in any way get what it does and optimize it, please share it with me.
may be with a little study, i can get on with it. plus there's not much resources concerning java using openGL. it's still in its underground state. more people are still using c++.
if you don't mind, i would like to talk about my stuff. maybe by then, you could give some suggestions.
i have these basic objects that make up my system.
Vector3D //an x,y,z values holder
Vertex //holder of three vectors (local, world, aligned)
Matrix //basic scaling, translating, rotating
Edge //holds two ints, each int is an index to the array
//of vertices. As you can see with the wireframe.
Triangle //holds three ints, each is an index to the array of
//edges
Object3D //holds the array of vertices, edges, triangles
//also holds vectors for scaling, position(translate)
//and rotation
Camera //holds three vectors for zooming, camera position
//and camera rotation
This is basically it. The rendering is as follows. I only need one matrix for the whole procedure. It's basically straightforward.
-get identity matrix
-scale matrix with the object's scaling vector
-translate matrix with the object's position vector
-rotate matrix with the object's rotation vector
-get the world coordinates of each vertex by transforming the local vectors using the current matrix
So I now have world coordinates. Next is the aligned. Same procedure, only that I will use the camera vectors this time.
-get identity matrix
-scale matrix with the camera's zooming vector
-translate matrix with the camera's position vector
-rotate matrix with the camera's rotation vector
-get the aligned coordinates of each vertex by transforming the world vectors using the current matrix
Then I will have to get the array of 2D projection points of each aligned vertex using the basic equations, x = v.x / v.z and y = v.y / v.z. Basically, the ints that each edge hold would also refer to the same index in the array of 2D points. Same is true with each triangle ( triangle -> edge -> vertex ). All i have to do then is to get three distinct points from the triangle. Once i got the three points, i'll get z - deth. This is then where i'll have to sort the triangles using quick sort. Apply shading to its color. Then I'll draw it with a simple function in Java, g.drawPolygon( { p1.x, p2.x, p3.x }, { p1.y, p2.y, p3.y } );.
That's all there is to it. Of course there's some lacking stuff like texture mapping, clipping, many others... But if you can in any way get what it does and optimize it, please share it with me.
OpenGL really does no more than replace the rasteriser. It will do matrix transforms, but, if you need the results within your application, then you have to implement some functionality in this department.
I assume you are using g.drawFilledPolygon(x, y, 3); to draw each triangle?
If so you probably now have something like:
With OpenGL you could something like the following (from memory):
It's not the fastest way (eg., loading the object into a vertex array and using that may be faster).
I assume you are using g.drawFilledPolygon(x, y, 3); to draw each triangle?
If so you probably now have something like:
public class MainApp {//stuffvoid paint(Graphics g) { Object3D object; // sort objects Iterator iter = orderedobjects.elements(); while(iter.hasNext()) { object = iter.getNext(); object.paint(g); };}
public class Object3D {//stuffvoid paint(Graphics g) { int x[] = new int[3]; int y[] = new int[3]; Face face; // transform vertices // sort faces Iterator iter = orderedfaces.elements(); while(iter.hasNext()) { face = iter.getNext(); x[0] = vertices[face.xvertex[0]]; x[1] = vertices[face.xvertex[1]]; x[2] = vertices[face.xvertex[2]]; y[0] = vertices[face.yvertex[0]]; y[1] = vertices[face.yvertex[1]]; y[2] = vertices[face.yvertex[2]]; g.drawfilledPolygon(x,y,3); };}
With OpenGL you could something like the following (from memory):
public class MainApp {//stuffvoid paint(Graphics g) { Object3D object; // NO NEED TO SORT OBJECTS glBegin(); // set view transform Iterator iter = unorderedobjects.elements(); while(iter.hasNext()) { object = iter.getNext(); object.paint(g); }; glEnd();}
public class Object3D {//stuffvoid paint(Graphics g) { int x[] = new int[3]; int y[] = new int[3]; Face face; // NO NEED TO SORT FACES // set model transform Iterator iter = orderedfaces.elements(); glBegin(GL_TRIANGLES); while(iter.hasNext()) { face = iter.getNext(); glVertex3f(vertices[face.xvertex[0]], vertices[face.yvertex[0]], vertices[face.zvertex[0]]; glVertex3f(vertices[face.xvertex[1]], vertices[face.yvertex[1]], vertices[face.zvertex[1]]; glVertex3f(vertices[face.xvertex[2]], vertices[face.yvertex[2]], vertices[face.zvertex[2]]; }; glEnd();}
It's not the fastest way (eg., loading the object into a vertex array and using that may be faster).
you don't need to sort things using openGL? sounds good. so when i pass things to it, does it already know the objects' z-depth?
It uses what's called a "z-buffer," which is a buffer that encodes the depth of every fragment. Before a new fragment is combined with the color buffer, it is (optionally) first checked to make sure it passes the depth test. Generally, the depth test is set up so that fragments that are behind (have a depth further than) the current fragment are discarded.
At it's core you give OpenGL a modelview matrix (transforms model to world space), a projection matrix (transforms world to screen space) and then a series of lists of stuff to draw (triangles (individually, strips or fans), quads, lines, points or a polygon.
The lists include all the data about position, colour, texturing etc., OpenGL can also do lighting for you (you have to help it with shadowing though).
The lists include all the data about position, colour, texturing etc., OpenGL can also do lighting for you (you have to help it with shadowing though).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement