首页 > 代码库 > Unity3D~~~3D模型的简单属性

Unity3D~~~3D模型的简单属性

  每个3D对象是由顶点和面的。这被称为一个网格(Mesh)。每个顶点有一个归一化的“normal”的向量,表示连接到该顶点的面的方向。这对于计算光照来说很重要。当计算漫反射和镜面反射的照明,normal向量用于确定所述光与3d物体的表面之间的角度。

  下面是用于计算在一个物体表面上的每个点的颜色,以提供所有的值之间的关系的一个粗略的公式的一个极端的简化。这些都不是实际使用的方程式。 distance_to_object是在光源和物体与角之间的距离是在表面与光源之间的角度:

diffuse      = object_diffuse * light_diffuse / (distance_to_object * angle);
ambient   = object_ambient * light_ambient;
emissive  = object_emissive;
specular      = object_specular * light_specular;
final_color   =(diffuse + ambient +emissive)* object_texture+specular;

正如你所看到的,对象的最终颜色实际上是许多不同的灯光产生的效果的混合体。

简单介绍:

diffuse:最常用的颜色分量。变暗的表面点的距离的光(阴影)。如果衰减设置你的光源,当对象远离该光漫反射值将减小。扩散是主要的颜色值的后顾之忧。为材料的漫反射颜色是可见的,则必须具有至少一个光与非黑色漫反射颜色的图像,并且光必须在对象物的摄像机的一侧。作为与环境和自发光颜色,如果存在纹理,这会通过在纹理颜色相乘,否则这是因为如果它有一个白色的纹理。

ambient:创建具有光从四面八方打你的对象同样的效果。对于材料的环境颜色是可见的,则必须具有至少一个光带中的图象的非黑色环境色。为了确保没有黑边,以你的对象,尝试在场景中设置一个光源的环境值(0.1,0.1,0.1)和你的对象的环境价值等于其漫反射值(设置“颜色”参数为方便本)。这是理想的快速建立,只有一个光源的场景。如弥漫性和自发光颜色,如果存在纹理,这会通过在纹理颜色相乘,否则这是因为如果它有一个白色的纹理。

emissive:如果你想,即使没有灯光,或者如果你只是想有一点光彩添加到您的对象,请将此值设置为可见的对象。这具有作为环境确实只是它不要求有在发射环境光的场景的光相同的效果。如弥漫性和环境的颜色,如果存在纹理,这会通过在纹理颜色相乘。发光颜色并不实际光发射到其它的目的,否则这是因为如果它有一个白色的纹理。

specular:将此值设置将使你的对象或多或少有光泽。对于一个目的是具有镜面反射,该对象及所述光(多个)必须具有此值设为非黑色。对象也有一个“电源”组件的镜面反射,影响光泽的宽度。较低的值会产生小的镜面反射,而较大的值将拓宽反映。一个非常漂亮的效果是有4个或5个灯光在场景中随意放在身边每一个不同颜色的镜面,和你的对象的高光设置为白色(1.0,1.0,1.0)。尽量在5?100的功率值要得到充分发挥作用,你应该有你的对象绕。材质有镜面高光无影响。

texture:纹理映射到你的物体表面的图像。对于每个画面的像素表示的对象,对每个颜色分量(红,绿,蓝),我们首先计算使用漫反射,环境和自发光亮度,再乘上的纹理在该像素的颜色。镜面高,如果有任何,然后加入到所得到的颜色值。如果有质感,你通常要设置的漫反射和环境为白色。如果你想纹理展现原样,没有任何阴影,设置漫反射和环境为黑色,并设置发光为白色。

alpha:阿尔法决定物体最终颜色的透明度。它是在0.0(透明)到1.0(不透明)的值。如果材料具有纹理,纹理的alpha通道将覆盖材质的α值。

 

