Most of this page was translated from http://demura.net/archives/9ode by Babel Fish Translation.
Sorry for strange and funny English from “the Chinese room“.
A sample screenshot of modified texures (details on RoboCon MagazineNo.50)
This is 19th article about ODE (Open Dynamics Engine) Tutorial. ODE is an open source physics libary, and it is widely used in various game software, and simulators in research.
This time, I explain how to customize the drawstuff , the 3D graphics library, which has been attached to ODE with a free gift. Drawstuff being to be the very used OpenGL simple library is useful to also the study of OpenGL. You viewing one time source code, how, probably will be?
3 kinds of textures
In the draw staff just texture of 3 types which are shown in the rough sketch is used. As for these filesusingstandard ones which are called ppm (portable pixmap) format, it is under ode-0.8/drawstuff/textures. The user does not appoint the texture of the sky and the ground, it is applied automatically, but, using dsSetTexture (DS_WOOD), it sets the texture of the object. When cancelling setting, dsSetTexture (DS_NONE) is used.
- Texture of the sky: Sky.ppm
- Texture of the ground: Ground.ppm
- Texture of objects: Wood.ppm
Texture of the sky
Texture of the ground
Texture of objects
Note: It has converted texture in the upper figures to jpg format in order to indicate with the browser.
Modification method of texture
When using the GIMP, the GNU image maniplulation program, you can save the texture file as raw (raw) mode of ppm type, and overwrite the texture file on the original texture file. The new teture becomes effective. As for size sky.ppm 128×128 pixel, ground.ppm and wood.ppm has become 256×256 pixel.
Being to be able to modify, it does, texture with this but, being boundary of the land and the sky continues to be the standard color grey a little it becomes matter of concern. In order to modify this color, it is necessary to rewrite the source code of drawstuff. Until now, the source code is rewritten, please try challenging also the one which you think that how it is awesome. The fact that the source code is customized steadily is Daigo taste of the open source.
- The file ode-0.8/drawstuff/drawstuff.cpp which modifies
It meaning that 1123rd line glClearColor (0.5, 0.5, 0.5, 0) has decided boundary color, when it modifies 3 arguments (red component, green component and blue component) of beginning in the color which by your like, make does again to do ode it is reflected. Each color component of glClearColor is the range up to 1 from 0 as the point where you note.
- Sampling process of color
If boundary color is possible, don’t you think? it is to do it is potato in the same type color as the texture of the land. The software of of free color of the place where we like on the picture is extracted is found if it searches with google, simply. As for me GetColor has been used, but if you search, you think that there is a variety.
- In order to gradate the horizon,
In the actual world as for horizon with such as dust in the atmosphere being visible in clearing it is rare. In order to simulate this, if there is a fog, the horizon becomes blurred, don’t you think?. In order to actualize this, if the comment of 1016th line is removed from the 1006th line of drawstuff.cpp, it is OK. However, there is a problem with some graphics boards.
This time with this end.