本文整理汇总了C++中IAnimatedMeshSceneNode::getMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ IAnimatedMeshSceneNode::getMaterial方法的具体用法?C++ IAnimatedMeshSceneNode::getMaterial怎么用?C++ IAnimatedMeshSceneNode::getMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAnimatedMeshSceneNode
的用法示例。
在下文中一共展示了IAnimatedMeshSceneNode::getMaterial方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateScene
void CScene::UpdateScene(vector<vector3df> otherClientPosition, ICameraSceneNode* camera)
{
ISceneManager* smgr=device->getSceneManager();
IVideoDriver* driver=device->getVideoDriver();
// 测试用
IAnimatedMesh* personMeshTest=smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* personNode = smgr->addAnimatedMeshSceneNode( personMeshTest );
if (!personMeshTest)
{
device->drop();
return ;
}
if (personNode)
{
personNode->setScale(vector3df(0.4f,0.4f,0.4f));
personNode->setPosition(vector3df(0.0f,10.0f,0.0f));
personNode->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
personNode->setMaterialFlag(EMF_LIGHTING, false);
personNode->getMaterial(0).Shininess=28.0f;
personNode->getMaterial(0).NormalizeNormals=true;
personNode->setMD2Animation ( scene::EMAT_STAND );
}
personMeshTest->setMaterialFlag(EMF_LIGHTING,false);
// 显示其他客户端
for (int i=0;i!=otherClientPosition.size();i++)
{
IAnimatedMesh* personMesh=smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* personNode = smgr->addAnimatedMeshSceneNode( personMesh );
if (!personMesh)
{
device->drop();
return ;
}
if (personNode && personNode->getPosition()!=camera->getPosition())
{
// personNode->setPosition(vector3df(10,20,0));
// personNode->setScale(vector3df(0.5,0.5,0.5));
personNode->setPosition(otherClientPosition[i]);
personNode->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
personNode->setMaterialFlag(EMF_LIGHTING, false);
personNode->getMaterial(0).Shininess=28.0f;
personNode->getMaterial(0).NormalizeNormals=true;
personNode->setMD2Animation ( scene::EMAT_STAND );
}
personMesh->setMaterialFlag(EMF_LIGHTING,false);
}
}
示例2: loadSceneObject
SceneObject* PhysicsSim::loadSceneObject(stringw mesh_file, stringw texture_file)
{
IAnimatedMesh *mesh = smgr->getMesh(mediaDirectory + mesh_file);
IAnimatedMeshSceneNode* Node = smgr->addAnimatedMeshSceneNode(mesh, smgr->getRootSceneNode());
stringw tex_file = texture_file;
if(tex_file == L"")
{
tex_file = mesh_file;
if(tex_file.find(".dae") > -1)
tex_file.remove(".dae");
if(tex_file.find(".3ds") > -1)
tex_file.remove(".3ds");
tex_file.append(".jpg");
}
tex_file = mediaDirectory + tex_file;
if(smgr->getFileSystem()->existFile(tex_file))
Node->setMaterialTexture(0, driver->getTexture(tex_file));
Node->setMaterialFlag(EMF_LIGHTING, true);
Node->setMaterialFlag(EMF_TEXTURE_WRAP, false);
Node->setMaterialFlag(EMF_BACK_FACE_CULLING, true);
Node->addShadowVolumeSceneNode(0,-1,false);
Node->getMaterial(0).AmbientColor.set(255,255,255,255);
updateObjects();
return Node;
}
示例3: loadPlayerNode
//loads the player and sets initial position
IAnimatedMeshSceneNode* Player::loadPlayerNode(IrrlichtDevice* device, ISceneManager* smgr)
{
IAnimatedMesh* player = smgr->getMesh("Assets/player.x");
if (!player) { device->drop(); return NULL; }
IAnimatedMeshSceneNode *plyrNode = smgr->addAnimatedMeshSceneNode(player);
for (int i = 0; i < plyrNode->getMaterialCount(); i++)
{
plyrNode->getMaterial(i).NormalizeNormals = true;
}
plyrNode->setPosition(vector3df(5.0f, 0.1f, 5.0f));
return plyrNode;
}
示例4: addModel
void Unit::addModel() {
IAnimatedMeshSceneNode* modelNode = Game::getInstance().sceneManager->addAnimatedMeshSceneNode( model, node );
if (modelNode)
{
modelNode->setMaterialTexture( 0, texture );
modelNode->getMaterial(0).Shininess = 0;
modelNode->setScale(vector3df(0.15f, 0.15f, 0.15f) );
modelNode->addShadowVolumeSceneNode(0, 0, false);
modelNode->setID(0);
currentAnimation = IDLE_ANIMATION;
float randX = rand() % 8 - 4;
float randZ =rand() % 8 - 4;
modelNode->setPosition(vector3df(randX, 0.0f, randZ));
}
modelNodes.push_back(modelNode);
}
示例5: runExample
void CCharacterExample::runExample()
{
for(s32 i=0; i<KEY_KEY_CODES_COUNT; i++)
KeyIsDown[i] = false;
debugDraw = true;
drawProperties = true;
drawWireFrame = false;
rows = 10;
columns = 10;
device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
false, false, false, this);
device->setWindowCaption(L"irrBullet Character Example - Josiah Hartzell");
device->getFileSystem()->addFileArchive("./media/");
device->getSceneManager()->addLightSceneNode(0, vector3df(20, 40, -50), SColorf(1.0f, 1.0f, 1.0f), 4000.0f);
////////////////////////////
// Create irrBullet World //
////////////////////////////
world = createIrrBulletWorld(device, true, debugDraw);
world->setDebugMode(EPDM_DrawAabb |
EPDM_DrawContactPoints);
world->setGravity(vector3df(0,-10,0));
camera = device->getSceneManager()->addCameraSceneNodeMaya();
camera->setPosition(vector3df(50,15,200));
camera->bindTargetAndRotation(true);
createGround();
createBoxes();
IKinematicCharacterController* character = new IKinematicCharacterController(world);
IAnimatedMeshSceneNode* sydney = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("sydney.md2"));
sydney->setScale(vector3df(0.14,0.14,0.14));
sydney->getMaterial(0).setTexture(0, device->getVideoDriver()->getTexture("sydney.bmp"));
sydney->setMD2Animation(scene::EMAT_STAND);
// Set our delta time and time stamp
u32 TimeStamp = device->getTimer()->getTime();
u32 DeltaTime = 0;
EMD2_ANIMATION_TYPE animation = EMAT_STAND;
EMD2_ANIMATION_TYPE newAnimation = EMAT_RUN;
bool jump = false;
while(device->run())
{
device->getVideoDriver()->beginScene(true, true, SColor(255,100,101,140));
DeltaTime = device->getTimer()->getTime() - TimeStamp;
TimeStamp = device->getTimer()->getTime();
/*sydney->setPosition(character->getWorldTransform().getTranslation()+vector3df(0,-((sydney->getBoundingBox().MaxEdge.Y-sydney->getBoundingBox().MinEdge.Y)*0.1*0.5f),0));
vector3df dir = camera->getAbsolutePosition()-sydney->getAbsolutePosition();
dir.normalize();
dir.Y = 0;
dir *= -1;
character->setWalkDirection(dir*0.3f);*/
if(IsKeyDown(KEY_KEY_W))
{
DirZ = -1.0f;
}
else if(IsKeyDown(KEY_KEY_S))
{
DirZ = 1.0f;
}
else
{
DirZ = 0.0f;
}
if(IsKeyDown(KEY_KEY_A))
{
DirX = 1.0f;
}
else if(IsKeyDown(KEY_KEY_D))
{
DirX = -1.0f;
}
else
//.........这里部分代码省略.........
示例6: LoadModels
///////////////////////////////////////////函数实现////////////////////////////////////////////////
bool LoadModels(ISceneNode* m_ICamera,std::map<std::string,IAnimatedMeshSceneNode*>& myNode)
{
_finddata_t file;
long longf;
//读取文件夹下文件名字
if((longf = _findfirst("..\\model\\*.3ds", &file))==-1l)
{
std::cout<<"没有找到模型!\n";
}
else
{
std::cout<<"\n加载模型\n";
std::string tempName;
tempName = "";
tempName = file.name;
m_vecStrModelName.push_back(tempName);//加载第一个模型名字
while( _findnext( longf, &file ) == 0 )
{
tempName = "";
tempName = file.name;
if (tempName == "..")
{
continue;
}
m_vecStrModelName.push_back(tempName);
}
}
_findclose(longf);
//模型库模型节点的ID(从1000开始)
int storeModelID=1000;
//加载模型创建场景节点
auto iter(m_vecStrModelName.begin());
while(iter!=m_vecStrModelName.end())
{
std::string myPath=*iter;
myPath="..\\model\\"+myPath;
scene::IAnimatedMesh* mesh = m_IrrSmgr->getMesh((char*)myPath.c_str());
//模型设为摄像头的子节点
IAnimatedMeshSceneNode* modelNode = m_IrrSmgr->addAnimatedMeshSceneNode(mesh,m_ICamera);
// 设置自发光强度大小(即镜面渲染中的亮度大小)
modelNode->getMaterial(0).Shininess = 20.0f;
modelNode->setMaterialFlag(EMF_LIGHTING, true);
modelNode->setRotation(vector3df(90, 0, 0));
modelNode->setPosition(vector3df(90, 0, 0));
//创建三角选择器
m_ItriElector = m_IrrSmgr->createTriangleSelector(modelNode);
modelNode->setTriangleSelector(m_ItriElector);
m_ItriElector->drop(); // We're done with this m_ItriElector, so drop it now.
myNode[(*iter)]=modelNode;//插入模型名字和模型库结点对
iter++;
//设置模型为不可见
modelNode->setVisible(false);
//设置模型库模型ID
modelNode->setID(storeModelID);
++storeModelID;
}
//计算模型库的页数(三个模型一页)
m_iTotalPageNumber=m_vecStrModelName.size()/m_iPageModelCount;
if(m_vecStrModelName.size()%m_iPageModelCount!=0)
{
m_iTotalPageNumber+=1;
}
//添加翻页标志模型
for(int i=0;i<2;i++)
{
scene::IAnimatedMesh* mesh;
if(0==i)
{
mesh = m_IrrSmgr->getMesh("left.3ds");
}
else
{
mesh = m_IrrSmgr->getMesh("right.3ds");
}
//模型设为摄像头的子节点
IAnimatedMeshSceneNode* modelNode = m_IrrSmgr->addAnimatedMeshSceneNode(mesh,m_ICamera);
// 设置自发光强度大小(即镜面渲染中的亮度大小)
modelNode->getMaterial(0).Shininess = 20.0f;
modelNode->setMaterialFlag(EMF_LIGHTING, true);
modelNode->setRotation(vector3df(90, 0, 0));
//创建三角选择器
m_ItriElector = m_IrrSmgr->createTriangleSelector(modelNode);
modelNode->setTriangleSelector(m_ItriElector);
//.........这里部分代码省略.........
开发者ID:xueyedamo,项目名称:Workshop-layout-design-system-based-on-augmented-reality,代码行数:101,代码来源:MainRenderLoop.cpp
示例7: OnRegisterSceneNode
// registering the scene node for rendering, here we take the opportunity
// to make LOD adjustments to child nodes
void CLODSceneNode::OnRegisterSceneNode()
{
//if this node is invisible forget any child nodes
if (!IsVisible)
return;
// get a timer to calculate the amount to fade objects
u32 time = device->getTimer()->getTime();
// get the camera position
ICameraSceneNode* cam = smgr->getActiveCamera();
core::vector3df vectorCam = cam->getAbsolutePosition();
// loop through all child nodes
u32 i,j;
u32 lod, fade;
SMaterial * material;
for (i=0; i < children.size(); ++i)
{
// get the node associated with this link
SChildLink &child = children[i];
IAnimatedMeshSceneNode *node = (IAnimatedMeshSceneNode *)child.node;
// calculate the distance to the node. at the moment we do this the
// slow linear way instead of using the distance squared method
core::vector3df vectorNode = node->getAbsolutePosition();
float distance = vectorNode.getDistanceFrom( vectorCam );
// itterate through all of the LOD levels and find the lod distance
// that is appropriate for this distance
lod = 0xFFFFFFFF;
for (j=0; j < lods.size(); ++j)
{
if ( distance >= lods[j].distance )
{
lod = j;
}
}
// if a LOD level was found
if ( lod != 0xFFFFFFFF )
{
// if this lod is associated with a mesh
if ( lods[lod].mesh )
{
// if this lod differs from the child lod
if ( lod != children[i].lod )
{
children[i].lod = lod;
// if the node is an animated mesh node
if ( ( node->getType()) == ESNT_ANIMATED_MESH )
{
// set the new mesh to be used
node->setMeshClean( lods[lod].mesh );
}
}
// handle instances where the node is faded
switch ( children[i].mode )
{
case LOD_INVISIBLE:
// make the node visible
node->setVisible( true );
children[i].mode = LOD_FADE_IN;
children[i].fade = time;
break;
// we are partially faded we need to fade back in
case LOD_FADE_IN:
// fade the node in by 1 multiplied by the time passed
fade = (time - children[i].fade) / fadeScale;
if ( fade > 0xFF ) fade = 0xFF;
// if the node is fully opaque again
if ( fade == 0xFF )
{
// restore the origonal material type
node->setMaterialType(children[i].matType);
children[i].mode = LOD_OPAQUE;
if ( callback ) callback( true, node );
}
// fade the node through its materials
fade *= 0x01010101;
material = &node->getMaterial( 0 );
if ( useAlpha )
{
material->DiffuseColor.set( fade );
material->AmbientColor.set( fade );
}
else
{
material->DiffuseColor.set( fade & 0xFFFFFF );
material->AmbientColor.set( fade & 0xFFFFFF );
}
break;
//.........这里部分代码省略.........
示例8: Mesh3DInitScene
void Mesh3DInitScene()
{
IAnimatedMesh* mesh;
IAnimatedMeshSceneNode* node;
scene::ISceneNodeAnimator* anim;
scene::ISceneManager* smgr = IrrlichtManager::GetIrrlichtManager()->GetScene();
IrrlichtDevice* device = IrrlichtManager::GetIrrlichtManager()->GetDevice();
video::IVideoDriver* driver = IrrlichtManager::GetIrrlichtManager()->GetDriver();
std::string load_zip;
std::string load_data;
std::string reload_path;
FileSystemZip* pfilesystem = NULL;
io::IReadFile* memfile = NULL;
byte* apk_buffer = NULL;
byte* buff_extract = NULL;
int size = 0;
int apk_size = 0;
if (!IrrlichtManager::GetIrrlichtManager()->GetDevice())
{
LogError("Error initializing Irrlicht");
return;
}
IrrlichtManager::GetIrrlichtManager()->GetDevice()->getTimer()->setTime(0);
smgr->addLightSceneNode(0, core::vector3df(-100,10,0), video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 200.0f);
smgr->addLightSceneNode(0, core::vector3df(+100,10,0), video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 200.0f);
//////////////////////////////mesh/////////////////////////////////////////////////
load_zip = (GetBaseAppPath() + "game/ninja.zip").c_str();
load_data = "ninja.b3d";
reload_path = (GetBaseAppPath() + "game/ninja.b3d").c_str();
#ifdef ANDROID_NDK
apk_buffer = FileManager::GetFileManager()->Get(load_zip.c_str(), &apk_size, false, false);
if( apk_buffer )
{
pfilesystem = new FileSystemZip();
pfilesystem->Init_unzMemory(apk_buffer, apk_size);
buff_extract = pfilesystem->Get_unz(load_data, &size);
delete apk_buffer;
apk_buffer = NULL;
}
#else
pfilesystem = new FileSystemZip();
pfilesystem->Init_unz(load_zip.c_str());
buff_extract = pfilesystem->Get_unz(load_data.c_str(), &size);
#endif
memfile = device->getFileSystem()->createMemoryReadFile(buff_extract, size, reload_path.c_str(), true);
//new buffer copy on file->read(Buffer, size) of CXMeshFileLoader::readFileIntoMemory
mesh = smgr->getMesh( memfile );
node = smgr->addAnimatedMeshSceneNode( mesh );
//delete buff_extract in drop() then goto ~CMemoryReadFile
memfile->drop();
if( pfilesystem )
{
delete pfilesystem;
pfilesystem = NULL;
}
//////////////////////////////texture/////////////////////////////////////////////////
node->setMaterialTexture( 0, driver->getTexture((GetBaseAppPath()+"game/nskinbl.jpg").c_str()) );
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
anim = smgr->createRotationAnimator(core::vector3df(0,0.3f,0));
node->addAnimator(anim);
anim->drop();
u32 alpha_val = 90;
u32 MaterialCount = node->getMaterialCount();
for(u32 i=0; i<MaterialCount; i++)
{
video::SMaterial& tex_mat = node->getMaterial(i);
tex_mat.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
//tex_mat.MaterialTypeParam = 0.1;
//tex_mat.MaterialTypeParam2= 0.1;
tex_mat.AmbientColor.setAlpha(alpha_val);
tex_mat.DiffuseColor.setAlpha(alpha_val);
tex_mat.SpecularColor.setAlpha(alpha_val);
tex_mat.EmissiveColor.setAlpha(alpha_val);
}
#if defined(_IRR_COMPILE_WITH_OGLES2_)
for(u32 i=0; i<mesh->getMeshBufferCount(); i++)
{
scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
video::S3DVertex* vertex = (video::S3DVertex*)buffer->getVertices();
for(u32 j=0; j<buffer->getVertexCount(); j++)
{
vertex[j].Color.setAlpha(alpha_val);
//.........这里部分代码省略.........