Showing posts with label model. Show all posts
Showing posts with label model. Show all posts

Sunday, 9 January 2011

Week 15 - Planet Models and Sky Box

My last major update was some weeks ago, detailing the completion of text on the screen. This that point, the program has progressing significantly - most of all aesthetically.

The first problem in the programs looks I wanted to solve was how to get a starry background in place - this adds greatly to the realism of the program. I decided that the best method would be to create a sky box - essentially a large box around the camera with edges that blend into each other, so it looks like a continuous background every way you look.

This proved to be more difficult that I had anticipated. In the end, I used sky box tutorial code, found here, and edited the size of the box and the images to be displayed myself. Another problem risen by this was the use of the GLaux library - which has been discontinued. This is mainly used in the loading of the BMP image for each side of the box. I had to implement replacement code, which I found here.

Initially, I used a really hi res star map I found using google images - this can be seen in the background for the program two blogs ago, showing the Earth. I replaced this with a star map found on the NASA website - namely, the Hipparcos star map. The stars are really colourful, and I used the original colouring at first - but found it was too hard to spot some of the smaller planets like Mercury in the program, because they looked like one of the stars in the map! So I greyscaled the image and used that as my background. Because the scene has to look continuous, every side of the sky box uses the same image.

In my project plan I had specified that I had hoped for planet modelling and loading into the program to be completed by this week, week 15 - and that is the other main part I have managed to complete this week. You can see the renders for each model in the previous blog. The models unfortunately cannot look that good in the program, but I think they still look pretty nice. Another big change from the previous blog is that I have fixed the lighting - in my excitement at getting the models into the program and working, I had not noticed that the lightning was no longer affecting them. In fact, I had forgot to turn on GL lightning in the myDrawGLScene class! I placed this call after the Sun model is draw - this way, shadows don't affect the Sun model so it appears to be a light source.

The final change I made was to make the model scales more realistic - previously, they were very rough estimates by myself, just to give an idea. I used the size calculator at this website, with the largest planet having a scale value of 1.21 - Jupiter (actually saturns is larger, but this is because the model is loaded in a lot smaller due to the rings). If the Sun was draw to scale, it would have a value of 11 - this is too large realistically for my model, so it is currently at a value of 2 (although I may change this).

Finally for this week, a screenshot of the program, again seen from Jupiter. As you can see, the lighting has made quite a difference to the quality of the model:


The inner four planets have all taken a size decrease, whilst Jupiter has actually got slightly bigger than I orginally had it. You can make out The Earth, Venus and Mercury in various states of orbit in the above image, as well as Mars (red dot some way above Venus, quite hard to spot!).

That's all for this week. The next major update will probably not be till the start of the new semester, due to exams.

Wednesday, 5 January 2011

More Models + Program shot

Another quick update today, I finished all the 3Ds Max models and here are some screenshots of the renders. Remember and click to expand the images.

The Sun



Mercury


Venus


Mars

Jupiter

Saturn

Uranus


Neptune



And finally, a shot of the program, from the perspective of Jupiter looking towards the Sun. You can see the inner four planets - Mars (top right), Earth and Venus (above the Sun) and Mercury (small dot below the Sun). I've also decided to use a different star image in my skybox, as the last one seemed a little busy and hurt the eyes - I think this one looks better.



Full technical update still to come at the end of the week.

Tuesday, 4 January 2011

Earth model

A full update on all the work I've done over the Christmas break will come at the end of the week, but I just wanted to post the model of the Planet Earth I've just completed:


I'm quite pleased with it. However, it should be noted that this is a render in 3Ds Max - it won't look as good as this in the program. I've managed to get it to load in the program, but it seems to be causing a lot of speed issues - a bit worrying when theres 8 other models to go!

Full update on the date system and hopefully more models to come at the end of the week.

Edit:

I've just implemented a sky box to give a starry background, and here is what the Earth model looks like in the openGL program:


Not quite as good as the render, but still pretty nice!

Monday, 29 November 2010

Week 8 - Animation

This week I have been working on the DrawSolarSystem class. I've added quite a lot  - some initial keyboard functionality has been added (zoom, pan, rotate and pause), as well as mouse movement. This is in a very early form and I'm not happy with some elements, but it will do for now! The main focus of this weeks work was trying to implement the orbit of one sphere around another. I managed to implement this successfully, and went ahead to program the orbits for all the planets.

Another issue that was raised during my meeting with Rob was the slight difference in accuracy for my figures in the previous blog. I did some more research, and believe this is down to a difference in time. In the Utretch unversity page, they take 1st Jan 2000, 12 noon UTC as their start date. Their current date is 1st Jan 2004, 0:00 UTC. My program only calculates julian dates using day, month and year, where the time of day is as default 12 noon. This means theres a 12 hour difference between their current date and mine, which is I believe the reason for the slight difference in figures.

Firstly, I'd like to list major changes and additions to the classes.


  • the drawOrbit method in OrbitalCalculations has been changed to a type void, and thus doesn't return the planet's vector anymore. I've created a new method to return the vector, so it can be retrieved by the program without doing the whole drawing orbit calculation.
  • The Julian Date is defined as a variable julDate at the top of the DrawSolarSystem class now. This allows the julian date to have numbers added to it in order to increase the time.
  • Planets are created at the top of the DrawSolarSystem class as well, instead of in initGL, outside all methods. This is so different methods can use them.
  • For the same reason, instances of OrbitalCalculations are also created at the top of DrawSolarSystem.
  • Two new methods have been added to DrawSolarSystem for camera manipulation. One called camera, and one called mouseMovement.
  • A new method has been added to DrawSolarSystem to read in each model, so there are 9 methods of this type in total.
  • A new method has also been added to update every planets position, so there are 8 methods of this type.


Now I'm going to run through how the program reads in a model, puts it into a display list, draws that list then updates the planets position.

Firstly the model has to be read in. I use a seperate method for each model, simply to ensure each model is read in correctly. For now I am only using two models - suntest.obj, a yellow sphere, and planettest.obj, a red sphere. Both were created and exported from 3Ds Max. Here's the code to read in the sun model, the rest are much the same:


Next, the models are put into display lists in initGL. Putting the model into a display list means it can be scaled before being called by the drawing method, so it only happens once at the start of the program. As all the models read in are scaled to the same size to fit in the matrix, they have to be scaled again in order to maintain size difference. At the moment my figures are pure estimates, just done to give an impression of the size differences. Lights are also defined in initGL. At the minute, all I have is an ambient light. Here is the code to place the sun model into a display list (note: the scale is so small so that I can zoom greater distances, you'll see why I need to later!):


Now before I call the display list in myDrawGLScene, I need a method to update the position of the planet. Since myDrawGLScene is redrawn all the time, a loop is not required, as the update method will be called each time the scene is redrawn. So all I need to do is increase the julian day every call to the method, draw the orbit and translate the model by the x, y and z coordinates generated. Here is the method for mercury:


Now the display list can be called in myDrawGLScene when the model is drawn. Here is the code for the sun and mercury:


All this resulted in the following screen shots. The first image shows the Sun, Mercury,Venus and the Earth. The second is zoomed out slightly to include Mars. The third is zoomed out a lot to include Jupiter, Saturn, Uranus and Neptune. As you can see, the distances all look to be in proportion, with a lot of zooming out required to see Neptune! At the moment it looks a bit 2D, but thats due to the fixed angle and lack of lighting to give shade. Note that all planets are reading in the same test model, which is why they are all red.






Thats it for this week!