本文整理汇总了C++中IAnimatedMeshSceneNode::setMaterialType方法的典型用法代码示例。如果您正苦于以下问题:C++ IAnimatedMeshSceneNode::setMaterialType方法的具体用法?C++ IAnimatedMeshSceneNode::setMaterialType怎么用?C++ IAnimatedMeshSceneNode::setMaterialType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAnimatedMeshSceneNode
的用法示例。
在下文中一共展示了IAnimatedMeshSceneNode::setMaterialType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCheckPoint
void Game::addCheckPoint(const vector3df& position, const vector3df& rotation)
{
string<char> str = "checkpoint" + checkpoint->size();
IAnimatedMesh *cp1 = smgr->addHillPlaneMesh(str.c_str(), dimension2d<f32>(1000,1000), dimension2d<u32>(1,1));
IAnimatedMeshSceneNode *c = smgr->addAnimatedMeshSceneNode(cp1);
c->setRotation(rotation);
c->setPosition(position);
//c->setDebugDataVisible(EDS_BBOX);
checkpoint->push_back(c);
if (checkpoint->size() == 1)
{
first_checkpoint = c;
}
c->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
//c->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
}
示例2: main
int main( ) {
// Boring stuff: set up the scene, object & camera as usual
// To make things more interesting, we add many Sydneys and a textured floor this time
IrrlichtDevice* device = createDevice( DRIVER, dimension2d<s32>( 640, 480 ), 16, false, false, false, 0 );
IVideoDriver* driver = device->getVideoDriver( );
ISceneManager* smgr = device->getSceneManager( );
IGUIEnvironment* guienv = device->getGUIEnvironment( );
device->getFileSystem( )->changeWorkingDirectoryTo( MEDIA_DIRECTORY );
guienv->addStaticText( L"Sandbox", rect<s32>( 10, 10, 260, 22 ), true );
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices( );
u32 matid;
switch( driver->getDriverType( ) ) {
case EDT_OPENGL:
matid = gpu->addHighLevelShaderMaterial( GL_V_MAT, "main", EVST_VS_1_1, GL_PLAIN, "main", EPST_PS_1_1, new CTexturesShaderCallback( ), EMT_SOLID, 1 );
break;
case EDT_DIRECT3D8:
case EDT_DIRECT3D9:
default:
matid = gpu->addHighLevelShaderMaterial( DX_V_MAT, "main", EVST_VS_1_1, DX_PLAIN, "main", EPST_PS_2_0, new CTexturesShaderCallback( ), EMT_SOLID, 0 );
}
for( u8 x = 0u; x != 2u; ++ x )
for( u8 i = 0u; i != 5u; ++ i ) {
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
node->setMaterialType( (E_MATERIAL_TYPE) matid );
node->setPosition( vector3df( -x * 20.0f, 0.0f, i * 40.0f ) );
}
ISceneNode* nodeF = smgr->addTerrainSceneNode( "terrain-heightmap.bmp" );
nodeF->setMaterialFlag(EMF_LIGHTING, false);
nodeF->setMaterialTexture( 0, driver->getTexture("terrain-heightmap.bmp") );
nodeF->setPosition( vector3df( -512.0f, -50.0f, -512.0f ) );
nodeF->setScale( vector3df( 4.0f, 0.2f, 4.0f ) );
nodeF->setMaterialType( (E_MATERIAL_TYPE) matid );
ICameraSceneNode* cam1 = smgr->addCameraSceneNode( 0, vector3df( 0.0f, 0.0f, -40.0f ), vector3df( 0.0f, 5.0f, 50.0f ) );
IPostProc* ppRenderer1 = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255, 130u, 180u, 230u ) );
CWaterPostProc* ppWater = new CWaterPostProc( ppRenderer1, dimension2di( 1024, 512 ), -22.0f );
ppWater->setTimer( device->getTimer( ) );
wchar_t tmp[255];
u8 t = 0u;
while( device->run( ) ) {
// cam1->setPosition( vector3df( 40.0f, 60.0f - (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, -40.0f ) );
cam1->setPosition( vector3df( (device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, -40.0f ) );
// cam1->setTarget( vector3df( (device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, 0.0f ) );
// cam1->setTarget( cam1->getPosition( ) + vector3df( 0.0f, 0.0f, 10.0f ) );
// cam1->setTarget( vector3df( -(device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.2f, 50.0f ) );
driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
ppWater->render( NULL );
guienv->drawAll( );
driver->endScene( );
if( ++ t == 30u ) {
t = 0u;
swprintf(tmp, 255, L"%ls fps:%3d", driver->getName(), driver->getFPS() );
device->setWindowCaption( tmp );
}
}
delete ppWater;
delete ppRenderer1;
// Back to boring stuff
device->drop();
return 0;
}
示例3: 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;
//.........这里部分代码省略.........
示例4: main
int main()
{
/* shadowDimen = dimension2du(1024,1024);
shadowDimen = dimension2du(2048,2048);
shadowDimen = dimension2du(4096,4096);
shadowDimen = dimension2du(2048,2048);
filterType = EFT_NONE;
filterType = EFT_4PCF;
filterType = EFT_8PCF;
filterType = EFT_4PCF;
*/
dimension2du shadowDimen = dimension2du(1024,1024);
E_FILTER_TYPE filterType = EFT_4PCF;
filterType = EFT_NONE;
////
IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2du(800,600),32);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,100,.5);
cam->setPosition(vector3df(0,10,0));
// Create the effect handler, passing the device and RTT size (as a dimension2d) .
effectHandler* effect = new effectHandler(device,shadowDimen);
ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain.bmp",0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(1,1,1),SColor(255,255,255,255),1,ETPS_33);
terrain->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap.jpg"));
terrain->scaleTexture(1,10);
terrain->setScale(core::vector3df(4, 0.01f, 4));
terrain->setPosition(vector3df(-120,-1.5f,-120));
terrain->setMaterialType(EMT_DETAIL_MAP);
// Make the terrain recieve a shadow with the specified filter type.
// (NOTE: 12PCF is only available in Direct3D9, all others work with OpenGL)
effect->addShadowToNode(terrain,filterType);
IAnimatedMeshSceneNode* sydney;
IAnimatedMesh* sydneymesh = smgr->getMesh("media/dwarf.x");
for(int g = 0;g < 1;g++)
{
for(int v = 0;v < 3;v++)
{
sydney = smgr->addAnimatedMeshSceneNode(sydneymesh);
sydney->setScale(vector3df(0.05f,0.05f,0.05f));
sydney->setPosition(vector3df(g * 4,0.5f,v * 4));
sydney->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);
sydney->setAutomaticCulling(EAC_FRUSTUM_BOX);
sydney->setMaterialType(EMT_SOLID);
// Add the nodes to the depth pass so that they cast a shadow.
effect->addNodeToDepthPass(sydney);
}
}
effect->getLightCamera()->addAnimator(smgr->createFlyCircleAnimator(sydney->getPosition() + vector3df(0,15,0),25,0.0002f));
effect->getLightCamera()->setNearValue(5);
effect->setMaxShadowDistanceFromLight(120);
smgr->addLightSceneNode(effect->getLightCamera());
MyEventReceiver receiver(cam);
device->setEventReceiver(&receiver);
// Parent a sphere to the light camera so we can see its position.
smgr->addSphereSceneNode(1,8,effect->getLightCamera())->setMaterialFlag(EMF_LIGHTING,false);
while(device->run())
{
wchar_t tmp[255];
swprintf(tmp,255,L"Shadow Map Demo (FPS: %d)",driver->getFPS());
device->setWindowCaption(tmp);
driver->beginScene(true,true,SColor(0,0,0,0));
// Point the light camera at one of the nodes as it rotates around them.
effect->setLightTarget(sydney->getPosition());
// Update the effect handler, remember to always do this BEFORE smgr->drawAll and AFTER beginscene!
effect->update();
smgr->drawAll();
// If user wishes we can display the shadow map to the screen. (May not work in OpenGL)
//.........这里部分代码省略.........