.. (לתיקייה המכילה) | ||
How can I create a mipmap files? | |
You can take any image from the internet and create multiple downscaled copies of it for all mipmap levels. To create those files you can use some kind of image editing software (For example IrfanView). The example set of mipmap images was put on the HW2 section. | |
קישור: Link: Ссылка: وصلة: | http://webcourse.cs.technion.ac.il/234325/Winter2010-2011/hw/WCFiles/mipmap_example.zip |
We can only load texture images with power-of-2 size. How can we fix it? | |
Modern OpenGL cards support loading of any texture sizes, however if you use a simple graphics card or an old one you may still have power-of-2size limitation. In general you are not required to solve this problem in the HW and it is enough to support only power-of-2 size textures. For those of you who still want to make their textures a bit more robust and pretty there is a solution. You can use gluBuild2DMipMaps() function instead of glTexImage2D which will load any texture and make it power-of-2 compatible. You can even improve the quality of your texture mapping by using the appropriate filters when that function is used. (Note that it is wrong to use gluBuild2DMipMaps for implementation of mipmap advanced feature) |
Where should the texture file be found? Should we specify the full path in the model's ptexture attribute? | |
The texture file is expected to be in the same directory as the IRIT model file. There is no need to specify the full path to the texture file in IRIT ptexture attribute but only the filename itself. For example "myimage.png". |
When rendering object with texture we don't see effect of specular lighting. Specular works fine without the texture , what happened? | |
In order to fix this you will have to add the following line to your code: glLightModel (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR); See item 21.040 at http://www.opengl.org/resources/faq/technical/texture.htm for more details on why this happens. Also, not that you might get a compilation error due to missing definition of the GL_.. constants. In this case also add the following lines in the beginning of your file: #ifndef GL_LIGHT_MODEL_COLOR_CONTROL #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #endif #ifndef GL_SINGLE_COLOR #define GL_SINGLE_COLOR 0x81F9 #endif #ifndef GL_SEPARATE_SPECULAR_COLOR #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #endif |
We want to implement the transparency. Where can we get transparent objects? | |
Most of the car models has transparent windows. But you should take a few multi-object scenes and set the "transp" attribute for one or two interesting objects. [transp <value>] The transparency value in IRIT is in 0..1 range while 0 is not transparent and 1 is fully transparent. Note that you should use 1-transp since in OpenGL RGBA alpha component has 1 as non-transparent and 0 for fully transparent color. IRIT model example: [OBJECT [RGB 255 255 255] [COLOR 15] [transp 0.3] globes [POLYGON [PLANE -0.104431 -0.991299 0.0801278 5.63015] 3 [-1.11344 5.67411 -1.5187] [-0.935916 5.64712 -1.62119] [-1.08087 5.67411 -1.47624] ] ... Parser code (CGSkelStoreData): ... if (CGSkelGetObjectTransp(PObj, &Transp)) { /* transparency code */ } ... |
How do I read UV coordinates from IRIT? | |
For each vertex you can check PVertex->Attr->Type and if it equals to IP_ATTR_UV you can read the UV coordinate from PVertex->Attr->U.UV. Code example: if(PVertex->Attr && PVertex->Attr->Type==IP_ATTR_UV) { uv[0]=PVertex->Attr->U.UV[0]; uv[1]=PVertex->Attr->U.UV[1]; } |
Where does IRIT get the UV coordinates for the model? Can I add my own into IRIT file? | |
IRIT generates UV coordinates for certain models. (For example "teapot.itd".) Unfortunately you cannot add UV coordinate manually to the file. In case you want to debug the OpenGL functionality on a simple model my advice is to create a function which draws a cube and specifies it's texture coordinates directly in the code. |
Which IRIT files have a "ptexture" attributes? | |
The files which by default have "ptexture" attributes are "ComputerRoom" and "LivingRoom". You are not required to work with only these and are encouraged to add manually textures to other irit files. It's best to start with a teapot. In order to add "ptexture to the file manually you need to find and OBJECT keyword and put the following phrase right after it (along with other parameters): [ptexture "myimage.PNG"] Example for usage of ptexture in IRIT file: ... [OBJECT [ptexture "myimage.PNG"] [color 5] HANDLE [SURFACE BSPLINE 7 7 4 4 E3 [KV 0 0 0 0 1 1 1 2 2 2 2] [KV 0 0 0 0 1 1 1 2 2 2 2] ... |
The material dialog has some problems with the types of its members. | |
There is bug in the material dialog code. The type of specular and shininess variables got swapped. Please change specular to double and shininess to int. Also the shininess range check should be 0..128 and not 0…1 as it is now. In addition in the COpenGLView there is a member variable m_nMaterialCosineFactor. This varialbe name can be changed into m_nMaterialShininessFactor. |
There are a few options for the spotlight that are not included in the light dialog such as GL_SPOT_CUTOFF and GL_SPOT_EXPONENT. What should we do? | |
You can choose any of the following options (or their combination): • Choose default fixed values so the lights are useful and nice. • Choose default values based on object & light positions so the object always looks nice • Add parameters to the GUI which allow controlling those values. |
My object is shaded with very saturated colors (like extremely bright sunlight). Is it ok? | |
No it is not. Check that you are scaling the light colors you got from the dialog from 0-255 to 0…1 and use correct OpenGL APIs to configure them. |
I have to specify three components for diffuse/specular and ambient material properties, however in the dialog there is only one for each of them. | |
You should put the same factor value in each color component when setting material properties. For example: glMaterialf(GL_FRONT_AND_BACK, GL_SPECULAR,m_specular, m_specular, m_specular,1.0f); |