简体   繁体   English

如何在不设置OpenSceneGraph中的材质的情况下在osg :: Geometry上设置发光度

[英]How can I set shininess on an osg::Geometry without setting a material in OpenSceneGraph

I have an osg::Geometry on whose state set I used to set a material that I made shiny via osg::Material::setShininess(). 我有一个osg :: Geometry,其状态集用于设置我通过osg :: Material :: setShininess()变得发亮的材料。 The problem is that now I have the need to set various colors across the geometry. 问题在于,现在我需要为整个几何图形设置各种颜色。 I tried doing this with the geometry's color array, but that approach didn't work unless I stopped setting a material on the geometry's state set. 我尝试使用几何的颜色数组来执行此操作,但是除非停止在几何的状态集上设置材质,否则该方法将不起作用。

I understand the logic here, that a material should override a color array, but I'm curious if there's some other way to make the geometry shiny now that I can't set a material on its state set? 我理解这里的逻辑,即一种材质应该覆盖颜色数组,但是我很好奇是否有其他方法可以使几何体变得闪亮,因为我无法在其状态集中设置材质?

I asked the same question on the OSG forum (which was not working in August, which was the only reason I asked this question on SO since this is not really a good place to ask OSG questions...) 我在OSG论坛上问了同样的问题(8月份不起作用,这是我在SO上问这个问题的唯一原因,因为这并不是问OSG问题的好地方...)

If you set the color mode on the material to AMBIENT_AND_DIFFUSE, you can still use a color array and set the shininess too. 如果您将材质的颜色模式设置为AMBIENT_AND_DIFFUSE,您仍然可以使用颜色阵列并设置光泽度。

pMaterial->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE)

The original answer on the OSG forum: OSG论坛上的原始答案:

original answer on the OSG forum OSG论坛上的原始答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM