当前位置: 首页>>代码示例>>C++>>正文


C++ IAnimatedMeshSceneNode::setMeshClean方法代码示例

本文整理汇总了C++中IAnimatedMeshSceneNode::setMeshClean方法的典型用法代码示例。如果您正苦于以下问题:C++ IAnimatedMeshSceneNode::setMeshClean方法的具体用法?C++ IAnimatedMeshSceneNode::setMeshClean怎么用?C++ IAnimatedMeshSceneNode::setMeshClean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAnimatedMeshSceneNode的用法示例。


在下文中一共展示了IAnimatedMeshSceneNode::setMeshClean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;

//.........这里部分代码省略.........
开发者ID:rexwhitten,项目名称:battlespace,代码行数:101,代码来源:CLODSceneNode.cpp


注:本文中的IAnimatedMeshSceneNode::setMeshClean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。