Wednesday, December 31, 2008
I added a Sidebar on ZirconCode.com with the Blogger, Twitter, and RSS logo so you people can find me there. The sidebar is not complete yet and will later also include a search and navigation function along with some more social bookmarking logos. Otherwise nothing new, I didn`t have time to work on the MMORPG.
Have a nice New Year and don`t forget to make some great New Years resolutions =)
Tuesday, December 30, 2008
The walking was handled by four methods in the Character class: walkUp, walkDown, walkLeft, walkRight. When a method was called (probably by a key press), it checked if the player would collide with the tile the player was about to walk on and then accordingly moved the player. The collision system looks something like this:
Each tile had four edges, each of which could be walk-through or not. To move the player the walk-methods had to check if the corresponding wall on the current tile was walk-trough and if the corresponding wall on the next tile was walk-through. If this was not the case, the player was not moved. In the above case the player (black dot) wants to move left. The tile the player is on allows that but the tile the player is going to move too doesn't so the player isn't allowed move.
I had to make an additional collision map for my current test map. The collision map stores the collision values of all four walls of each tile in the map. It was a simple arrays of 0's and 1's, where a 1 stands for collision and 0 stands for walk-through.
Each time the player moved his height he had too be properly adjusted so that if he moved to a higher tile, he doesn't sink into the floor and if he moved to a lower tile, he doesn't float above it. This was also handled by the four walk methods. The methods simply found the average of the tiles Vertices and used that as the players height. This has some disadvantages on very very steep tiles but I'm not planing to let the player walk on top of tiles with more than a 45 degrees slope.
It's kind of great to be able to walk around the small test world and I'm happy because the MMORPG is now a big step closer to being finished.
Monday, December 29, 2008
What I basically did was to substitute arrays and loops for things I was doing in a totally different way. I'm pretty surprised that I hadn't thought about this stuff before but I probably didn't think it was necessary. I now have an array of tiles in my Map class. Each tile holds all the variables about itself and almost nothing gets stored in the Map class itself except very general things. A Tiles variables include: Walkability (collision of all four sides), Colour(s), Object (ex. thing on top), Heights (all four corners), Actions (some script of a scripting language I haven't created yet triggered by character moving near/on tile).
I thought of a way to determine an objects/characters height when on a Tile. I would simply take the four sides of a Tile and find the average (height1+height2+height3+height4/4). The Characters height would have to be altered accordingly when moving. I hope to interpolate between nearby tiles when the character is not standing on any to find the next best height.
Nothing else really happened on day 8 which is kind of disappointing but I hope twice as much is going to happen on day 9 as I kind of pre-worked.
Sunday, December 28, 2008
It was very easy to add colour to the height field I had already created. I simply created a text file similar to the height field file and put colours inside instead of heights. The colours where given as rgb (red green blue) as that was the only option I would even consider. There was one simple problem I had to face:
The height field had a number for each Vertex (those red dots) so the colour file had stored a colour for each vertex too. I could probably have Interpolated Colours between the vertices to create the gradient colours inside the squares but that would have slowed down the Applet a lot so I simply assigned the colour of a squares bottom-right vertex to the entire square. This way the first row of vertices from the left and top simply got ignored but if I ever change my mind to interpolating colours I won't have to change any files.
I plan to approach the adding of objects on top of the tiles the same way. I'll simply create another file for the same map and store objects numbers instead of Colours or heights. I hope it works. I'll see if it works tomorrow (hopefully).
Saturday, December 27, 2008
The MMORPG became interactive on day 6 of it's development. I made it possible to move around the map and change the camera angle.
To move around the map I either had to move the Map itself or the Character and the Camera. I decided to move only the Map since it was harder to move the Camera and the Character. Every time the character "moves" a tile, the map gets translated by the TileSize to make it look like the character moved.
The camera angle can be moved freely which isn't so great yet. I'm going to have to find some proper camera restrictions so that the player can't rotate the map 180 degrees and look below it.
The MMORPG of day 6 can be found Here. You can move around by using the arrow keys. You can change the camera angle by holding down the control key and pressing an arrow key. Unfortunately you have to press the arrow key each time you want to change the camera angle by 0.5. I'm probably going to change that.
To finish the Map I need to be able to load Objects and add them on top of the height map. Then I need to be able to display everything in color, not in grey tones. Then I need to put the character class into the map at the proper height. Then I'm finished with a lot of the MMORPG and I will be happy.
Monday, December 22, 2008
First I had to create a height map to test the loader. I wasn't sure if I should use a picture or a text file. I decided on a text file since it's easier to store additional information about the map this way. I decided on a really simple format:
// A random 5*5 Sized Map
To load that height map I first created a grid of 5*5 Vertices and connected them together with triangles so that they would form a Square pattern like so:
After that I simply assigned a number to each vertex so that they would be the height they should be in. A resulting height map of the Loader looked something like this in my 3D Engine:
Now I just would have to find the perfect size of the squares and the Height Map loader would be finished. I though of 32 times 32 pixels because most 2D video games use this tile size. I found 32 pixels too small to fit a 3D human into so I set it to 50 pixels. 50 Pixels is quite good and I'll probably stay at that size but I'm not sure yet.
Now to finish the Map loader I need to find a way to load objects (ex. trees, houses, chairs) into the map and place them at the appropriate position. Then I need to find a way to add colour to the whole thing, grey is kind of boring. After that I should find a way to make the Camera focus on a certain tile (probably the one with the player on it). I'm not quite sure how much more time I have before Christmas so I'm saying that the next MMORPG Day might be more than 3 days from now.
Sunday, December 21, 2008
One of the many problems is Animating the Characters model. I think I might group together many polygons and bond them with a "bone" point and when I do anything to that point it impacts all the polygons tied to it. That way by moving one vertex I can be able to move an entire part of a character (ex. Left Leg, Right Arm). I will also have to find some way to record the movement of the "bone" points in a simple text file. As stated before I'm kind of stuck there.
I also hadn't considered the Item class properly. I forgot to add any way the Item could interact with another thing. When I realised I added 3 new methods to the Item class; useonCharacter, useonItem, and useonTile. This way the Item can interact with players, other items, and the surrounding area. I have to create some kind of scripting language to create the results of an interaction. This Scripting language could also be useful with map related events. The scripting language would have to be simple, something like this:
> Player is less hungry
> Fish Disappears
> Tree dissapears
> Player gains (item)Wood
> 50% chance axe may brake
I also forgot about any kind of Levels the character may have. I think a simple array of numbers will do but I'm still thinking about it.
The thing I mainly worked on on Day 4 is This Applet. It took quite some tweaking to get the Applet to load files from the server it was stored on. I may write an Article about it later on. When you view the applet you should see a green cube rotating representing the character. It's loaded from a file and treated as a character would be. I will improve the characters visual appearance later on so don't panic =). On the top of the applet it says "3D Engine (ZBuffer: False)" which means that ZBuffering is disabled in the 3D Engine (as you may have guessed). On the bottom of the Applet is a series of letters harder to decipher. They basically represent the players character.
I'm kind of stuck on all fronts with the Character so if I don't solve the problems I'll continue on to the Map class and return later.
Saturday, December 20, 2008
# comments.. bla bla bla
-1 2 3
6 -3 6
9 3 -5
1 5 8
-4 2 6
1 2 3
3 4 1
1 3 2
1 3 4
1 2 4
1 2 3
1 2 3
First of all I loaded the file using the Java method I had created for loading text files. Then I excluded all lines starting with "#" except "# points" and "# polygons". I used those two comments as references as to what I was loading right now. I simply loaded all the points into a List using each of the three numbers as a coordinate (x,y,z). When I got to loading the polygons, triangles in this case, I picked the points out of the list with the corresponding index (ex. List Item number 1, 2, and 3) and created a Triangle with them which I then added to my Model.
I created a Model.merge method so I could load another model and merge it into the first model. This allowed for loading each part of a model separately, as was needed for my Character class.
Next I created a folder layout to save all my Character parts in. It would bring some more order into all the files I would need to create so that players could customise their character as they wanted. The folder layout looked something like this:
+CParts (character parts)
Each folder would have files in it with names ranging from the number 1 to something hopefully below 100. So to generate my players model I could simply load the corresponding file to the corresponding number in his Look Array from the correct folder. The number 0 in a players Look Array means that he isn't wearing that right now (ex. hat=0; not wearing a hat).
Once I finished that I started thinking about the Item class I would hopefully create on the next day. I didn't come up with anything but since my current speed is pretty good I hope I'll think of something tomorrow. If I don't, I'll start working on the Map class.
Friday, December 19, 2008
The character class started out easy, I just created variables which would store the characters data. These variables where:
- Name (of character)
- Position (Map Name)
- Position (X & Y)
- Action (ex. Walking, Sleeping...)
- Frame Number (frame of action)
- Logged On (yes/no)
- Chat (what the player is saying right now)
- Look (how he looks, what the player is wearing)
- Inventory (items the player is carrying)
I ran into some problems with the Look and Inventory. For the Inventory I decided an array of the class Item would do just fine. I will work on the Item class later on but for now it doesn't even exist. For the look I decided an array of numbers would do. Each number would represent one aspect of the characters look. For example:
1. Hair Style (1=Bald, 2=Punk, 3=Mohawk, 4=Normal)
2. Hair Colour (1=Blue, 2=Red, 3=Green)
3. Skin Colour (1=Blue, 2=Normal, 3=White)
4. Hat/Helmet (1= none, 2=gold helmet)
5. etc. etc. etc.
After creating the variables I went to work on the methods. The first and simplest method I created was toString. This method simply took all the variable and turned them into one string. The second method was fromString. This method took all the variables from a String. These two methods will hopefully help me later with the networking of the game.
The method I'm currently working on is the createModel method. It's supposed to take all the numbers from the number array Look and turn them into a 3D model for the 3D engine to display. I'm thinking about having a 3D file for each number of an aspect (ex. hair, skin, hat) and then just simply loading them and piecing them together. I'm not sure yet if that will work but I hope so.
Once I have that method finished I just need to create the item class and my character class will be finished.
Thursday, December 18, 2008
I'll write a daily Blog post so you guys know what's going on. I have decided that I will only dedicate full days to my MMORPG, nothing less. This way it will be easier for me to focus. If I take a break of working on my MMORPG (for whatever reasons) I will simply skip that day and continue on the next (If possible).
So on Day 1 of my MMORPG I made an outline of all the things I would need to program in Java. That way I will hopefully be able to tell exactly how much progress I have made and how much I still need to do. Here's the simplified outline:
- 3D Engine
- HUD / Menu
The 3D Engine is going to be the first thing I will work on. It will "simply" take 3D Models and display them on the screen. I have decided to use the 3D Engine I developed earlier on due to portability reasons. If I would take a 3D engine depending on graphic cards there certainly would be problems. I choose Java because of portability and I'll choose the 3D Software Rendering Engine out of portability too. Maybe later I'll add the option for people with good graphic cards to use them. I decided to work on this first so you people out there can see results quickly.
The Map will load a 2D tile based map and convert it into a 3D model which will be displayed by the 3D Engine. It will also store all the data of the players surroundings.
The Character will load a Characters DNA and make a 3D model out of it which will also be displayed by the 3D Engine. A Characters "DNA" includes all the characters Information in one short line of text. The Character stores everything about the player and what he's doing right now.
The Networking will probably be the hardest since I have no experience in that area at all. I'll just have to try this and that and hope it works. Wish me Luck!
The Sound and HUD are very low priority and will be the last thing I'm going to work on. The HUD may come a long as I work on my MMORPG and it may not, it depends on how much I need it.
I had some time left after making a good outline so I imported my old 3D engine and familiarised myself with it as it has been a long time since I last looked at it. It's working nicely and I'll just have to tweak some small things here and there to make it fit into a MMORPG. The biggest concern will probably be the speed but I'll find a way (hopefully).
Wednesday, December 17, 2008
I have given up on the Hardest Logic Puzzle on Earth for now. My friend has told me that the answer can be found at Wikipedia so if you are curious take a look. I myself won't look until I think I found the correct answer, I'll keep trying every few weeks to see how much my brain has grown.
As I stated above Christmas break has just begin for me and I know have exactly 20 days of free time on my hands. Maybe take away one or two days for Christmas and after. I'm currently trying to think of a big project to start and finish during these days but I haven't thought of anything fun and exciting yet.
I have optimised the website layout further and my "Games and Applications" section is starting to take shape. It's still pretty bland but I have already uploaded my very first Java game. As you may have guessed, it's a Pong game. It's not the best game but it's certainly fun to play for 5 minutes or so (I hope). The sound magically vanished when I uploaded and I'm trying to fix it.
Have a Nice Christmas Break!
Sunday, November 23, 2008
On a happier note I was being bored again and surfing through the net I found this: http://philosophy.hku.hk/think/logic/hardest.php. It's a very interesting website and I advise you to read through it if you haven't finished a course on Psychology and Critical Thinking yet. The website states that George Boolos states that this is the most difficult logical puzzle on earth:
Three gods A , B , and C are called, in some order, True, False, and Random. True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter. Your task is to determine the identities of A , B , and C by asking three yes-no questions; each question must be put to exactly one god. The gods understand English, but will answer in their own language, in which the words for yes and no are “da” and “ja”, in some order. You do not know which word means which.I thought I might give it a try.
First of I Organised My Data:
- 3 Gods: A,B,C
- True Names of 3 Gods: True, False, Random
- I can ask 3 true and false questions.
- The response is either da/ja which means either yes/no.
After that I used one of my favorite computer algorithms; Brute Force =)
I calculated all of the possible answers to the puzzle:
So once I knew the 6 different answers I couldn't do anything more on that part of the puzzle but wonder if it was even something useful I had done.
I moved on to another part of the puzzle: The Questions.
I would have to ask 3 true and false questions to find out which of the 6 answers was the correct one. Not only would I have to consider the questions I would ask but also to which God I would ask them to.
Lets look closer at "True and False Questions". The question would have to be answered by yes or no (da/ja). The types of "True and False Questions" I could think of are listed below:
- Asks weather dogs are animals (true)
- Asks weather dogs are stones (false)
- Asks: Are you True/False/Random
- Asks opposite of 1-3
- Asks: Are you "Insert a Double Combination of Questions 1-3"
- Asks opposite of 5
Lets apply the Brute Force Method Again:
- The different Questions I could ask is: 2+3+3+3+3=14
- The amount of Questions I could ask is: 3 (given)
- The number of Responses I could get is: 2 (da/ja)
I'm pretty much stuck there. I will analyse the routes more carefully in the Next Post and I hope I'll get a result.
Monday, November 17, 2008
Since I'm not going to get anything done due to boredom I've decided to make a list which I have to follow. Excuses about boredom are not accepted.
- Make website Internet Explorer Capable
- Finish of Website Layout
- Create Help Files for my Website
- Add my E-Mail address and the likes under "Contact"
- Add one Game under "Games"
- Finish of Current Content
- Think of more ways to use up time:
- Maybe get Traffic?
- Put on more games?
- Create an Article Section?
Monday, November 3, 2008
This Blog will be integrated into that site but will still be available under: http://devediary.blogspot.com/
I'm currently just trying to get this site to work. For best results view it in Firefox (3 or above?). I'll get this site to look good for funnier browsers like IE too but that has to wait until I got everything set up.
The Site currently has the following categories:
Home = A Welcome Message + News Blog (this one)
Applications & Games = Anything Java for Computer Illiterate (it's also longer)
Help! = ...
Contact = a non-private e-mail and maybe comments?
I may be adding a forum later once I get more than about 350 hits a year =).
Also I'm not quite sure if I should add an "Articles" section (with polished blogposts, ex. Triangle Interpolation) but it would probably boost my hit counter.
On a more Boring note (location,location,location...):
Let me explain in a monotonous voice how I stumbled on the name ZirconCode because I know that you are just burning to know =/.
Well first I thought something with "Source" or "Code" or similar would be nice. Then I thought that maybe I could add some colour prefix like "red" or "blue" but for various reasons it didn't sound so good... (really, trust me)
Then I thought instead of colours I could add a precious metal like "diamond" or "ruby" or "gold" or "titanium" or...
Well I somehow ended up at ZirconCode and as it was the first name I came up with which wasn't taken I took it =).
Tuesday, August 26, 2008
I'll try to fix this problem as soon as possible.
edit: there seems to be no solution yet for blogger (only for blogger-draft). Even more of a reason to create my own website and host my blog there.
I have saved this post in .txt file and as soon as I complete my website I will post it.
Have Faith =)
Saturday, August 23, 2008
Here's how I did it:
the website will have to be split so that each box can be represented by a box with the following attributes:
- height (percent of screen/pixels/font size)
- width (see above)
- background color (any color represented by hex)
- background image (any size and anywhere)
- text or other content (tables/lists/links in any form of presentation)
Next we will start coding...
So I've gone ahead and done 2 quick sketches in bitmap:
remember this sketch is designed for me by me (which means it's encoded in maniacode) but I'm going to explain it to you anyway. The bblahblah part is the text the user is viewing, this can be a game too or pictures. The scribble to the right of it is supposed to be a scroll bar (don't laugh). The title (at the top) is the title of the document the user is viewing. The red scribble in the top left corner is my company logo (it signalizes uniqueness and creativity). The curvy blue/purple/light-blue lines are going to look shiny and clear like plasma/water tentacles. The menu is the black scribbles below my great company logo.
Here's my second sketch:
I'm not going to explain this one, it's readable by average maniacs so yeah...
When drawing your sketches put yourself in your viewers shoes. Would you find it accessible? Interesting on first sight? Neat? Ugly? Too Pretty? Too Colorized? Too Bland? Take special care that he finds what he's searching for quickly without any hassle.
The next post will be about splitting up your image into boxes as those are easier to represent in CSS/HTML,
Until Then... Bye
Wednesday, August 20, 2008
My outline looks like this:
---Unknown (will think of later)
----Welcome message with blog below that
----Contact formula not showing my e-mail address (due to security reasons)
--Style of Website
----Dark background with light text (cool)
-----black background with almost white text
----Very Light background with dark text (clean)
-----Blue tones and white and maybe mix in some purple
those colors just randomly came to my mind because i think they fit nicely together:
dark theme (cool): lllllllllllllllllllllllllllllllllllllllllllllllllllllll
light theme (clean): lllllllllllllllllllllllllllllllllllllllllllllllllllllll
Color picking can be a very big deal but for my purpose I don't need to know what every color represents and stuff like that's since it will be a rather small website at the beginning. When the hit-count picked up some speed I might post about picking correct colors for correct occasions but that's going to take some (long) while unfortunately.
Well, the outline is finished and now I have to think about how I will accomplish my goals...
Tuesday, August 19, 2008
Anyhow, I've decided to pause my development from my 3D engine and create myself a website. I really need one to post my Java apps/games and I'll add this blog to my website too (if I can). The website will also contain a contact formula (not showing my e-mail address). Later on, when there are more visitor I'm hoping to add a forum and an account-system which saves your game high scores and the like.
That's it for today...
Tuesday, June 24, 2008
Wednesday, June 18, 2008
Here's a picture:
The red line represents the end of the map. Now the map could go on almost infinitely so it's important that we stop drawing at some distance. This distance is the field of vision and is represented in the following image as a blue line.
To implement field of vision simply do a check:
Blogger is messing up my code, Trying to fix it soon
This doesn't look quite so good so we try to blend it out with fog:
The green line represents the FogDistance, this is so that the fog doesn't start right in front of our eyes. That could get annoying, but sometimes it is wanted so just set the distance to 1 when needed. We simply add a little bit more black each time the triangle gets farther away from FogDistance:
Blogger is messing up my code, Trying to fix it soon
int r,b,g; // Color values of triangle
if((a.z+b.z+c.z)/3 > FogDistance) // Check if greater than distance
// Make Darker by distance to fogdistance*fogintensity
r = r-(FogIntensity*a.z+b.z+c.z)/3-FogDistance);
b = b-(FogIntensity*a.z+b.z+c.z)/3-FogDistance);
g = g-(FogIntensity*a.z+b.z+c.z)/3-FogDistance);
// Very important check if color values are acceptable:
if(r > 255) r = 255;
if(r < r =" 0;"> 255) b = 255;
if(b < b =" 0;"> 255) g = 255;
if(g < g =" 0">
int r,b,g // Color values of triangle
if((a.z+b.z+c.z)/3 > FogDistance) // Check if greater than distance
// Make Darker by distance to fogdistance*fogintensity
// Very important check if color values are acceptable:
if(r > 255) r = 255;
if(r < r =" 0;"> if(b > 255) b = 255;
if(b < b =" 0;"> if(g > 255) g = 255;
if(g < g =" 0;">
FogIntensity should be very small, just try it out. Something like: 0.0001
That's it for today, I'll hopefully implement colors next.
Thursday, June 12, 2008
A friend of mine(my teacher, heh) got me interested in Ubuntu and I must admit it's rather god(intention++; spelling--;) compared to windows. I'm trying to install Ubuntu on my current computer so I will have dual boot(XP/Ubuntu). So far it's all working except the start-up takes 5min., that's the thing I'm working on right now of course.
Ubuntu is a great operating system if you enjoy do-it-yourself guides and want to know whats going on behind the scenes. It has shiny, quick, great, beautiful, work-enhancing, graphics which you can turn off if you have a different opinion. It's very clean since everything can be installed by packages from one place. No need to buy a CD or search the web for a cracked version, everything is completely free. (rambles on about how secure it is...) *dreams on*
After installing Eclipse and if needed JDK/JRE (Java Development Kit/Java Runtime Environment) I'll be back to my 3D engine. I thought about a simple implementation of colored triangles and field of vision fog.
Saturday, May 31, 2008
Sunday, May 25, 2008
The applet is Here. Unfortunately inside the Applet there is only a cube as the above figure is loaded from a text file and an applet can not do that for security reasons.
Now how did I remove the hidden surfaces? Well you simply find the Z-normal of a triangle and see if it's positive or not. If it is, it's facing you, otherwise it isn't. To find the Z-normal use the following formula:
normal = (t.b.x-t.a.x)*(t.a.y-t.c.y)-(t.b.y-t.a.y)*(t.a.x-t.c.x)
Where t is your triangle, a,b, and c are the three vertices and x,y, and z are the vertices coordinates.
I'm not sure where to go next. Until now, bugs have guided me but now there are none left (Yaaaay! o.o). A few options which I can think of are:
- speed optimisations
- Shading with interpolation (smoother shading)
- Add colors and textures (textures are main problem)
- create a very simple game with my current engine
- take a break and do something else
I'll probably do speed optimisations first but as I said, I'm not sure yet.
Tuesday, May 20, 2008
Do you see the green edges? well if z-fighting occurs along those edges it's not a big problem because you won't be able to see it since the wrong pixel will connect to all of the other pixels of the triangle it belongs to making it invisible. The points is, we can't see if pixels along the green edges z-fight so we don't have to fix that (lazy me =p).
Now how about the red edges? Well those are the problem, if a wrong pixel pops out from the other side of the cube it's totally out of place on the screen and doesn't connect to any other big body of same colored pixels which makes it really obvious that there is something wrong to the person looking at the applet.
Well we can get rid of the other half of the cube (the one which is not seen) by some type of hidden surface removal. This will speed up things and the red edges won't have anything to fight with therefore solving the problem. I'm not sure yet what the best way is to eliminate not seen triangles but I'll do some research and hopefully come up with an answer.
For those of you interested in solving the problem of z-fighting along the green edges for whatever strange reason ever it probably could be solved by adding a id number to each triangle and biasing the z-fight so that the triangle with the higher id would win even if it's pixel is deeper by 0.0001. I'll implement this when I'm terribly bored and have some spare time to waste. (probably never as it's not needed *.*)
Sunday, May 18, 2008
My Z-buffering implementation is almost perfect but there are still some problems:
- Speed optimizations (I'll do this after finishing my 3d engine)
- Flimsy Edges / Z-Fighting
Here's a picture of what I mean by "flimsy edges":
This happens because of Z-fighting. Z-fighting is when two triangles fight for a place on the screen because they are both about the same depth. Here it is only edges which fight as only they have equal depth. The above edge (circled in red and magnified) has light gray shaded pixels from the triangle on the other side on it. In the applet it is a lot easier to see what I mean so take a look.
I'm not quite sure yet about how I should fix this, a few (bad) ideas which come to mind are:
- Don't make the edges equal, translate one edge by 0.000001. I really don't want to do this since it's annoying to do for big models and my engine should be able to fix this some other way. This would be the answer for when I'm desperate, which I'm not yet...
- Draw a line around each side of the triangle after I'm done drawing it eliminating pixels from other triangle around the edges no matter what depth they are. This would of course mean that the triangles would have to be drawn in the correct order which they are not.
- Do some research, which is what I'm going to pick for now.
Apart from fixing this Z-Fighting issue I plan to go over the previous and future posts with spell check. My posts don't have any labels/keywords so I'll add some. Also my title is all text and I think it would be nice to add a picture behind it, I'm just going to experiment a little with my blog layout and settings.
My geocities page which hosts the applets is all white except for the applet and doesn't have a proper menu. I'll try to make it look a little better. Also geocities is probably not the best choice so I'll look around for something without advertisements.
Sunday, May 11, 2008
First you interpolate to find the two edges of the line you're drawing right now:
So if you would be drawing the grey line, you would have to find the numbers 1 and 10 by interpolating the end points of the two red lines; 1-1 and 1-20.
Next you interpolate between these two points to find any pixels depth/color/shading:
Now just repeat this process for every line of your triangle and you will have a nicely shaded/colored triangle. Remember to switch to you second pair of lines once you have passed about half of your triangle:
My implementation of z-buffering is buggy (triangles are drawn smaller/bigger than necessary) so I cant show you guys the applet yet but i hope it will be fixed in two or three days.
Thursday, May 8, 2008
Add a grid of numbers the size of the applet, One number per pixel. Now each time i draw a pixel I'm going to put the depth of that pixel into the grid. If the depth of the new pixel is higher than the depth of the old pixel I'm not going to draw it, otherwise i will.
To find the depth of a pixel in a triangle I will interpolate between the three vertex depths of the triangle, I'm not sure how yet.
I just finished a school project so ill have a lot more spare time. I plan to have Z-Buffering finished by Saturday or Sunday.
Wednesday, May 7, 2008
The cube rotates randomly in all three directions (x,y,z). Use your mouse to drag the cube around. While you are dragging it you can see the wire frame and vertices.
This applet should make it apparent why I'm going to work on z-buffering next.
Tuesday, May 6, 2008
Right now I'm trying to fix some things like:
This is caused by the over simplistic algorithm called z-sorting where you sort the triangles which make up the object by the average depth of it's 3 vertices (points) and then draw them from farthest to nearest.
Ill try to fix this by implementing z-buffering, or testing the depth of each pixel I draw and checking if it's going to be drawn onto a deeper pixel, if it is, I'll draw it, otherwise, I won't.
So my current ToDo list looks like this:
1. Upload applet
2. Fix z-buffering/z-sorting issue
Monday, May 5, 2008
It's still very simple, heres a list of things it does:
- load 3d models from simple triangle lists
- rotate models in any direction
- translate models...
- fill in triangles
- draw wireframe...
- shade triangles with normal shading (only grey scale)
- has object and world coordinates
- uses z-sorting
The rendering process goes something like this:
- get object
- add world coordinates to object
- add camera coordinates to object
- 3d -> 2d coordinates
- draw object, sort triangles with z-buffering and shade with triangle normals
Ill try to post pictures or even an applet tomorrow.
Sunday, May 4, 2008
I've finally decided to get a blog. I'm new to this thing so if I'm doing anything wrong (which I'm certain of) please leave a constructive comment to help me out.
I've been programming for about two to three years now. I first started out with Delphi, an object oriented programming language coming from pascal which is relatively old now. It's really easy, you just drag components onto a form and double click onto them to add source code. It was kind of a shock to me that you couldn't do that with java when I finally switched over to it two years late. I got over my shock quickly and have learned to love java. My current development environment is Eclipse and I mostly make applets since they are easy to share over the net.
If anyone DOES read this please comment. I will be very happy.
p.s. I'll be working on this template a lot so don't expect this site to stay like this
p.s.2 I'll try to post a lot (you've probably heard that often by now)