public class SoMaterial extends SoNode
SoMaterial
sets several components of the current material during traversal. The ambientColor, diffuseColor, emissiveColor, specularColor and shininess fields are interpreted according to the classic OpenGL lighting model. The transparency field is effectively the inverse of "opacity" or "alpha value".
SoMaterial
在遍历过程中设置当前材质的几个组成部分。ambientColor,diffuseColor,emissiveColor,specularColor 和 shininess 字段根据经典的 OpenGL 光照模型进行解释。transparency 字段实际上是“不透明度”或“alpha 值”的反义词。If lighting is turned off (SoLightModel
set to BASE_COLOR), only the diffuse color and transparency fields are used to render geometry.
如果关闭了照明( SoLightModel
设置为 BASE_COLOR),则只使用漫反射颜色和透明度字段来渲染几何体。
Multiple values can be specified for the diffuseColor
and transparency
fields. Different shapes interpret materials with multiple values differently. To bind materials to shapes, use an SoMaterialBinding
node.
可以为 diffuseColor
和 transparency
字段指定多个值。不同的形状会以不同的方式解释具有多个值的材料。要将材料绑定到形状,使用 SoMaterialBinding
节点。
Several other nodes can be used to set diffuse color and transparency.
可以使用其他几个节点来设置漫反射颜色和透明度。
If the other color values are not needed, these nodes use a little less memory than an SoMaterial
node, especially if multiple color values are specified. Generally SoVertexProperty
is the most efficient mechanism and may provide better performance than using SoMaterial
. Note that for these nodes transparency is set as "alpha value" (inverse of transparency).
如果不需要其他颜色值,这些节点使用的内存比 SoMaterial
节点稍少,特别是如果指定了多个颜色值。通常, SoVertexProperty
是最有效的机制,可能比使用 SoMaterial
提供更好的性能。请注意,对于这些节点,透明度被设置为"alpha 值"(透明度的反义词)。
SoBaseColor
node. SoBaseColor
节点来指定。SoPackedColor
node.
SoPackedColor
节点来指定。SoVertexProperty
.
SoVertexProperty
的 orderedRGBA 字段为多边形几何图形指定漫反射颜色和透明度。The color components specified for lights mean something different than for materials. For a light, the numbers correspond to a percentage of full intensity for each color. If the R, G, and B values for a light's color are all 1.0, the light is the brightest possible white. If the values are 0.5, the color is still white, but only at half intensity, so it appears gray. If R=G=1 and B=0 (full red and green with no blue), the light appears yellow. The intensity can also be modulated using the SoLight.intensity
field.
对于灯光和材料,指定的颜色组件意味着不同的东西。对于灯光,这些数字对应于每种颜色的全强度的百分比。如果灯光颜色的 R、G 和 B 值都是 1.0,那么灯光就是最亮的可能的白色。如果值是 0.5,颜色仍然是白色,但只有一半的强度,所以它看起来是灰色的。如果 R=G=1 且 B=0(全红色和绿色,没有蓝色),灯光看起来是黄色的。强度也可以使用 SoLight.intensity
字段进行调节。
For materials, the numbers correspond to the reflected percentages of those colors. So if R=1, G=0.5, and B=0 for a material, that material reflects all the incoming red light, half the incoming green, and none of the incoming blue light. In other words, if an OpenGL light has components (LR, LG, LB), and a material has corresponding components (MR, MG, MB), then, ignoring all other reflectivity effects, the light that arrives at the eye is given by (LR*MR, LG*MG, LB*MB). As a result, for example, shining a pure blue light on a pure red cone has no visible effect.
对于材料,这些数字对应于反射的颜色百分比。因此,如果材料的 R=1,G=0.5,B=0,那么该材料反射所有进入的红光,反射一半的绿光,不反射任何进入的蓝光。换句话说,如果一个 OpenGL 光源有组件(LR, LG, LB),并且一个材料有相应的组件(MR, MG, MB),那么,忽略所有其他反射效应,到达眼睛的光线由(LR*MR, LG*MG, LB*MB)给出。因此,例如,将纯蓝色光照射在纯红色的圆锥上没有可见效果。
Similarly, if you have two lights that send (R1, G1, B1) and (R2, G2, B2) to the eye, the components are added, giving (R1+R2, G1+G2, B1+B2). If any of the sums are greater than 1 (corresponding to a color brighter than the hardware can display), the component is clamped to 1.
同样,如果你有两个灯光分别向眼睛发送 (R1, G1, B1) 和 (R2, G2, B2),这些组件会被相加,得到 (R1+R2, G1+G2, B1+B2)。如果任何和大于 1(对应于硬件无法显示的颜色),该组件将被限制为 1。
To force all geometry following/below this node to use specific color and transparency values, call the setOverride() method with true. Overriding the diffuse color and transparency overrides the color and transparency values in other nodes including SoPackedColor
and SoVertexProperty
. This can be useful, for example, to highlight a selected object.
要强制此节点以下的所有几何体使用特定的颜色和透明度值,请使用 true 调用 setOverride() 方法。覆盖漫反射颜色和透明度会覆盖其他节点(包括 SoPackedColor
和 SoVertexProperty
)中的颜色和透明度值。例如,这可以用于突出显示选定的对象。
It is also possible to override only a subset of the SoMaterial
fields. If, for example, you only want to override the diffuse color, but not the other values, call setIgnored(true) on the fields that you do not want to override. But note that this selective override technique only works on other SoMaterial
nodes! For SoPackedColor
and SoVertexProperty
, the diffuseColor and transparency values are bound together and cannot be overridden separately.
也可以仅覆盖 SoMaterial
字段的一部分。例如,如果你只想覆盖漫反射颜色,但不覆盖其他值,那么在你不想覆盖的字段上调用 setIgnored(true)。但请注意,这种选择性覆盖技术只适用于其他 SoMaterial
节点!对于 SoPackedColor
和 SoVertexProperty
,漫反射颜色和透明度值是绑定在一起的,不能单独覆盖。
The default transparency algorithm is NO_SORT. To get a nice appearance for transparent objects you must change this to another value, for example, OPAQUE_FIRST or SORTED_PIXEL, using the setTransparencyType method in the Viewer class. See SoGLRenderAction
for a discussion of transparency algorithms and rendering order.
默认的透明度算法是 NO_SORT。为了使透明对象看起来更好,您必须将其更改为另一个值,例如,OPAQUE_FIRST 或 SORTED_PIXEL,使用 Viewer 类中的 setTransparencyType 方法。请参阅 SoGLRenderAction
以讨论透明度算法和渲染顺序。
Material { 材料 {
ambientColor 环境色 | 0.2 0.2 0.2 |
diffuseColor 漫反射颜色 | 0.8 0.8 0.8 |
specularColor 镜面颜色 | 0 0 0 |
emissiveColor 发射颜色 | 0 0 0 |
shininess 光泽度 | 0.2 |
transparency | 0 |
Action behavior:
SoGLRenderAction
, SoCallbackAction
Sets the ambient color, the diffuse color, the specular color, the emissive color, the shininess, and the transparency of the current material. Sets: SoLazyElement
See also:
SoBaseColor
, SoLightModel
, SoMaterialBinding
, SoPackedColor
, SoVertexProperty
,
SoNode.RenderModes
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoMFColor |
ambientColor
Ambient color of the surface.
|
SoMFColor |
diffuseColor
Diffuse color(s) of the surface.
|
SoMFColor |
emissiveColor
Emissive color of the surface.
|
SoMFFloat |
shininess
Shininess coefficient of the surface.
|
SoMFColor |
specularColor
Specular color of the surface.
|
SoMFFloat |
transparency
Transparency value(s) of the surface.
|
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoMaterial()
Creates a material node with default settings.
|
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
getNativeResourceHandle
public final SoMFColor ambientColor
Ambient reflectance affects the overall color of the object. Because diffuse reflectance is brightest where an object is directly illuminated, ambient reflectance is most noticeable where an object receives no direct illumination. An object's total ambient reflectance is affected by the global ambient light (see SoEnvironment
) and ambient light from individual light sources. Like diffuse reflectance, ambient reflectance is not affected by the position of the camera.
public final SoMFColor diffuseColor
Diffuse reflectance plays the most important role in determining the appearance of an object. It's affected by the color of the incident light(s) and the angle of each incident light relative to the object's normal direction. (It's most intense where the incident light falls perpendicular to the surface.) The position of the camera doesn't affect diffuse reflectance at all.
public final SoMFColor specularColor
Specular reflection from an object produces highlights. Unlike ambient and diffuse reflection, the amount of specular reflection does depend on the location of the camera - it's brightest along the direct angle of reflection. To see this, imagine looking at a metallic ball outdoors in the sunlight. As you move your head, the highlight created by the sunlight moves with you to some extent. However, if you move your head too much, you lose the highlight entirely.
This field specifies the color of the reflected light. The shininess
field controls the size and brightness of the highlight.
public final SoMFColor emissiveColor
Emissive color makes an object appear to be giving off light of that color, independent of any lights (or lack of lights) in the scene. It can be useful for highlighting selected objects in the scene.
public final SoMFFloat shininess
The dot product of the vector reflected by the surface normal and the inverted light vector is raised to the "Shininess" power. The higher the shininess number, the smaller the resulting specular highlight turns out to be.
public final SoMFFloat transparency
Transparency is the inverse of "opacity" or "alpha" value.
Generated on July 31, 2019, Copyright � Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com