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


C++ array::set_used方法代码示例

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


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

示例1: initializeOccluders

void CCullingSystem::initializeOccluders()
{
	static core::array<SOccluderEntry> occluders_tmp;
	occluders_tmp.set_used(0);

	m_Occluders.sort();

	for (u32 i=0; i<m_Occluders.size(); i++)
	{
		bool occluded = false;

		for (u32 j=i+1; j<m_Occluders.size(); j++)
		{
			if (m_Occluders[j].isOccludeByPlanes(m_Occluders[i].tbbox))
			{
				occluded = true;
				break;
			}
		}

		if (!occluded)
		{
			occluders_tmp.push_back(m_Occluders[i]);	
		}
	}

	m_Occluders.set_used(0);
	m_Occluders = occluders_tmp;
}
开发者ID:zdementor,项目名称:my-base,代码行数:29,代码来源:CCullingSystem.cpp

示例2: if

void CCal3DSceneNode::render()
{
    //----------------------------------------------------------//
    if ( calModel == 0 )
        return;                              // Make sure there is a model to render
        
    //----------------------------------------------------------//
    video::IVideoDriver* driver = SceneManager->getVideoDriver(); // Get the video driver
    CalRenderer* renderer = calModel->getRenderer();            // Get the CalRenderer

    
    
    //----------------------------------------------------------//
    // All we're doing here is form a bridge between the CalRenderer and the IVideoDriver
    // The CalRenderer gives us data (doesn't draw anything) and IVideoDriver needs that data
    // Only problem is that we need to convert it to Irrlicht Compatible data
    // To explain what's going on, this simple diagram should help:
    //  CalRenderer >--GET--> Data >--CONVERT--> Irrlicht Format >--SEND--> IVideoDriver >--DRAW--> ..
    
    //----------------------------------------------------------//
    calModel->getSkeleton()->calculateBoundingBoxes();        // Calculate the bounding box of the skeleton
    
    //----------------------------------------------------------//
    if ( renderer == 0  )
        return;                               // Bail out if no renderer was received
    if ( !renderer->beginRendering() )
        return;                  // Bail out if renderer encountered an error
        
    //----------------------------------------------------------// Move to our position (and rotate/scale)
    driver->setTransform( video::ETS_WORLD, AbsoluteTransformation );
    
    
    //----------------------------------------------------------//
    s32 numMeshes = renderer->getMeshCount();                   // Get the number of meshes we need to draw
    for ( s32 meshId = 0; meshId < numMeshes; meshId++ )        // Loop for every mesh
    {
        //--------------------------------------------------------//
        s32 numSubMeshes = renderer->getSubmeshCount(meshId);     // Get the number of submeshes
        for ( s32 subId = 0; subId < numSubMeshes; subId++ )      // Loop for every submesh
        {
            if ( !renderer->selectMeshSubmesh(meshId, subId) )      // Select the current mesh and submesh
            {
                continue;                                             // Skip this submesh if it failed
            }
            
            //------------------------------------------------------//
            if ( !OverrideMaterial )                              // Should we use Cal3D's material?
            {
                u8 meshColor [4];                                     // Color stored in RGBA format
                // Irrlicht wants it in ARGB format
                renderer->getAmbientColor( meshColor );               // Get the ambient color
                Material.AmbientColor.setRed( meshColor[0] );       // Set the red component
                Material.AmbientColor.setGreen( meshColor[1] );     // Set the green component
                Material.AmbientColor.setBlue( meshColor[2] );      // Set the blue component
                Material.AmbientColor.setAlpha( meshColor[3] );     // Set the alpha component
                
                renderer->getDiffuseColor( meshColor );               // Get the diffuse color
                Material.DiffuseColor.setRed( meshColor[0] );       // Set the red component
                Material.DiffuseColor.setGreen( meshColor[1] );     // Set the green component
                Material.DiffuseColor.setBlue( meshColor[2] );      // Set the blue component
                Material.DiffuseColor.setAlpha( meshColor[3] );     // Set the alpha component
                
                renderer->getSpecularColor( meshColor );              // Get the specular color
                Material.SpecularColor.setRed( meshColor[0] );      // Set the red component
                Material.SpecularColor.setGreen( meshColor[1] );    // Set the green component
                Material.SpecularColor.setBlue( meshColor[2] );     // Set the blue component
                Material.SpecularColor.setAlpha( meshColor[3] );    // Set the alpha component
                
                Material.Shininess = renderer->getShininess();      // Set the shininess factor
                
                if ( renderer->getMapCount() >= 1 )
                {                                                     // Get the irrlicht texture from user data
                    Material.setTexture(0, (video::ITexture*)renderer->getMapUserData(0));
                }
            }
            
            //------------------------------------------------------//
            s32 vertexCount = renderer->getVertexCount();           // Get the number of vertices
            if (vertexCount == 0)
                continue;                         // Skip if the mesh is empty
                
            static core::array<core::vector3df> vertexBuffer;    // Use a core::array to support msvc
            vertexBuffer.set_used( vertexCount );          // Make room for the vertex coordinates
            renderer->getVertices( &vertexBuffer[0].X );              // Copy the vertices into the buffer
            
            //------------------------------------------------------//
            static core::array<core::vector3df> normalBuffer;
            normalBuffer.set_used( vertexCount );       // Buffer for the vertex normals
            renderer->getNormals( &normalBuffer[0].X );               // Copy the normals to the buffer
            
            //------------------------------------------------------//
            static core::array<core::vector2df> texCoordBuffer;
            texCoordBuffer.set_used( vertexCount );                 // Buffer for the vertex texture coordinates
            renderer->getTextureCoordinates( 0, &texCoordBuffer[0].X );// Copy the texture coordinates to the buffer
            
            //------------------------------------------------------//
            s32 faceCount = renderer->getFaceCount();               // Get the number of faces
            static CalIndex cal_indices[30000000];
            renderer->getFaces(  cal_indices );                   // Copy the face indices to the buffer
            static core::array<u16> faceBuffer;
//.........这里部分代码省略.........
开发者ID:F-22,项目名称:blender2cal3d,代码行数:101,代码来源:CCal3DSceneNode.cpp

示例3: Width

	HeightMap(u16 _w, u16 _h) : Width(_w), Height(_h), s(0.f), data(0)
	{
		s = sqrtf((f32)(Width * Width + Height * Height));
		data.set_used(Width * Height);
	}
开发者ID:bacsmar,项目名称:irrlicht,代码行数:5,代码来源:main.cpp

示例4: collideWithWorld

core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData, core::vector3df pos, core::vector3df vel)
{
	f32 veryCloseDistance = colData.slidingSpeed;
	
	if (recursionDepth > 5)
		return pos;

	colData.velocity = vel;
	colData.normalizedVelocity = vel;
	colData.normalizedVelocity.normalize();
	colData.basePoint = pos;
	colData.foundCollision = false;
	colData.nearestDistance = FLT_MAX;

	double uhel_cos = 90 - acos(colData.normalizedVelocity.dotProduct(vector3df(0, -1, 0).normalize())) * 180.0 / PI;

	if (recursionDepth > 0 && vel.getLength() > 0 && vel.Y < 0)
	{
		if (abs(uhel_cos) < 50)
			return pos;
	}


	//------------------ collide with world

	// get all triangles with which we might collide
	core::aabbox3d<f32> box(colData.R3Position);
	box.addInternalPoint(colData.R3Position + colData.R3Velocity);
	box.MinEdge -= colData.eRadius;
	box.MaxEdge += colData.eRadius;

	s32 totalTriangleCnt = colData.selector->getTriangleCount();
	Triangles.set_used(totalTriangleCnt);

	core::matrix4 scaleMatrix;
	scaleMatrix.setScale(
			core::vector3df(1.0f / colData.eRadius.X,
					1.0f / colData.eRadius.Y,
					1.0f / colData.eRadius.Z));

	s32 triangleCnt = 0;


	colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, box, &scaleMatrix);


	for (s32 i=0; i<triangleCnt; ++i)
		if(testTriangleIntersection(&colData, Triangles[i]))
			colData.triangleIndex = i;


	//---------------- end collide with world

	if (!colData.foundCollision)
		return pos + vel;

	// original destination point
	const core::vector3df destinationPoint = pos + vel;
	core::vector3df newBasePoint = pos;

	if (colData.nearestDistance >= veryCloseDistance)
	{
		core::vector3df v = vel;
		v.setLength( colData.nearestDistance - veryCloseDistance );
		newBasePoint = colData.basePoint + v;

		v.normalize();
		colData.intersectionPoint -= (v * veryCloseDistance);
	}

	// calculate sliding plane

	const core::vector3df slidePlaneOrigin = colData.intersectionPoint;
	const core::vector3df slidePlaneNormal = (newBasePoint - colData.intersectionPoint).normalize();
	core::plane3d<f32> slidingPlane(slidePlaneOrigin, slidePlaneNormal);

	core::vector3df newDestinationPoint =
		destinationPoint -
		(slidePlaneNormal * slidingPlane.getDistanceTo(destinationPoint));

	// generate slide vector

	const core::vector3df newVelocityVector = newDestinationPoint -
		colData.intersectionPoint;

	if (newVelocityVector.getLength() < veryCloseDistance)
		return newBasePoint;

	//printf("Puvodni delka: %f | nova delka: %f\n", colData.velocity.getLength(), newVelocityVector.getLength());

	return collideWithWorld(recursionDepth+1, colData,
		newBasePoint, newVelocityVector);
}
开发者ID:vasekkraka,项目名称:WorldOfWraithRPG,代码行数:93,代码来源:CColManager.cpp


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