Computer Science Canada 3D Engine code release |
Author: | MihaiG [ Mon Nov 24, 2008 6:37 pm ] | ||
Post subject: | 3D Engine code release | ||
So i decided to release the code to my 3d engine, personally i was fairly pleased at what i did in the allotted time in which i coded the program, but the way i actually developed the program set up roadblocks in doing zsorting and shading so here is the code
some tips the file formating is listed above to create a model i just used blender, and imported a model and then used the export function and exported as raw faces using the default values so just a brief overview of the initial parameters of the program zoom : basically zooms in its best to have values over 300 zshift moves the object back (sortoff like zoom) xshift : moves to the right/left yshift : moves pictures updown point size defines the size of the vertex of each face perspective is basically the strength of the camera, so basically having a perspective of 0 will make it have no perspective point, the higher the value, the closer it is to the camera enjoy -mihai |
Author: | A.J [ Mon Nov 24, 2008 6:50 pm ] |
Post subject: | Re: 3D Engine code release |
so.......do u have an input file that I can use? |
Author: | MihaiG [ Mon Nov 24, 2008 9:11 pm ] |
Post subject: | Re: 3D Engine code release |
***************NOTE***************** this is a wireframe only engine i couldnt get surfaces to work properly i will be making a completley new engine after winter break **************************** sorry i forgot to mention, the input files are on my original submission of the program its just an zip that has the exe inside http://compsci.ca/v3/viewtopic.php?t=19304 its the second last post in the topic has a bunch of models you can read that topic as how the data is stored in the files also ` is quit w&x are rotation on the x axis e&z are rotation on the y a&d are rotation on the z axis |
Author: | Zren [ Mon Nov 24, 2008 9:26 pm ] |
Post subject: | Re: 3D Engine code release |
There's a more efficient way to do 3D polygons in data files. You see here for 1 box you'd have to re write EVERY Point on each polygon. You'd have a 109-line long file. (Example file attached.) A much number crunching file would be to do as so. Make two input types: Vertice (Points) and Polygons. Load the total number of points and polygons (2 lines). load the vertices. (x,y,z) (3 lines) Load the polygons (the data here would be the number for the vertice.) (3 lines) Now, for a basic cube that consists of 8 vertices, and is broken down into 12 polygons: (2 lines) total numbers (8*3) points (12*3) polygons =62 lines total A better explanation with pictures is here. |
Author: | MihaiG [ Mon Nov 24, 2008 11:17 pm ] |
Post subject: | Re: 3D Engine code release |
thanks but i probably wont be doing any work on this engine anymore since im having some issues based on the way i developed it the code is there, so if you want to implement it, be my guest ![]() |
Author: | A.J [ Mon Nov 24, 2008 11:35 pm ] |
Post subject: | Re: 3D Engine code release |
good job MihaiG! I am doing a similar thing but in C++ (for my FP. I am making a 3D Game) good job! |
Author: | MihaiG [ Tue Dec 09, 2008 4:53 pm ] | ||
Post subject: | Re: 3D Engine code release major update | ||
hey guys, im adding a new major update to the code i now have zsorting so you will draw poly from furthest to closet, i did using saad's quicksort i also added a kind of pseudo-shading
|
Author: | Homer_simpson [ Wed Dec 10, 2008 4:08 pm ] |
Post subject: | Re: 3D Engine code release |
i like it...+ bits |
Author: | MihaiG [ Wed Dec 10, 2008 7:32 pm ] |
Post subject: | Re: 3D Engine code release |
thanks homer it achieves around 20+fps on 500 polygon models, my assumption is that if you use low detail polygons. i know that i didn't document much, but if you need any clarification with what code does feel free to send me an email at mihail[dot]gheorghe[at]gmail[dot]com i should respond within a day. also, id like to thank saad again for letting me steal his quicksort code ;P if anyone is interested in how i did the shading here it is.. when i found the distance to each face, i store a max and a min then when calculating the color i took the actual distance and subtracted the min which gave me the delta, i then divided that by the difference between the max and the min, which essential means that, the farther away the darker it is the closer the lighter, this is a bit buggy cause if you have disproportionate models, you will have an "uneven" lighting system, if someone figures out a more consistant way to do realistic lighting, remember light intensity is proportional to the inverse of the sqaure of the distance ![]() anyways, i know there are many places efficiency can be imroved probably using taylor series for some of the functions (ill try to implement that now) |
Author: | A.J [ Wed Dec 10, 2008 11:28 pm ] |
Post subject: | Re: 3D Engine code release |
where can i find helmet.ply? |
Author: | MihaiG [ Thu Dec 11, 2008 10:49 am ] |
Post subject: | Re: 3D Engine code release |
hey i attached the helmet.ply below its not a wel designed model cause there are erroneous polygons inside the helmet :/ the helmet probably gives the best result with the 3d engine note you need to change the file extension back to ply, compsci.ca doesnt allow *.ply uploads ![]() |
Author: | Homer_simpson [ Thu Dec 11, 2008 12:31 pm ] |
Post subject: | Re: 3D Engine code release |
for proper lighting effect you need to find the normal to each face and find the angle between your face normal to your light source and calculate the color based on that. you can look at the code off my old engine, i had normal calculations in there. http://compsci.ca/v3/viewtopic.php?t=6503 |
Author: | MihaiG [ Thu Dec 11, 2008 1:20 pm ] |
Post subject: | Re: 3D Engine code release |
homer, i understand as to how to calculate the normal to a plane in 3d space, but how do i know which side it would be facing? because there would be "two' normals that spring of any plane? or would the correct vector be calculated assuming each polygon's verticies are stored in the same order? ie CW or CCW? **edit** ya ifigured it out, i also read up on backface culling if anyone is interested http://www.cubic.org/docs/backcull.htm ie. if the normal of a polygon is facing away (ie if the Z value is less than 0) we can skip drawing it |