View Full Version : Assistance with programming ground and "Skyboxes"
01-20-2009, 11:32 AM
Hello, I am Ocram and I am trying to program a 3D game and I want to start with a basic environment with a flat terrain a sky, and a skyline. I have a picture (3392x1728) to cover the entire terrain and a much smaller picture to repeat as a skyline. In games like City Life the skyline would be called a "Skybox" a flat picture in the background to show what is beyond the map, (like a mountain range).
I know how to open an OpenGL window and change its colors, how to draw a triangle and quad, how to give them color, how to make a triangle strip and other basics. I also have a relatively firm grasp on C++ so I know what I am doing. I do NOT have glaux because it is outdated. Sorry if I sound like a newbie because I am pretty new to OpenGL.
01-20-2009, 11:44 AM
Mere is a picture demonstrating what I am trying to do.
I know that it is not very good, I made it in paint. I only showed two sides of the "skybox" because there will be no texture on the side facing away from the ground.
01-20-2009, 12:51 PM
And your question is ... ?
Do you know texturing ? In this case the ground is easy, textured quad and it is done. The skybox is easy too, to repeat the texture simply use larger texcoords to multiply the number of times needed.
Basic texture tutorial, with ultra simple file format to load :
01-26-2009, 10:34 AM
Well, it works good for the first 256x256 pixels and I thank you for that but texture I want for the ground is a rectangle with the dimensions being 3392x1728 pixels and I wish for each pixel to represent 25 cm so that the ground is 848x432 meters in game and then I would like to be able to eventually build upon that coding and allow 3D buildings to be built upon each colored rectangle (zone). Here is the picture to demonstrate what I mean (ground wise) http://img48.imageshack.us/img48/5217/opentowergroundqb2.th.png (http://img48.imageshack.us/my.php?image=opentowergroundqb2.png) Thank you for that link anyways, it helped a TON!
EDIT: If it helps, the picture is divisible by 64 both ways so if it must be divided into 64x64 pixel squares, I would need to make it into a grid of 53x27 64x64 pixel squares.
01-26-2009, 01:43 PM
Again, what is your question ???
Maybe what you are looking for is some kind of 2D tile engine, like in the old days of sprite-based graphics.
Some ideas here :
Then of course you can move freely your 3d camera instead of using ortho.
BTW, no offence, but your texture is ugly.
01-26-2009, 05:25 PM
It is meant to be similar tho SimCity 4's zoning (without the arrows) and the colors (blue, green, red, and rainbow) will be swapped out for dirt brown. My question was <u> "How do I get this terrain to work and be able to view it in 3D?" </u> Thank you for the links and yes, I will be using 3D. I asked everyone on the boards for our game and all the main members said full 3D (so did most everyone else except one member that said it would be more difficult and be more taxing on computers). So the links you gave me are for 2D tile engines, your comment said that they can be used for 3D. by the way, Did I mention that this is meant to be cross platform and that everyone on the websites for this game voted on development and almost unanimously voted for C++ with OpenGL via SFML using Code::Blocks. So if there is anything that would require platform dependent software, I will need to find an alternative.
EDIT: Would a quad strip alleviate the problem? Each quad in the strip would get a different texture and voila! I get the ground! Use a quad strip for each side at a 90 degree angle and I have a skyline! I believe a quad_strip uses less memory than a bunch of quads but do I need a different strip for every row? That makes 2 questions. Before I just stated what my problem was without asking for advice.
01-30-2009, 03:13 PM
All right. I am updating this thread with new information. I am now universally using 16 pixels per meter. I have now divided the giant picture into high quality 64x64 pixel squares and for the inside of the future towers to be built on the property I have divided it into 16x16 pixel squares (1 meter squared instead of 4x4 meters) because greater accuracy is needed for the inside. For now I want to Know how to make the 848x432 meter terrain and the 16 meter high skyline surrounding it. I want it to be rendered in 3D and my main question is what should I texture map? Should I texture map 1 quad, many quads, 1 quad strip or several quad strips? I want to know the least computer intensive and the best way for allowing construction accurate to the meter on top of it. So far all I have are the textures for the ground and partially transparent textures for the overlay (instead of the horrendous checkerboard I had going previously).
Please forgive me for double posting, I wanted to provide new information and no one posted for a little while. Please inform me politely if I have done anything wrong. The other people on the projects (who only make suggestions and pitch ideas and know little to nothing about any programming) are a little impatient (Especially because we were attacked by trolls who were originally disappointed fans that thought that our project was going no where fast). Here is the website by the way if you want to see our progress http://opentower.forumotion.com/forum.htm
01-31-2009, 02:05 AM
Best is to do your own tests. Simple is to use one quad for each face and texture. You can also google for tutorials on how to do textures.
01-31-2009, 02:59 AM
I just had a quick glance from your forums :
"Skyscrapersim.com is good but we have to decide OpenGL or crystal space."
"I say OpenGL. It's cross-platform."
And crystal space is not ? (hint: yes it is). Starting with an existing project which have working buildings will be useful for you, as apparently you have such a hard time to make your basic texturing correctly.
About performance, let me tell you a good advice : first make it work !
Then if needed, try to optimize. Benchmark perfomance before and after, sometimes optimizations can make it slower.
02-05-2009, 10:45 PM
OK, I have been experimenting with a couple of ways to generate the terrain an I have found out that I can make an integer variable and increase it for each quad in the quad strip and it even works for making multiple rows and columns of quads. I have switched over to smaller (16x16 pixel) individual textures and made 64x64 pixel semitransparent PNGs for the zone overlay (to implement much later).
<u>I (now) want to know if I should make each quad 1x1 OpenGL units or 16x16 OpenGL units. Please help me, I want this to run on as many types of computers as possible. Thank you in advanced. A link for applying textures to quad strips would also be greatly appreciated but will not be necessary (to continue programming OpenTower) for at least 2 weeks. </u>
Everyone is excited that I have made some progress and I am eternally grateful to everyone that lead me in the right direction.
If I don't find out how to texture a quad strip, I will ask about that later. Thank you for all the help and information so far (and if Zbuffer never pointed out the quality of my texture, I would not have made my textures aesthetically pleasing to myself at least). Once the forum is fixed to allow attachments, I will upload the source code where it belongs so all can critique it and use it and build upon it (the first dozen pre-alphas will be generating terrain only and would be great for building upon to make your own computer game). I will look at the legal terms for software and release everything as open-source and public domain.
by the way, I know nothing about Crystal Space, so far love OpenGL, and it would be difficult to combine SkyscraperSim and OpenTower. I found out that skyboxes are actually the background (when it comes to OpenGL at least) and will refer to the skyline as such (which will be a basic transparent quad strip for each side with a different PNG with transparency repeated over each quad strip).
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.