本文整理汇总了C++中Texmap::ClassID方法的典型用法代码示例。如果您正苦于以下问题:C++ Texmap::ClassID方法的具体用法?C++ Texmap::ClassID怎么用?C++ Texmap::ClassID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texmap
的用法示例。
在下文中一共展示了Texmap::ClassID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reload_texture_cf
Value* reload_texture_cf (Value** arg_list, int count)
{
// Make sure we have the correct number of arguments (1)
check_arg_count(reload_texture, 1, count);
char *message = "NelReloadTexture [BitmapTex]";
//type_check (arg_list[0], TextureMap, message);
// Get a good interface pointer
Interface *ip = MAXScript_interface;
theCNelExport.init (false, false, ip, true);
// The 2 filenames
Texmap *texmap = arg_list[0]->to_texmap ();
// BitmapTex ?
if (texmap->ClassID() == Class_ID (BMTEX_CLASS_ID, 0))
{
// Cast
BitmapTex *bitmap = (BitmapTex*)texmap;
// Reload
bitmap->ReloadBitmapAndUpdate ();
// Tell the bitmap has changed
BroadcastNotification (NOTIFY_BITMAP_CHANGED, (void *)bitmap->GetMapName());
return &true_value;
}
return &false_value;
}
示例2: getStdMatBitmapTex
BitmapTex* SceneExportUtil::getStdMatBitmapTex( StdMat* stdmat, int id )
{
StdMat2* stdmat2 = 0;
int channel = id;
if ( stdmat->SupportsShaders() )
{
stdmat2 = static_cast<StdMat2*>( stdmat );
channel = stdmat2->StdIDToChannel( id );
}
if ( stdmat->MapEnabled(channel) )
{
Texmap* tex = stdmat->GetSubTexmap(channel);
if ( tex && tex->ClassID() == Class_ID(BMTEX_CLASS_ID,0) &&
(!stdmat2 || 2 == stdmat2->GetMapState(channel)) )
{
BitmapTex* bmptex = static_cast<BitmapTex*>(tex);
if ( bmptex->GetMapName() )
{
return bmptex;
}
}
}
return 0;
}
示例3: ISetProbTexmap
void plDistribComponent_old::ISetProbTexmap(plDistributor& distrib)
{
distrib.SetProbabilityBitmapTex(nil);
Texmap* tex = fCompPB->GetTexmap(kProbTexmap);
if( tex )
{
BitmapTex* bmt = GetIBitmapTextInterface(tex);
if( bmt )
distrib.SetProbabilityBitmapTex(bmt);
else if( tex->ClassID() == LAYER_TEX_CLASS_ID )
distrib.SetProbabilityLayerTex((plLayerTex*)tex);
}
}
示例4: GetStdMtlChannelBitmapFileName
bool SGP_MaxInterface::GetStdMtlChannelBitmapFileName( StdMat* pStdMat, int nChannel, TCHAR szFileName[] )
{
if( !pStdMat )
{
assert( false );
return false;
}
Texmap *tx = pStdMat->GetSubTexmap(nChannel);
if( !tx )
return false;
if(tx->ClassID() != Class_ID(BMTEX_CLASS_ID,0))
return false;
BitmapTex *bmt = (BitmapTex*)tx;
_tcscpy( szFileName, bmt->GetMapName() );
return true;
}
示例5: UnifySlashes
/*
====================
GatherMesh
====================
*/
void G3DMExport::GatherMesh(INode* i_node)
{
// convert to the triangle type
Mesh* i_mesh = NULL;
Object* obj = i_node->EvalWorldState(mTime).obj;
if(obj && ( obj->SuperClassID() == GEOMOBJECT_CLASS_ID ))
{
if(obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
{
TriObject *tri_obj = (TriObject*)obj->ConvertToType(mTime, Class_ID(TRIOBJ_CLASS_ID, 0)); MAX_CHECK(tri_obj);
i_mesh = &tri_obj->mesh;
}
}
if(i_mesh==NULL||i_mesh->getNumFaces()==0||i_mesh->getNumVerts()==0) return;
MESH mesh;
// get the mesh name
mesh.name = i_node->GetName();
// get the material
mesh.texture = "textures/default.tga";
Mtl* mtl = i_node->GetMtl();
if(mtl && (mtl->ClassID()==Class_ID(DMTL_CLASS_ID, 0)) && ((StdMat*)mtl)->MapEnabled(ID_DI))
{
Texmap *texmap = mtl->GetSubTexmap(ID_DI);
if(texmap && texmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0x00))
{
mesh.texture = UnifySlashes(((BitmapTex *)texmap)->GetMapName());
if( !strstr( mesh.texture.c_str(), mPath.c_str() ) )
{
G3DAssert("The material(%s) is error : the texture path(%s) is illegal!",mtl->GetName(), mesh.texture.c_str());
return;
}
else
{
mesh.texture = strstr(mesh.texture.c_str(),mPath.c_str()) + strlen(mPath.c_str());
}
}
}
// if it has uvs
int map_count = i_mesh->getNumMaps();
bool has_uvs = i_mesh->getNumTVerts() && i_mesh->tvFace;
if(!(has_uvs&&map_count)) return;
// get the transform
Matrix3 transform = i_node->GetObjectTM(mTime);
// get the points
mesh.points.assign(i_mesh->verts, i_mesh->verts+i_mesh->getNumVerts());
// get the triangles
for(int i = 0; i < i_mesh->getNumFaces(); i++)
{
Face& face = i_mesh->faces[i];
TRIANGLE tri;
tri.smoothing = face.smGroup;
for(int j = 0; j < 3; j++)
{
VTNIS v;
v.pos = transform * i_mesh->verts[face.v[j]];
// get the uv
UVVert * map_verts = i_mesh->mapVerts(1);
TVFace * map_faces = i_mesh->mapFaces(1);
v.uv = reinterpret_cast<Point2&>(map_verts[map_faces[i].t[j]]);
v.uv.y = 1 - v.uv.y;
// initialize the normal
v.normal = Point3::Origin;
// get the vertex index
v.index = face.v[j];
// get the smoothing group
v.smoothing = face.smGroup;
// set the index for the triangle
tri.index0[j] = v.index;
// reassemble the vertex list
tri.index1[j] = AddVertex(mesh, v);
}
// add the triangle to the table
mesh.triangles.push_back(tri);
}
// build the index map
for( int i = 0; i < mesh.vertexes.size(); i++ )
{
mesh.vertex_index_map[mesh.vertexes[i].index].push_back(i);
}
//.........这里部分代码省略.........
示例6: ConvertMTL
bool sMaterial::ConvertMTL(Mtl *mtl)
{
char filename[64];
char file_ext[16];
char filename_with_ext[128];
m_EmissiveColor = mtl->GetSelfIllumColor();
m_AmbientColor = mtl->GetAmbient();
m_DiffuseColor = mtl->GetDiffuse();
m_SpecularColor = mtl->GetSpecular();
m_fShininess = mtl->GetShininess();
m_iNumTextures = 0;
m_BlendMode = "replace";
if ( mtl->ClassID()==Class_ID(DMTL_CLASS_ID, 0) )
{
StdMat* std = (StdMat*)mtl;
float fOpacity = std->GetOpacity(0);
if ( fOpacity < 1.0f )
{
switch (std->GetTransparencyType())
{
case TRANSP_FILTER:
m_BlendMode = "blend";
break;
case TRANSP_SUBTRACTIVE:
m_BlendMode = "subtract";
break;
case TRANSP_ADDITIVE:
m_BlendMode = "add";
break;
default:
m_BlendMode = "replace";
break;
}
}
m_bCullFace = !std->GetTwoSided();
}
for (int i=0; i<mtl->NumSubTexmaps(); i++)
{
Texmap *tex = mtl->GetSubTexmap(i);
if ( tex && tex->ClassID() == Class_ID(BMTEX_CLASS_ID, 0x00) )
{
bool valid_channel = false;
int texture_type = -1;
switch(i)
{
case 0: // ambientmap/lightmap
texture_type = TEXTURE_LIGHTMAP;
break;
case 1: // diffusemap
texture_type = TEXTURE_DIFFUSE;
break;
case 9: // environment
texture_type = TEXTURE_ENVIRONMENT;
break;
default:
// not supported by fixed pipeline 3D rendering
break;
}
if ( texture_type >= 0 )
{
TSTR mapName = ((BitmapTex *)tex)->GetMapName();
_splitpath(mapName, NULL, NULL, filename, file_ext);
sprintf(filename_with_ext, "%s%s", filename, file_ext);
m_Textures[texture_type] = filename_with_ext;
m_MapChannel[texture_type] = tex->GetMapChannel()-1;
}
}
}
return true;
}
示例7: if
AWDBlock * MaxAWDExporter::ExportCameraAndTextureExporter(INode * node, double * mtxData, AWDSceneBlock * parent, BlockSettings * blockSettings)
{
awd_float64 * transform_mtx_camera = (double *)malloc(12*sizeof(awd_float64));
awd_float64 store1 = mtxData[3];
awd_float64 store2 = mtxData[4];
awd_float64 store3 = mtxData[5];
transform_mtx_camera[0] = mtxData[0];
transform_mtx_camera[1] = mtxData[1];
transform_mtx_camera[2] = mtxData[2];
transform_mtx_camera[3] = mtxData[6];
transform_mtx_camera[4] = mtxData[7];
transform_mtx_camera[5] = mtxData[8];
transform_mtx_camera[6] = store1*-1;
transform_mtx_camera[7] = store2*-1;
transform_mtx_camera[8] = store3*-1;
transform_mtx_camera[9] = mtxData[9];
transform_mtx_camera[10] = mtxData[10];
transform_mtx_camera[11] = mtxData[11];
Object *obj;
obj = node->GetObjectRef();
SClass_ID sid=obj->SuperClassID();
getBaseObjectAndID( obj, sid );
CameraObject *camObject= (CameraObject *) obj;
double fov=camObject->GetFOV(0);
bool isOrtho=camObject->IsOrtho();
double clipNear=camObject->GetClipDist(0,CAM_HITHER_CLIP);
double clipFar=camObject->GetClipDist(0,CAM_YON_CLIP);
char * camName_ptr=W2A(node->GetName());
AWD_lens_type camType=AWD_LENS_PERSPECTIVE;
if (isOrtho)
camType=AWD_LENS_ORTHO;
AWDCamera * awdCamera = new AWDCamera(camName_ptr, strlen(camName_ptr), camType, transform_mtx_camera);
AWDTextureProjector * textureProjector= new AWDTextureProjector(camName_ptr, strlen(camName_ptr), mtxData);
AWDBitmapTexture * projectionTexture = NULL;
free(camName_ptr);
if(!isOrtho){
//double aspectRatio=maxInterface->GetRendApect();
double aspectRatio=1/double(maxInterface->GetRendImageAspect());
double horizontalFOV=double(fov* (double(double(180)/(double(3.14159265358979323846)))));
double verticalFOV=horizontalFOV * double(aspectRatio);
awdCamera->set_lens_fov(verticalFOV);
}
awdCamera->set_lens_near(clipNear * blockSettings->get_scale());
awdCamera->set_lens_far(clipFar * blockSettings->get_scale());
bool exportCamera=true;
bool exportTextureProjector=false;
BaseObject* node_bo = (BaseObject*)node->GetObjectRef();
IDerivedObject* node_der = NULL;
char * settingsNodeID_ptr=NULL;
if((node_bo->SuperClassID() == GEN_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == WSM_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == DERIVOB_CLASS_ID ))
{
node_der = ( IDerivedObject* ) node->GetObjectRef();
if (node_der!=NULL){
int nMods = node_der->NumModifiers();
for (int m = 0; m<nMods; m++){
Modifier* node_mod = node_der->GetModifier(m);
if (node_mod->IsEnabled()){
MSTR className;
node_mod->GetClassName(className);
char * className_ptr=W2A(className);
if (ATTREQ(className_ptr,"AWDCamera")){
IParamBlock2* pb = GetParamBlock2ByName((ReferenceMaker*)node_mod, "main");
if(pb!=NULL){
int numBlockparams=pb->NumParams();
int p=0;
for (p=0; p<numBlockparams; p++) {
ParamID pid = pb->IndextoID(p);
ParamDef def = pb->GetParamDef(pid);
ParamType2 paramtype = pb->GetParameterType(pid);
char * paramName=W2A(def.int_name);
if (paramtype==TYPE_STRING) {
if (ATTREQ(paramName, "thisAWDID"))
settingsNodeID_ptr = W2A(pb->GetStr(pid));
}
if (paramtype==TYPE_BOOL){
if (ATTREQ(paramName, "exportCamera"))
exportCamera = (0 != pb->GetInt(pid));
if (ATTREQ(paramName, "exportTextureProjector"))
exportTextureProjector = (0 != pb->GetInt(pid));
}
free(paramName);
}
}
if(exportCamera){
AWD_lens_type lens_type = AWD_LENS_PERSPECTIVE;
int lensType=1;
int projectionHeight=1;
int offcenterX_pos=1;
int offcenterX_neg=1;
int offcenterY_pos=1;
int offcenterY_neg=1;
IParamBlock2* pb = GetParamBlock2ByName((ReferenceMaker*)node_mod, "camera_params");
if(pb!=NULL){
int numBlockparams=pb->NumParams();
int p=0;
for (p=0; p<numBlockparams; p++) {
ParamID pid = pb->IndextoID(p);
//.........这里部分代码省略.........
示例8: ExportQuake3Model
//.........这里部分代码省略.........
{
mtl = node->GetMtl();
if (mtl)
{
// check for multi-material
if (mtl->IsMultiMtl())
{
// check if it's truly multi material
// we do support multi-material with only one texture (some importers set it)
bool multi_material = false;
MtlID matId = mesh.faces[0].getMatID();
for (i = 1; i < mesh.getNumFaces(); i++)
if (mesh.faces[i].getMatID() != matId)
multi_material = true;
if (multi_material)
if (g_mesh_multimaterials == MULTIMATERIALS_NONE)
ExportWarning("Object '%s' is multimaterial and using multiple materials on its faces, that case is not yet supported (truncating to first submaterial).", node->GetName());
// switch to submaterial
mtl = mtl->GetSubMtl(matId);
}
// get shader from material if supplied
char *materialname = GetChar(mtl->GetName());
if (g_mesh_materialasshader && (strstr(materialname, "/") != NULL || strstr(materialname, "\\") != NULL))
shadername = GetChar(mtl->GetName());
else
{
// get texture
tex = mtl->GetSubTexmap(ID_DI);
if (tex)
{
if (tex->ClassID() == Class_ID(BMTEX_CLASS_ID, 0x00))
{
shadername = GetChar(((BitmapTex *)tex)->GetMapName());
if (shadername == NULL || !shadername[0])
ExportWarning("Object '%s' material '%s' has no bitmap.", tex->GetName(), node->GetName());
}
else
{
tex = NULL;
ExportWarning("Object '%s' has material with wrong texture type (only Bitmap are supported).", node->GetName());
}
}
else
ExportWarning("Object '%s' has material but no texture.", node->GetName());
}
}
else
ExportWarning("Object '%s' has no material.", node->GetName());
}
long pos_meshstart = ftell(file);
// surface object
ExportState("Writing mesh '%s' header", meshname);
putChars("IDP3", 4, file);
putChars(meshname, 64, file);
put32(0, file); // flags
put32(g_total_frames, file); // framecount
put32(1, file); // skincount
long pos_vertexnum = ftell(file); put32(0, file); // vertexcount
put32(mesh.getNumFaces(), file); // trianglecount
long pos_trianglestart = ftell(file); put32(0, file); // start triangles
put32(108, file); // header size
示例9: GetCOREInterface
void DxStdMtl2::LoadTextureData(IHLSLCodeGenerator * codeGen)
{
Bitmap * bmap;
BitmapInfo stBI;
TimeValue t = GetCOREInterface()->GetTime();
int nWidth,nHeight;
int numberOfTextures = elementContainer.NumberofElementsByType(EffectElements::kEleTex);
for(int i=0; i<numberOfTextures;i++)
{
bool bBump;
TextureElement * texEle = static_cast<TextureElement*>(elementContainer.GetElementByType(i,EffectElements::kEleTex));
TSTR mapType = texEle->GetMapName();
Texmap *texmap = codeGen->GetShaderDefinedTexmap(map,mapType.data(),bBump);
if(texmap)
{
BMM_Color_64 *p;
nWidth = nHeight = DIMDEFAULT;
BitmapDimensions(nWidth,nHeight,texmap);
// load and create the D3D texture;
/* if(texmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0))
{
BitmapTex *pBT;
Bitmap *pTex;
pBT = (BitmapTex *)texmap;
pTex = pBT->GetBitmap(t);
if (pTex)
{
nWidth = getClosestPowerOf2(pTex->Width());
nHeight = getClosestPowerOf2(pTex->Height());
}
}
*/
stBI.SetType(BMM_TRUE_32);
stBI.SetWidth(nWidth);
stBI.SetHeight(nHeight);
bmap = TheManager->Create(&stBI);
if (bmap)
{
// LPDIRECT3DTEXTURE9 pRenderTex = texEle->GetD3DTexture();
texmap->RenderBitmap(t, bmap, MAPSCALE3D * 2.0f);
p = new BMM_Color_64[nWidth*nHeight];
for (int y = 0; y < nHeight; y++)
bmap->GetLinearPixels(0, y, nWidth, p + y * nWidth);
if(texEle->pTex)
{
D3DSURFACE_DESC stLD;
texEle->pTex->GetLevelDesc(0, &stLD);
if (stLD.Width != nWidth || stLD.Height != nHeight)
{
SAFE_RELEASE(texEle->pTex);
}
}
if(!texEle->pTex)
pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pTex, NULL);
if(texEle->pTex)
{
PIXELFMT *pT;
D3DLOCKED_RECT stLR;
texEle->pTex->LockRect(0, &stLR, 0, 0);
pT = (PIXELFMT *)stLR.pBits;
for (int i = 0; i < nWidth * nHeight; i++)
{
pT[i].r = p[i].r >> 8;
pT[i].g = p[i].g >> 8;
pT[i].b = p[i].b >> 8;
pT[i].a = p[i].a >> 8;
}
texEle->pTex->UnlockRect(0);
if(bBump && texmap->ClassID() != GNORMAL_CLASS_ID)
{
// LPDIRECT3DTEXTURE9 normalTex = texEle->GetD3DBumpTexture();
if(texEle->pBumpTex)
{
D3DSURFACE_DESC stLD;
texEle->pBumpTex->GetLevelDesc(0, &stLD);
if (stLD.Width != nWidth || stLD.Height != nHeight)
{
SAFE_RELEASE(texEle->pBumpTex);
}
}
if(!texEle->pBumpTex)
pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pBumpTex, NULL);
D3DXComputeNormalMap(texEle->pBumpTex,texEle->pTex,NULL, NULL, D3DX_CHANNEL_RED,30.0f);
if(texEle->GetParamHandle())
//.........这里部分代码省略.........
示例10: callback
//=================================================================
// Methods for DumpModelTEP
//
int DumpModelTEP::callback(INode *pnode)
{
Object* pobj;
int fHasMat = TRUE;
// clear physique export parameters
m_mcExport = NULL;
m_phyExport = NULL;
m_phyMod = NULL;
ASSERT_MBOX(!(pnode)->IsRootNode(), "Encountered a root node!");
if (::FNodeMarkedToSkip(pnode))
return TREE_CONTINUE;
int iNode = ::GetIndexOfINode(pnode);
TSTR strNodeName(pnode->GetName());
// The Footsteps node apparently MUST have a dummy mesh attached! Ignore it explicitly.
if (FStrEq((char*)strNodeName, "Bip01 Footsteps"))
return TREE_CONTINUE;
// Helper nodes don't have meshes
pobj = pnode->GetObjectRef();
if (pobj->SuperClassID() == HELPER_CLASS_ID)
return TREE_CONTINUE;
// The model's root is a child of the real "scene root"
INode *pnodeParent = pnode->GetParentNode();
BOOL fNodeIsRoot = pnodeParent->IsRootNode( );
// Get node's material: should be a multi/sub (if it has a material at all)
Mtl *pmtlNode = pnode->GetMtl();
if (pmtlNode == NULL)
{
return TREE_CONTINUE;
fHasMat = FALSE;
}
else if (!(pmtlNode->ClassID() == Class_ID(MULTI_CLASS_ID, 0) && pmtlNode->IsMultiMtl()))
{
// sprintf(st_szDBG, "ERROR--Material on node %s isn't a Multi/Sub-Object", (char*)strNodeName);
// ASSERT_AND_ABORT(FALSE, st_szDBG);
fHasMat = FALSE;
}
// Get Node's object, convert to a triangle-mesh object, so I can access the Faces
ObjectState os = pnode->EvalWorldState(m_tvToDump);
pobj = os.obj;
TriObject *ptriobj;
BOOL fConvertedToTriObject =
pobj->CanConvertToType(triObjectClassID) &&
(ptriobj = (TriObject*)pobj->ConvertToType(m_tvToDump, triObjectClassID)) != NULL;
if (!fConvertedToTriObject)
return TREE_CONTINUE;
Mesh *pmesh = &ptriobj->mesh;
// Shouldn't have gotten this far if it's a helper object
if (pobj->SuperClassID() == HELPER_CLASS_ID)
{
sprintf(st_szDBG, "ERROR--Helper node %s has an attached mesh, and it shouldn't.", (char*)strNodeName);
ASSERT_AND_ABORT(FALSE, st_szDBG);
}
// Ensure that the vertex normals are up-to-date
pmesh->buildNormals();
// We want the vertex coordinates in World-space, not object-space
Matrix3 mat3ObjectTM = pnode->GetObjectTM(m_tvToDump);
// initialize physique export parameters
m_phyMod = FindPhysiqueModifier(pnode);
if (m_phyMod)
{
// Physique Modifier exists for given Node
m_phyExport = (IPhysiqueExport *)m_phyMod->GetInterface(I_PHYINTERFACE);
if (m_phyExport)
{
// create a ModContext Export Interface for the specific node of the Physique Modifier
m_mcExport = (IPhyContextExport *)m_phyExport->GetContextInterface(pnode);
if (m_mcExport)
{
// convert all vertices to Rigid
m_mcExport->ConvertToRigid(TRUE);
}
}
}
// Dump the triangle face info
int cFaces = pmesh->getNumFaces();
for (int iFace = 0; iFace < cFaces; iFace++)
{
Face* pface = &pmesh->faces[iFace];
TVFace* ptvface = &pmesh->tvFace[iFace];
DWORD smGroupFace = pface->getSmGroup();
//.........这里部分代码省略.........
示例11: BuildShaders
// --[ Method ]---------------------------------------------------------------
//
// - Class : CStravaganzaMaxTools
//
// - prototype : bool BuildShaders()
//
// - Purpose : Builds the shader list from MAX's materials.
// Preview mode requires texture files to be stored with full
// path in order to load them. When we export, we only store the
// filename. Another thing is that in the export mode, we copy
// all textures into the path specified by the user if that
// option is checked.
//
// -----------------------------------------------------------------------------
bool CStravaganzaMaxTools::BuildShaders()
{
std::vector<Mtl*>::iterator it;
assert(m_vecShaders.empty());
if(!m_bPreview && m_bCopyTextures && m_strTexturePath == "")
{
CLogger::NotifyWindow("Textures won't be copied\nSpecify a valid output texture path first");
}
LOG.Write("\n\n-Building shaders: ");
for(it = m_vecMaterials.begin(); it != m_vecMaterials.end(); ++it)
{
Mtl* pMaxMaterial = *it;
assert(pMaxMaterial);
LOG.Write("\n %s", pMaxMaterial->GetName().data());
CShaderStandard* pShaderStd = new CShaderStandard;
pShaderStd->SetName(pMaxMaterial->GetName().data());
// Properties
StdMat2 *pMaxStandardMtl = NULL;
StdMat2 *pMaxBakedMtl = NULL;
float fAlpha;
if(pMaxMaterial->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
{
pMaxStandardMtl = (StdMat2 *)pMaxMaterial;
}
else if(pMaxMaterial->ClassID() == Class_ID(BAKE_SHELL_CLASS_ID, 0))
{
pMaxStandardMtl = (StdMat2 *)pMaxMaterial->GetSubMtl(0);
pMaxBakedMtl = (StdMat2 *)pMaxMaterial->GetSubMtl(1);
}
if(pMaxStandardMtl)
{
// Standard material
fAlpha = pMaxStandardMtl->GetOpacity(0);
Shader* pMaxShader = pMaxStandardMtl->GetShader();
CVector4 v4Specular = ColorToVector4(pMaxStandardMtl->GetSpecular(0), 0.0f) * pMaxShader->GetSpecularLevel(0, 0);
pShaderStd->SetAmbient (ColorToVector4(pMaxStandardMtl->GetAmbient(0), 0.0f));
pShaderStd->SetDiffuse (ColorToVector4(pMaxStandardMtl->GetDiffuse(0), fAlpha));
pShaderStd->SetSpecular (v4Specular);
pShaderStd->SetShininess(pMaxShader->GetGlossiness(0, 0) * 128.0f);
if(pMaxStandardMtl->GetTwoSided() == TRUE)
{
pShaderStd->SetTwoSided(true);
}
// Need to cast to StdMat2 in order to get access to IsFaceted().
// ¿Is StdMat2 always the interface for standard materials?
if(((StdMat2*)pMaxStandardMtl)->IsFaceted())
{
pShaderStd->SetFaceted(true);
}
if(pMaxStandardMtl->GetWire() == TRUE)
{
pShaderStd->SetPostWire(true);
pShaderStd->SetWireLineThickness(pMaxStandardMtl->GetWireSize(0));
}
}
else
{
// Material != Standard
fAlpha = 1.0f; // pMaxMaterial->GetXParency();
pShaderStd->SetAmbient (ColorToVector4(pMaxMaterial->GetAmbient(), 0.0f));
pShaderStd->SetDiffuse (ColorToVector4(pMaxMaterial->GetDiffuse(), fAlpha));
pShaderStd->SetSpecular (CVector4(0.0f, 0.0f, 0.0f, 0.0f));
pShaderStd->SetShininess(0.0f);
}
// Layers
//.........这里部分代码省略.........
示例12: GetModifier
/*
====================
GatherSkin
====================
*/
void G3DSExport::GatherSkin(INode* i_node)
{
SKIN skin;
// get the name of the node
skin.name = i_node->GetName();
// get the skin interface
Modifier *modifier = GetModifier(i_node,SKIN_CLASSID);
ISkin* i_skin = (ISkin*)modifier->GetInterface(I_SKIN);
MAX_CHECK(i_skin);
// convert to the triangle type
Mesh* i_mesh = NULL;
Object* obj = i_node->EvalWorldState(mTime).obj;
if(obj && ( obj->SuperClassID() == GEOMOBJECT_CLASS_ID ))
{
if(obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
{
TriObject *tri_obj = (TriObject*)obj->ConvertToType(mTime, Class_ID(TRIOBJ_CLASS_ID, 0)); MAX_CHECK(tri_obj);
i_mesh = &tri_obj->mesh;
}
}
MAX_CHECK(i_mesh&&i_mesh->getNumFaces()&&i_mesh->getNumVerts());
// get the material
skin.texture = "textures/default.tga";
Mtl* mtl = i_node->GetMtl();
if(mtl && (mtl->ClassID()==Class_ID(DMTL_CLASS_ID, 0)) && ((StdMat*)mtl)->MapEnabled(ID_DI))
{
Texmap *texmap = mtl->GetSubTexmap(ID_DI);
if(texmap && texmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0x00))
{
skin.texture = UnifySlashes(((BitmapTex *)texmap)->GetMapName());
if( !strstr( skin.texture.c_str(), mPath.c_str() ) )
{
G3DAssert("The material(%s) is error : the texture path(%s) is illegal!",mtl->GetName(), skin.texture.c_str());
}
else
{
skin.texture = strstr(skin.texture.c_str(),mPath.c_str()) + strlen(mPath.c_str());
}
}
}
// if it has uvs
int map_count = i_mesh->getNumMaps();
bool has_uvs = i_mesh->getNumTVerts() && i_mesh->tvFace;
if(!(has_uvs&&map_count)) { G3DAssert("The skin(%s) has not the uv coordinates.",skin.name.c_str()); return; }
// get the transform
Matrix3 mesh_matrix = i_node->GetObjectTM(mTime);
Matrix3 node_matrix = i_node->GetNodeTM(mTime);
Matrix3 transform = mesh_matrix * Inverse(node_matrix);
// get the points
skin.points.assign(i_mesh->verts, i_mesh->verts+i_mesh->getNumVerts());
// get the triangles
for(int i = 0; i < i_mesh->getNumFaces(); i++)
{
Face& face = i_mesh->faces[i];
TRIANGLE tri;
tri.smoothing = face.smGroup;
for(int j = 0; j < 3; j++)
{
VPTNIS v;
v.pos = transform * i_mesh->verts[face.v[j]];
// get the uv
UVVert * map_verts = i_mesh->mapVerts(1);
TVFace * map_faces = i_mesh->mapFaces(1);
v.uv = reinterpret_cast<Point2&>(map_verts[map_faces[i].t[j]]);
v.uv.y = 1 - v.uv.y;
// initialize the normal
v.normal = Point3::Origin;
// get the vertex index
v.index = face.v[j];
// get the smoothing group
v.smoothing = face.smGroup;
// set the index for the triangle
tri.index0[j] = v.index;
// reassemble the vertex list
tri.index1[j] = AddVertex(skin, v);
}
// add the triangle to the table
skin.triangles.push_back(tri);
}
//.........这里部分代码省略.........
示例13: GetMtlAnim
bool SGP_MaxInterface::GetMtlAnim( StdMat* pStdMtl, ColorTrack& track, int nChannel )
{
if( pStdMtl == NULL )
{
assert( false && "std mtl is NULL" );
return false;
}
int nFrameCount = 0;
TimeValue nStartTick = GetStartTick();
TimeValue nEndTick = GetEndTick();
int nTickPerFrame = GetTickPerFrame();
track.bTiling = false;
StdUVGen *uv = NULL;
Texmap *tx = pStdMtl->GetSubTexmap(nChannel);
if( tx )
{
if( tx->ClassID() == Class_ID( BMTEX_CLASS_ID, 0 ) )
{
BitmapTex *bmt = (BitmapTex*)tx;
uv = bmt->GetUVGen();
if( uv )
{
track.nUTile = (int)uv->GetUScl(0);
track.nVTile = (int)uv->GetVScl(0);
if( track.nUTile == 1 && track.nVTile == 1 )
track.bTiling = false;
else
track.bTiling = true;
track.nStartFrame = bmt->GetStartTime();
track.fPlaybackRate = bmt->GetPlaybackRate();
track.nLoopMode = bmt->GetEndCondition();
if( uv->GetUAng( 0 ) != 0.0f ||
uv->GetVAng( 0 ) != 0.0f )
{
track.fUSpeed = uv->GetUAng( 0 ) / piOver180;
track.fVSpeed = uv->GetVAng( 0 ) / piOver180;
track.bUVMoving = true;
}
else
track.bUVMoving = false;
}
}
}
TimeValue t;
for( t = nStartTick; t <= nEndTick; t += nTickPerFrame )
nFrameCount++;
track.ColorKeyFrame.resize( nFrameCount );
t = nStartTick;
for( int i = 0; i < nFrameCount; i++, t += nTickPerFrame )
{
SGP_ColorKey key;
memset( &key, 0x00, sizeof( key ) );
Color diffuse = pStdMtl->GetDiffuse( t );
Color ambient = pStdMtl->GetAmbient( t );
Color specular = pStdMtl->GetSpecular( t );
Color filter = pStdMtl->GetFilter( t );
float alpha = pStdMtl->GetOpacity( t );
float shinstr = pStdMtl->GetShinStr(t);
float selfillum = pStdMtl->GetSelfIllum( t );
float uoffset = 0;
float voffset = 0;
if( uv )
{
uoffset = uv->GetUOffs( t );
voffset = uv->GetVOffs( t );
}
/*
int nTransparencyType = pStdMtl->GetTransparencyType();
key.dwBlendMode = 0;
switch( nTransparencyType )
{
case TRANSP_SUBTRACTIVE:
key.dwBlendMode |= HR3D_MDX2_MODULATE;
break;
case TRANSP_ADDITIVE:
key.dwBlendMode |= HR3D_MDX2_ADD;
break;
case TRANSP_FILTER:
key.dwBlendMode |= HR3D_MDX2_MODULATE2X;
break;
default:
break;
};
*/
key.dr = diffuse.r;
//.........这里部分代码省略.........