本文整理汇总了C++中StdMat2::SetDiffuse方法的典型用法代码示例。如果您正苦于以下问题:C++ StdMat2::SetDiffuse方法的具体用法?C++ StdMat2::SetDiffuse怎么用?C++ StdMat2::SetDiffuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdMat2
的用法示例。
在下文中一共展示了StdMat2::SetDiffuse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMesh
void bhkProxyObject::CreateMesh()
{
if (Interface *gi = this->mIP)
{
if (const Mesh* pMesh = &this->proxyMesh)
{
if (TriObject *triObject = CreateNewTriObject())
{
MNMesh mnmesh(*pMesh);
Mesh& mesh = triObject->GetMesh();
mnmesh.OutToTri(mesh);
INode *node = gi->CreateObjectNode(triObject);
// Wireframe Red color
StdMat2 *collMat = NewDefaultStdMat();
collMat->SetDiffuse(Color(1.0f, 0.0f, 0.0f), 0);
collMat->SetWire(TRUE);
collMat->SetFaceted(TRUE);
gi->GetMaterialLibrary().Add(collMat);
node->SetMtl(collMat);
node->SetPrimaryVisibility(FALSE);
node->SetSecondaryVisibility(FALSE);
node->BoneAsLine(TRUE);
node->SetRenderable(FALSE);
node->SetWireColor( RGB(255,0,0) );
gi->SelectNode(node);
}
}
}
}
示例2: FindOrCreateMaterial
Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& slot, const IfcGeom::Material& material) {
Mtl* m = FindMaterialByName(library, material.name());
if (m == 0) {
StdMat2* stdm = NewDefaultStdMat();
const TimeValue t = -1;
if (material.hasDiffuse()) {
const double* diffuse = material.diffuse();
stdm->SetDiffuse(Color(diffuse[0], diffuse[1], diffuse[2]),t);
}
if (material.hasSpecular()) {
const double* specular = material.specular();
stdm->SetSpecular(Color(specular[0], specular[1], specular[2]),t);
}
if (material.hasSpecularity()) {
stdm->SetShininess(material.specularity(), t);
}
if (material.hasTransparency()) {
stdm->SetOpacity(1.0 - material.transparency(), t);
}
m = stdm;
m->SetName(S(material.name()));
library->Add(m);
if (slot < NUM_MATERIAL_SLOTS) {
max_interface->PutMtlToMtlEditor(m,slot++);
}
}
return m;
}
示例3: ImportBase
bool CollisionImport::ImportBase(bhkRigidBodyRef body, bhkShapeRef shape, INode* parent, INode *shapeNode, Matrix3& tm)
{
// Now do common post processing for the node
if (shapeNode != NULL)
{
shapeNode->SetName( TSTR(shape->GetType().GetTypeName().c_str()) );
if (!tm.IsIdentity())
{
Point3 pos = tm.GetTrans();
Quat rot(tm);
PosRotScaleNode(shapeNode, pos, rot, 1.0, prsDefault);
}
// Wireframe Red color
StdMat2 *collMat = NewDefaultStdMat();
collMat->SetDiffuse(Color(1.0f, 0.0f, 0.0f), 0);
collMat->SetWire(TRUE);
collMat->SetFaceted(TRUE);
ni.gi->GetMaterialLibrary().Add(collMat);
shapeNode->SetMtl(collMat);
shapeNode->SetPrimaryVisibility(FALSE);
shapeNode->SetSecondaryVisibility(FALSE);
shapeNode->BoneAsLine(TRUE);
shapeNode->SetRenderable(FALSE);
//shapeNode->XRayMtl(TRUE);
shapeNode->SetWireColor( RGB(255,0,0) );
if (parent)
parent->AttachChild(shapeNode);
return true;
}
return false;
}
示例4: CreateMesh
void bhkRigidBodyModifier::CreateMesh()
{
if (Interface *gi = this->mIP)
{
if (const Mesh* pMesh = this->GetMesh())
{
if (TriObject *triObject = CreateNewTriObject())
{
MNMesh mnmesh(*pMesh);
Mesh& mesh = triObject->GetMesh();
mnmesh.buildNormals();
mnmesh.OutToTri(mesh);
INode *node = gi->CreateObjectNode(triObject);
// Wireframe Red color
StdMat2 *collMat = NewDefaultStdMat();
collMat->SetDiffuse(Color(1.0f, 0.0f, 0.0f), 0);
collMat->SetWire(TRUE);
collMat->SetFaceted(TRUE);
gi->GetMaterialLibrary().Add(collMat);
node->SetMtl(collMat);
node->SetPrimaryVisibility(FALSE);
node->SetSecondaryVisibility(FALSE);
node->BoneAsLine(TRUE);
node->SetRenderable(FALSE);
node->SetWireColor( RGB(255,0,0) );
if (gi->GetSelNodeCount() == 1)
{
if (INode *snode = gi->GetSelNode(0))
{
Matrix3 tm = snode->GetObjTMAfterWSM(0, NULL);
node->SetNodeTM(0, tm);
}
}
gi->SelectNode(node);
}
}
}
}
示例5: NewDefaultStdMat
StdMat2* M2Importer::createMaterial()
{
static int i = 1;
TCHAR matName[128];
sprintf(matName, "%02d - Default", i++);
StdMat2* material = NewDefaultStdMat();
material->SetName(matName);
material->SetAmbient(Color(1.0f, 1.0f, 1.0f), 0);
material->SetDiffuse(Color(1.0f, 1.0f, 1.0f), 0);
material->SetSpecular(Color(1.0f, 1.0f, 1.0f), 0);
material->SetShininess(0.5f, 0);
material->SetShinStr(0.7f, 0);
material->SetMtlFlag(MTL_DISPLAY_ENABLE_FLAGS, TRUE);
return material;
}
示例6: NewDefaultStdMat
StdMat2 *NifImporter::ImportMaterialAndTextures(ImpNode *node, NiAVObjectRef avObject)
{
// Texture
NiMaterialPropertyRef matRef = avObject->GetPropertyByType(NiMaterialProperty::TYPE);
if (matRef != NULL){
StdMat2 *m = NewDefaultStdMat();
m->SetName(matRef->GetName().c_str());
if (showTextures) {
m->SetMtlFlag(MTL_DISPLAY_ENABLE_FLAGS, TRUE);
}
// try the civ4 shader first then default back to normal shaders
if (ImportNiftoolsShader(node, avObject, m)) {
return m;
}
NiTexturingPropertyRef texRef = avObject->GetPropertyByType(NiTexturingProperty::TYPE);
NiWireframePropertyRef wireRef = avObject->GetPropertyByType(NiWireframeProperty::TYPE);
NiAlphaPropertyRef alphaRef = avObject->GetPropertyByType(NiAlphaProperty::TYPE);
NiStencilPropertyRef stencilRef = avObject->GetPropertyByType(NiStencilProperty::TYPE);
NiShadePropertyRef shadeRef = avObject->GetPropertyByType(NiShadeProperty::TYPE);
vector<NiPropertyRef> props = avObject->GetProperties();
if (IsFallout3()) {
m->SetAmbient(Color(0.588f, 0.588f, 0.588f),0);
m->SetDiffuse(Color(0.588f, 0.588f, 0.588f),0);
m->SetSpecular(Color(0.902f, 0.902f, 0.902f),0);
} else {
m->SetAmbient(TOCOLOR(matRef->GetAmbientColor()),0);
m->SetDiffuse(TOCOLOR(matRef->GetDiffuseColor()),0);
m->SetSpecular(TOCOLOR(matRef->GetSpecularColor()),0);
}
Color c = TOCOLOR(matRef->GetEmissiveColor());
if (c.r != 0 || c.b != 0 || c.g != 0) {
m->SetSelfIllumColorOn(TRUE);
m->SetSelfIllumColor(c,0);
}
m->SetShinStr(0.0,0);
m->SetShininess(matRef->GetGlossiness()/100.0,0);
m->SetOpacity(matRef->GetTransparency(),0);
bool hasShaderAttributes = (wireRef != NULL) || (stencilRef != NULL) || (shadeRef != NULL);
if (m->SupportsShaders() && hasShaderAttributes) {
if (Shader *s = m->GetShader()) {
if (wireRef != NULL && (wireRef->GetFlags() & 1)) {
BOOL value = TRUE;
m->SetWire(value);
}
if (stencilRef != NULL) {
if (stencilRef->GetFaceDrawMode() == DRAW_BOTH) {
BOOL value = TRUE;
m->SetTwoSided(value);
}
}
if (shadeRef != NULL && shadeRef->GetFlags() & 1) {
m->SetFaceted(TRUE);
}
}
}
if (NULL != texRef)
{
// Handle Base/Detail ???
if (texRef->HasTexture(DECAL_0_MAP)){
if (Texmap* tex = CreateTexture(texRef->GetTexture(DECAL_0_MAP)))
m->SetSubTexmap(ID_DI, tex);
if (texRef->HasTexture(BASE_MAP)){
m->LockAmbDiffTex(FALSE);
if (Texmap* tex = CreateTexture(texRef->GetTexture(BASE_MAP)))
m->SetSubTexmap(ID_AM, tex);
}
} else if (texRef->HasTexture(BASE_MAP)) {
if (Texmap* tex = CreateTexture(texRef->GetTexture(BASE_MAP))) {
m->SetSubTexmap(ID_DI, tex);
if (showTextures) gi->ActivateTexture(tex,m);
}
}
// Handle Bump map
if (texRef->HasTexture(BUMP_MAP)) {
if (Texmap* tex = CreateTexture(texRef->GetTexture(BUMP_MAP)))
m->SetSubTexmap(ID_BU, CreateNormalBump(NULL, tex));
}
// Shiny map
if (texRef->HasTexture(GLOSS_MAP)) {
if (Texmap* tex = CreateTexture(texRef->GetTexture(GLOSS_MAP)))
m->SetSubTexmap(ID_SS, tex);
}
// Self illumination
if (texRef->HasTexture(GLOW_MAP)) {
if (Texmap* tex = CreateTexture(texRef->GetTexture(GLOW_MAP)))
m->SetSubTexmap(ID_SI, tex);
}
// Custom Shader Handling
int nTex = texRef->GetShaderTextureCount();
if (nTex > 0) {
list<NiExtraDataRef> data = avObject->GetExtraData();
NiGeometryRef trigeom = DynamicCast<NiGeometry>(avObject);
if (trigeom->HasShader()) {
//.........这里部分代码省略.........
示例7: createStandardMaterial
//------------------------------
StdMat2* MaterialCreator::createStandardMaterial( const COLLADAFW::EffectCommon& effectCommon, const String& name, const MaterialCreator::MaterialIdentifier& materialIdentifier )
{
StdMat2* material = NewDefaultStdMat();
COLLADAFW::EffectCommon::ShaderType shaderType = effectCommon.getShaderType();
switch ( shaderType )
{
case COLLADAFW::EffectCommon::SHADER_CONSTANT:
material->SetFaceted(true); // BUG393: Max actually does not support a constant shader!
case COLLADAFW::EffectCommon::SHADER_BLINN:
material->SwitchShader(Class_ID(StandardMaterial::STD2_BLINN_SHADER_CLASS_ID, 0));
break;
case COLLADAFW::EffectCommon::SHADER_LAMBERT:
case COLLADAFW::EffectCommon::SHADER_PHONG:
case COLLADAFW::EffectCommon::SHADER_UNKNOWN:
default:
material->SwitchShader(Class_ID(StandardMaterial::STD2_PHONG_CLASS_ID, 0));
break;
}
// Retrieve the shader parameter blocks
Shader* materialShader = material->GetShader();
IParamBlock2* shaderParameters = (IParamBlock2*) materialShader->GetReference(0);
IParamBlock2* extendedParameters = (IParamBlock2*) material->GetReference(StandardMaterial::EXTENDED_PB_REF);
// Common material parameters
material->SetName(name.c_str());
const COLLADAFW::ColorOrTexture& diffuse = effectCommon.getDiffuse();
if ( diffuse.isColor() )
material->SetDiffuse( toMaxColor(diffuse), 0);
const COLLADAFW::ColorOrTexture& emission = effectCommon.getEmission();
if ( emission.isColor() )
{
material->SetSelfIllumColorOn(TRUE);
material->SetSelfIllumColor( toMaxColor(emission), 0);
}
else
{
material->SetSelfIllumColorOn(FALSE);
material->SetSelfIllum( 0, 0 );
}
float maxOpacity = 1;
const COLLADAFW::ColorOrTexture& opacity = effectCommon.getOpacity();
if ( opacity.isColor() )
{
const COLLADAFW::Color& opacityColor = opacity.getColor();
float averageTransparent = (float)(opacityColor.getRed() + opacityColor.getGreen() + opacityColor.getBlue())/3;
maxOpacity = averageTransparent;
}
if ( getDocumentImporter()->getInvertTransparency() )
{
maxOpacity = 1 - maxOpacity;
}
// Max seems to like to have opacity 0 for opacity textures
if ( opacity.isTexture() )
{
material->SetOpacity( 0, 0);
}
else
{
material->SetOpacity( maxOpacity, 0);
}
if (shaderType != COLLADAFW::EffectCommon::SHADER_CONSTANT && shaderType != COLLADAFW::EffectCommon::SHADER_UNKNOWN)
{
// Unlock the ambient and diffuse colors
materialShader->SetLockAD(FALSE);
materialShader->SetLockADTex(FALSE);
material->LockAmbDiffTex(FALSE);
material->SyncADTexLock(FALSE);
// Lambert/Phong material parameters
const COLLADAFW::ColorOrTexture& ambient = effectCommon.getAmbient();
if ( ambient.isColor() )
material->SetAmbient( toMaxColor(ambient), 0);
}
else
{
// Approximate constant shader, specular is the same color
if ( diffuse.isColor() )
material->SetSpecular( toMaxColor(diffuse), 0 );
}
const COLLADAFW::ColorOrTexture& specular = effectCommon.getSpecular();
const COLLADAFW::FloatOrParam& shininessFloatOrParam = effectCommon.getShininess();
float shininess = 1;
if ( shininessFloatOrParam.getType() == COLLADAFW::FloatOrParam::FLOAT )
{
shininess = shininessFloatOrParam.getFloatValue();
}
if ( shaderType == COLLADAFW::EffectCommon::SHADER_PHONG || shaderType == COLLADAFW::EffectCommon::SHADER_BLINN)
{
//.........这里部分代码省略.........