colorThis is both the diffuse and ambient color of your object. It is merely a convenient way of setting both at the same time. See diffuse and ambient below for more detail.
diffuseThis is the diffuse float_color value for a material on your object. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Objects can have multiple materials, one for each part of the object (cubes have six materials, one for each face). If you don‘t specify a material_index, you will be setting the color for all materials in the object. You can set an entire cube to blue by setting its color to (0.0, 0.0, 1.0). Color component values (red, green and blue) should be between 0.0 and 1.0, though using values greater than 1 can make the object brighter in darkly lit scenes. When calculating the color and shading of an object, we take each light source within range and cumulatively multiply their diffuse and ambient colors by the diffuse and ambient colors of the object respectively. The diffuse light is adjusted for attenuation (distance to light) and the angle between the surface and the light (on a per vertex basis using vertex normals) while ambient light is NOT adjusted for distance or angle. Emissive is then added to the diffuse and ambient values. If there is a texture, it will be adjusted by the sum of the lit diffuse, ambient and emissive values. So setting diffuse and ambient or emissive color values to (1, 0, 0) will eliminate all greens and blues from the displayed texture. Then the calculated lit specular value is added to produce the final shading for the D3D Picture Part. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0).
ambientThis is the ambient float_color value for a material on your object. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Color component values (red, green and blue) should be between 0.0 and 1.0, though using values greater than 1 can make the object brighter in darkly lit scenes. When calculating the color and shading of an object, we take each light source within range and cumulatively multiply their diffuse and ambient colors by the diffuse and ambient colors of the object respectively. The diffuse light is adjusted for attenuation (distance to light) and the angle between the surface and the light (on a per vertex basis using vertex normals) while ambient light is NOT adjusted for distance or angle. Emissive is then added to the diffuse and ambient values. If there is a texture, it will be adjusted by the sum of the lit diffuse, ambient and emissive values. So setting diffuse and ambient or emissive color values to (1, 0, 0) will eliminate all greens and blues from the displayed texture. Then the calculated lit specular value is added to produce the final shading for the D3D Picture Part. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0).
emissiveThis is the emissive float_color value for a material on your object. Emissive color is similar to ambient color, except that it does not require that any light be in the picture. An object with an emissive color of white and no texture will appear pure white in your picture. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Color component values (red, green and blue) should be between 0.0 and 1.0. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0).
specularThis is the specular float_color value and power for a material on your object. Specular is made up of a float_color (red, green, blue) and a Power component. The Power component of specularity adjusts the sharpness of the highlights. A larger power value creates sharper specular highlights, making the surface appear to be quite shiny. Smaller values increase the area of the effect, creating a dull reflection that makes the surface look frosty. To make an object truly matte, set the power member to zero and the color in specular to black. Powers usually range between 0 and 100 or so. Specular highlights are affected by attenuation. Specular is independent from diffuse, ambient and emissive, and requires that the light have a non-zero specular value. The specular highlights are added to the lit diffuse, ambient and emissive values to get the final displayed color. Specular is an independent system This can be either 4 floats (red, green, blue, power) or 4 floats and 1 int (red, green, blue, power, material_index). Setting specular to anything other than black will incur a slight performance hit for each call to picture.present().
alphaThis is the alpha value for a material on your object. Alpha is a float which should be between 0.0(transparent) and 1.0(opaque). A value of 0.5 will be half transparent, meaning that whatever is behind this object (given that what is behind is drawn BEFORE this object) will contribute to 50% of the final color.
transparent_colorThe transparent_color color is used by the load_texture() method in sdl. It is 3 ints (red, green, blue). Any texture loaded by the load_texture() method in pcl will have this color set to transparent (an alpha of 0). When loading a mesh, the textures loaded during that process will have this transparent_color applied to them. To conserve video memory, we recommended that you create Texture objects and apply them to your D3D Picture Parts manually in order to reuse the same texture in multiple places.
mesh_textureTexture to apply to the object. The material_index is optional. Create a named Texture object in sdl above the D3D Picture Part definition and then apply it to objects by setting this value.
mesh_scaleScale modifier. Takes three floats (x, y, z). Will scale an object along three axes. A scale of anything other than (1.0, 1.0, 1.0) will incur a slight performance penalty when rendering. If you object is one of the built in D3D Picture Parts (i.e. cone, cuboid, cylinder, mesh, plane, sphere), it is better to size your object beforehand to the desired size. If you are loading an 3d object from a file using the mesh picture part, it is better to use scale_factor, which applies a one time scaling to the mesh upon loading. If you plan to frequently scale your D3D Picture Part during animation, mesh_scale and the set_scale() method would be more appropriate since the scale_mesh() method can incur a slight one time hit to performance.
descriptionDescription of this object.

Unity3D~~~3D模型的简单属性