• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Node函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Node函数的典型用法代码示例。如果您正苦于以下问题:C++ Node函数的具体用法?C++ Node怎么用?C++ Node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1:

/// create node
Graph::Node& Graph::add(int value)
{
	nodes.push_back(Node(value));

	return nodes.back();
}
开发者ID:azurenote,项目名称:ctest,代码行数:7,代码来源:graph.cpp


示例2: CHECK

//------------------------------------------------------------------------------
//!
void
BIH::create(
   const Vector<AABBoxf*>& bboxes,
   const Vector<Vec3f>&    centers,
   Vector<uint>*           ids,
   uint                    leafSize,
   uint                    maxDepth
)
{
   CHECK( bboxes.size() == centers.size() );

   DBG_BLOCK( os_bih, "Start computing BIH..." );
   DBG( Timer timer );

   // Initialization.
   DBG_MSG( os_bih, "# of elements: " << bboxes.size() << " " << centers.size() << "\n" );
   // 1. Init maximum recursion level.
   if( maxDepth == 0 )
   {
      maxDepth = (int)CGM::log2( float(centers.size()) ) * 2 + 1;
   }
   _maxDepth = CGM::min( maxDepth, (uint)100 );

   // 2. Init ids.
   if( ids == 0 )
   {
      _ids.resize( centers.size() );
      for( uint i = 0; i < _ids.size(); ++i )
      {
         _ids[i] = i;
      }
   }
   else
   {
      _ids.swap( *ids );
   }
   
   Vector<uint>  remap( centers.size() );
   for( uint i = 0; i < remap.size(); ++i )
   {
      remap[i] = i;
   }

   // 3. Init nodes and root.
   //_nodes.reserve();
   _nodes.resize(1);

   // 4. Compute bounding box.
   AABBoxf nodeBox  = AABBoxf::empty();
   for( uint i = 0; i < bboxes.size(); ++i )
   {
      nodeBox |= *bboxes[i];
   }
   AABBoxf splitBox = nodeBox;

   // 5. Stack.
   Vector<BuildStackNode> stack( maxDepth );
   uint stackID = 0;

   uint maxPrim = 0;
   uint maxD = 0;

   // Construct BIH.
   uint begin = 0;
   uint end   = uint(_ids.size());
   uint depth = 1;
   uint node  = 0;
   while( 1 )
   {
      // Do we have a root node?
      if( (end - begin <= leafSize) || depth >= maxDepth )
      {
         // Root node.
         _nodes[node]._index = (begin << 3) + 3;
         _nodes[node]._numElements = end-begin;

         maxPrim = CGM::max( maxPrim, end-begin );
         maxD = CGM::max( maxD, depth );

         // Are we done?
         if( stackID == 0 )
         {
            break;
         }
         stack[--stackID].get( node, begin, end, depth, nodeBox, splitBox );
      }
      else
      {
         // Compute split plane and axis.
         uint axis        = splitBox.longestSide();
         float splitPlane = splitBox.center( axis );

         // Partition primitives.
         AABBoxf leftNodeBox  = AABBoxf::empty();
         AABBoxf rightNodeBox = AABBoxf::empty();
         uint pivot = begin;
         for( uint i = begin; i < end; ++i )
         {
//.........这里部分代码省略.........
开发者ID:LudoSapiens,项目名称:Dev,代码行数:101,代码来源:BIH.cpp


示例3: Node

bool isBoxAppl	(Tree t)					{ return t->node() == Node(gGlobal->BOXAPPL); }
开发者ID:EBone,项目名称:Faust,代码行数:1,代码来源:boxes.cpp


示例4: BL_ASSERT

void
CArena::free (void* vp)
{
    if (vp == 0)
        //
        // Allow calls with NULL as allowed by C++ delete.
        //
        return;
    //
    // `vp' had better be in the busy list.
    //
    NL::iterator busy_it = m_busylist.find(Node(vp,0));

    BL_ASSERT(!(busy_it == m_busylist.end()));
    BL_ASSERT(m_freelist.find(*busy_it) == m_freelist.end());
    //
    // Put free'd block on free list and save iterator to insert()ed position.
    //
    std::pair<NL::iterator,bool> pair_it = m_freelist.insert(*busy_it);

    BL_ASSERT(pair_it.second == true);

    NL::iterator free_it = pair_it.first;

    void* freeblock = static_cast<char*>((*busy_it).block());

    BL_ASSERT(free_it != m_freelist.end() && (*free_it).block() == freeblock);
    //
    // And remove from busy list.
    //
    m_busylist.erase(busy_it);
    //
    // Coalesce freeblock(s) on lo and hi side of this block.
    //
    if (!(free_it == m_freelist.begin()))
    {
        NL::iterator lo_it = free_it;

        --lo_it;

        void* addr = static_cast<char*>((*lo_it).block()) + (*lo_it).size();

        if (addr == (*free_it).block())
        {
            //
            // This cast is needed as iterators to set return const values;
            // i.e. we can't legally change an element of a set.
            // In this case I want to change the size() of a block
            // in the freelist.  Since size() is not used in the ordering
            // relations in the set, this won't effect the order;
            // i.e. it won't muck up the ordering of elements in the set.
            // I don't want to have to remove the element from the set and
            // then reinsert it with a different size() as it'll just go
            // back into the same place in the set.
            //
            Node* node = const_cast<Node*>(&(*lo_it));
            BL_ASSERT(!(node == 0));
            node->size((*lo_it).size() + (*free_it).size());
            m_freelist.erase(free_it);
            free_it = lo_it;
        }
    }

    NL::iterator hi_it = free_it;

    void* addr = static_cast<char*>((*free_it).block()) + (*free_it).size();

    if (++hi_it != m_freelist.end() && addr == (*hi_it).block())
    {
        //
        // Ditto the above comment.
        //
        Node* node = const_cast<Node*>(&(*free_it));
        BL_ASSERT(!(node == 0));
        node->size((*free_it).size() + (*hi_it).size());
        m_freelist.erase(hi_it);
    }
}
开发者ID:dwillcox,项目名称:BoxLib,代码行数:78,代码来源:CArena.cpp


示例5: Node

//----------------------------------------------------------------------------
void CollisionsBoundTree::CreateScene ()
{
    // The root of the scene will have two cylinders as children.
    mScene = new0 Node();
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);
    mCullState = new0 CullState();
    mCullState->Enabled = false;
    mRenderer->SetOverrideCullState(mCullState);

    // Create a texture image to be used by both cylinders.
    Texture2D* texture = new0 Texture2D(Texture::TF_A8R8G8B8, 2, 2, 1);
    unsigned int* data = (unsigned int*)texture->GetData(0);
    data[0] = Color::MakeR8G8B8(0,     0, 255);  // blue
    data[1] = Color::MakeR8G8B8(0,   255, 255);  // cyan
    data[2] = Color::MakeR8G8B8(255,   0,   0);  // red
    data[3] = Color::MakeR8G8B8(255, 255,   0);  // yellow

    Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);

    // Create two cylinders, one short and thick, one tall and thin.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    StandardMesh sm(vformat);
    VertexBufferAccessor vba;
    int i;

    mCylinder0 = sm.Cylinder(8, 16, 1.0f, 2.0f, false);
    vba.ApplyTo(mCylinder0);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mBlueUV;
    }
    mCylinder0->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder0);

    mCylinder1 = sm.Cylinder(16,8,0.25,4.0,false);
    vba.ApplyTo(mCylinder1);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mRedUV;
    }
    mCylinder1->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder1);

    mScene->Update();

    // Set up the collision system.  Record0 handles the collision response.
    // Record1 is not given a callback so that 'double processing' of the
    // events does not occur.
    CTree* tree0 = new0 CTree(mCylinder0, 1, false);
    CRecord* record0 = new0 CRecord(tree0, 0, Response, this);
    CTree* tree1 = new0 CTree(mCylinder1, 1, false);
    CRecord* record1 = new0 CRecord(tree1, 0, 0, 0);
    mGroup = new0 CGroup();
    mGroup->Add(record0);
    mGroup->Add(record1);

    ResetColors();
    mGroup->TestIntersection();
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:64,代码来源:CollisionsBoundTree.cpp


示例6: Node

//----------------------------------------------------------------------------
void Terrains::CreateScene ()
{
	// Create the root of the scene.
	mScene = new0 Node();

	// Load and initialize the sky dome.  It follows the camera.
	std::string skyMeshName = Environment::GetPathR("SkyDomePNT2.wmvf");
	Visual::PrimitiveType type;
	VertexFormat* vformat;
	VertexBuffer* vbuffer;
	IndexBuffer* ibuffer;
	Visual::LoadWMVF(skyMeshName, type, vformat, vbuffer, ibuffer);
	mSkyDome = new0 TriMesh(vformat, vbuffer, ibuffer);
	mScene->AttachChild(mSkyDome);

	APoint skyPosition = mCamera->GetPosition();
	skyPosition[2] = 0.0f;
	mSkyDome->LocalTransform.SetTranslate(skyPosition);
	mSkyDome->LocalTransform.SetUniformScale(mCamera->GetDMax());

	Texture2DEffect* skyEffect = new0 Texture2DEffect(
	                                 Shader::SF_LINEAR_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT);
	std::string skyTextureName = Environment::GetPathR("SkyDome.wmtf");
	Texture2D* skyTexture = Texture2D::LoadWMTF(skyTextureName);
	skyTexture->GenerateMipmaps();
	mSkyDome->SetEffectInstance(skyEffect->CreateInstance(skyTexture));

	// Load the height field and create the terrain.
	vformat = VertexFormat::Create(3,
	                               VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
	                               VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0,
	                               VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 1);

	// For lower-resolution terrain, change the paths to Height64/Color64 or
	// Height32/Color32.
	std::string heightName = ThePath + "Data/Height128/height";
	std::string colorName = ThePath + "Data/Color128/color";

	mTerrain = new0 Terrain(heightName, vformat, mCamera);
	mScene->AttachChild(mTerrain);

	// The effect that is shared across all pages.
	std::string effectFile =
	    Environment::GetPathR("BaseMulDetailFogExpSqr.wmfx");
	TerrainEffect* terrainEffect = new0 TerrainEffect(effectFile);

	std::string detailName = Environment::GetPathR("Detail.wmtf");
	Texture2D* detailTexture = Texture2D::LoadWMTF(detailName);
	detailTexture->GenerateMipmaps();

	ShaderFloat* fogColorDensity = new0 ShaderFloat(1);
	(*fogColorDensity)[0] = 0.5686f;
	(*fogColorDensity)[1] = 0.7255f;
	(*fogColorDensity)[2] = 0.8353f;
	(*fogColorDensity)[3] = 0.0015f;

	// Attach an effect to each page.  Preload all resources to video memory.
	// This will avoid frame rate stalls when new terrain pages are
	// encountered as the camera moves.
	const int numRows = mTerrain->GetRowQuantity();
	const int numCols = mTerrain->GetColQuantity();
	for (int r = 0; r < numRows; ++r)
	{
		for (int c = 0; c < numCols; ++c)
		{
			TerrainPage* page = mTerrain->GetPage(r, c);

			char suffix[32];
			sprintf(suffix, ".%d.%d.wmtf", r, c);
			std::string colorTextureName = colorName + std::string(suffix);
			Texture2D* colorTexture = Texture2D::LoadWMTF(colorTextureName);
			colorTexture->GenerateMipmaps();

			VisualEffectInstance* instance = terrainEffect->CreateInstance(
			                                     colorTexture, detailTexture, fogColorDensity);

			page->SetEffectInstance(instance);

			mRenderer->Bind(page->GetVertexBuffer());
			mRenderer->Bind(page->GetVertexFormat());
			mRenderer->Bind(page->GetIndexBuffer());
			mRenderer->Bind(colorTexture);
		}
	}
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:86,代码来源:Terrains.cpp


示例7: main

int main()
{
    glfwInit();

    Window testWindow(50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, "Deferred Shading");
    glfwMakeContextCurrent(testWindow.getWindow());
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);


    // You have to set a camera name
    cam.setName("PilotviewCam");
    cam.setPosition(glm::vec4(0.0, 0.5, 3.0, 1.0));
    cam.setNearFar(0.01f, 100.0f);

    iH.setAllInputMaps(cam);
    iH.changeActiveInputMap("Pilotview");

    //Callback
    glfwSetKeyCallback(testWindow.getWindow(), key_callback);

    glewInit();

    //our shader
    VertexShader vsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.vert")));
    FragmentShader fsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.frag")));
    ShaderProgram shaderGBuffer(vsGBuffer, fsGBuffer);

    //load shader here
    VertexShader vsDsLighting(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsLighting.vert")));
    FragmentShader fsDsLighting(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsLighting.frag")));
    ShaderProgram shaderDsLightingShader(vsDsLighting, fsDsLighting);

    VertexShader vsDsCompositing(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsFinalCompositing.vert")));
    FragmentShader fsDsCompositing(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsFinalCompositing.frag")));
    ShaderProgram shaderDsCompositingShader(vsDsCompositing, fsDsCompositing);

    VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert")));
    FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag")));
    ShaderProgram shaderSFQ(vsSfq, fsSfq);

    //our renderer
    OpenGL3Context context;
    Renderer renderer(context);

    FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboDeferredShading(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboCompositing(WINDOW_WIDTH, WINDOW_HEIGHT, 3, false, false);

    //our object
    Cube cube;

    Teapot teapot;

    Rect plane;
    Rect screenFillingQuad;
    screenFillingQuad.loadBufferData();

    //our textures
    Texture bricks((char*)RESOURCES_PATH "/bricks_diffuse.png");
    Texture bricks_normal((char*)RESOURCES_PATH "/bricks_normal.png");
    Texture bricks_height((char*)RESOURCES_PATH "/bricks_height.png");

    Texture chrome((char*)RESOURCES_PATH "/chrome.jpg");
    Texture cvLogo((char*)RESOURCES_PATH "/cv_logo.bmp");

    //Scene creation
    Level testLevel("testLevel");
    Scene testScene("testScene");
    testLevel.addScene(&testScene);
    testLevel.changeScene("testScene");

    //Add Camera to scenegraph
    testScene.getScenegraph()->addCamera(&cam);
    testScene.getScenegraph()->getCamera("PilotviewCam");
    testScene.getScenegraph()->setActiveCamera("PilotviewCam");

    Rect rect;

    Node cube1("cube1");
    cube1.addGeometry(&cube);
    cube1.addTexture(&bricks);
    cube1.addNormalMap(&bricks_normal);
    cube1.addHeightMap(&bricks_height);
    cube1.setModelMatrix(glm::translate(cube1.getModelMatrix(), glm::vec3(-1.0, 0.5, -0.5)));
    cube1.setModelMatrix(glm::scale(cube1.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube2("cube2");
    cube2.addGeometry(&cube);
    cube2.addTexture(&bricks);
    cube2.addNormalMap(&bricks_normal);
    cube2.setModelMatrix(glm::translate(cube2.getModelMatrix(), glm::vec3(-1, 0.5, 0.5)));
    cube2.setModelMatrix(glm::scale(cube2.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube3("cube3");
    cube3.addGeometry(&cube);
    cube3.addTexture(&bricks);
    cube3.setModelMatrix(glm::translate(cube3.getModelMatrix(), glm::vec3(0, 0.5, -0.5)));
    cube3.setModelMatrix(glm::scale(cube3.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube4("cube4");
//.........这里部分代码省略.........
开发者ID:MarcelBock,项目名称:GeKo,代码行数:101,代码来源:main.cpp


示例8: abs

Pacman::ViewDirection Pacman::getNextDirection(unsigned int startIndex, unsigned int searchIndex, unsigned int ignoreCell)
{
	std::list<Node> OpenNodeList;
	std::list<Node> ClosedNodeList;

	// Guardamos en la lista de Nodos Abiertos el Nodo correspondiente a startIndex
	OpenNodeList.push_back(Node());
	OpenNodeList.back().Index = startIndex;
	OpenNodeList.back().Range = abs((startIndex % m_mapSize.x) - (searchIndex % m_mapSize.x)) + abs(floor(startIndex / m_mapSize.y) - floor(searchIndex / m_mapSize.y));

	if(ignoreCell == m_mapNullCell)
	{
		// Guardamos en la lista de Nodos Cerrados el Nodo correspondiente a la casilla a ignorar
		ClosedNodeList.push_back(Node());
		ClosedNodeList.back().Index = ignoreCell;
	}

	Node* preferentNode = &OpenNodeList.back();

	// Hasta que no encuentre el destino o la lista de nodos abiertos se vacíe (no haya caminos posibles)...
	while (preferentNode->Index != searchIndex && !OpenNodeList.empty())
	{
		// Si el nodo preferente está en la lista de nodos cerrados...
		for (auto closedNode : ClosedNodeList)
		{
			if (closedNode.Index == preferentNode->Index)
			{
				preferentNode = &OpenNodeList.back();

				// Elegimos el primer nodo más preferente de la lista de nodos abiertos
				for (auto openNodeIt = OpenNodeList.begin(); openNodeIt != OpenNodeList.end(); ++openNodeIt)
				//for (auto openNode : OpenNodeList)
				{
					if ((preferentNode->Range + preferentNode->Cost) > (openNodeIt->Range + openNodeIt->Cost))
					{
						preferentNode = &*openNodeIt;
					}
				}

				break;
			}
		}

		// Guardamos el nodo preferente en la lista de Nodos cerrados y lo eliminamos de la lista de nodos abiertos
		for (auto openNodeIt = OpenNodeList.begin(); openNodeIt != OpenNodeList.end(); ++openNodeIt)
		{
			if (openNodeIt->Index == preferentNode->Index)
			{
				ClosedNodeList.push_back(*preferentNode);

				// Actualizamos los punteros
				for (Node openNode : OpenNodeList)
				{
					if(openNode.ParentNode == preferentNode)
					{
						openNode.ParentNode = &ClosedNodeList.back();
					}
				}

				preferentNode = &ClosedNodeList.back();

				OpenNodeList.erase(openNodeIt);

				break;
			}
		}

		std::vector<unsigned int> nextIndex;

		// Añadimos a nextIndex CADA UNA de las 4 direcciones si es posible su tránsito
		if (!checkCollision(preferentNode->Index, ViewDirection::Left, false))
		{
			nextIndex.push_back(getMapIndex(preferentNode->Index, ViewDirection::Left));
		}
		if (!checkCollision(preferentNode->Index, ViewDirection::Right, false))
		{
			nextIndex.push_back(getMapIndex(preferentNode->Index, ViewDirection::Right));
		}
		if (!checkCollision(preferentNode->Index, ViewDirection::Up, false))
		{
			nextIndex.push_back(getMapIndex(preferentNode->Index, ViewDirection::Up));
		}
		if (!checkCollision(preferentNode->Index, ViewDirection::Down, false))
		{
			nextIndex.push_back(getMapIndex(preferentNode->Index, ViewDirection::Down));
		}

		if (!nextIndex.empty())
		{
			Node* previousNode = preferentNode;

			for (unsigned int Index : nextIndex)
			{
				bool isValid = true;

				// Miramos si existe en la lista de nodos abiertos
				for (Node openNode : OpenNodeList)
				{
					if (openNode.Index == Index)
					{
//.........这里部分代码省略.........
开发者ID:TheIllusionistMirage,项目名称:SFML2-Game,代码行数:101,代码来源:PacmanController.cpp


示例9: Node

/// Returns the cell (represented as a Node object) at the specified point.
Node Game::pointToNode(const QPointF &point){
    return Node(point.x()/cellSize_,point.y()/cellSize_);
}
开发者ID:MeLikeyCode,项目名称:PacmanPathfindingDemo,代码行数:4,代码来源:Game.cpp


示例10: revcomp

bool IFindObserver<span>::contains(KmerType kmer)
{
    kmer = std::min(kmer, revcomp(kmer, this->_find->kmer_size()));
    Node node = Node(Node::Value(kmer));
    return this->_find->graph_contains(node);
}
开发者ID:GATB,项目名称:MindTheGap,代码行数:6,代码来源:IFindObserver.hpp


示例11: Observer

// ---------------------------------------------------------------------------
// CIAUpdateContentOperation::OperationProgress
// 
// ---------------------------------------------------------------------------
// 
void CIAUpdateContentOperation::OperationProgress( 
    TInt aProgress, TInt aMaxProgress )
    {
    Observer().ContentOperationProgress( Node(), aProgress, aMaxProgress );
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:10,代码来源:iaupdatecontentoperation.cpp


示例12: Node

//----------------------------------------------------------------------------
void BillboardNodes::CreateScene ()
{
    mScene = new0 Node();
    mCullState = new0 CullState();
    mRenderer->SetOverrideCullState(mCullState);
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    // All triangle meshes have this common vertex format.  Use StandardMesh
    // to create these meshes.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    StandardMesh stdMesh(vformat);

    // Create the ground.  It covers a square with vertices (1,1,0), (1,-1,0),
    // (-1,1,0), and (-1,-1,0).  Multiply the texture coordinates by a factor
    // to enhance the wrap-around.
    mGround = stdMesh.Rectangle(2, 2, 16.0f, 16.0f);
    VertexBufferAccessor vba(mGround);
    int i;
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        Float2& tcoord = vba.TCoord<Float2>(0, i);
        tcoord[0] *= 128.0f;
        tcoord[1] *= 128.0f;
    }

    // Create a texture effect for the ground.
    std::string path = Environment::GetPathR("Horizontal.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);
    VisualEffectInstance* instance = Texture2DEffect::CreateUniqueInstance(
        texture, Shader::SF_LINEAR_LINEAR, Shader::SC_REPEAT,
        Shader::SC_REPEAT);
    mGround->SetEffectInstance(instance);
    mScene->AttachChild(mGround);

    // Create a rectangle mesh.  The mesh is in the xy-plane.  Do not apply
    // local transformations to the mesh.  Use the billboard node transforms
    // to control the mesh location and orientation.
    mRectangle = stdMesh.Rectangle(2, 2, 0.125f, 0.25f);

    // Create a texture effect for the rectangle and for the torus.
    Texture2DEffect* geomEffect = new0 Texture2DEffect(Shader::SF_LINEAR);
    path = Environment::GetPathR("RedSky.wmtf");
    texture = Texture2D::LoadWMTF(path);
    mRectangle->SetEffectInstance(geomEffect->CreateInstance(texture));

    // Create a billboard node that causes a rectangle to always be facing
    // the camera.  This is the type of billboard for an avatar.
    mBillboard0 = new0 BillboardNode(mCamera);
    mBillboard0->AttachChild(mRectangle);
    mScene->AttachChild(mBillboard0);

    // The billboard rotation is about its model-space up-vector (0,1,0).  In
    // this application, world-space up is (0,0,1).  Locally rotate the
    // billboard so it's up-vector matches the world's.
    mBillboard0->LocalTransform.SetTranslate(APoint(-0.25f, 0.0f, 0.25f));
    mBillboard0->LocalTransform.SetRotate(HMatrix(AVector::UNIT_X,
        Mathf::HALF_PI));

    // Create a torus mesh.  Do not apply local transformations to the mesh.
    // Use the billboard node transforms to control the mesh location and
    // orientation.
    mTorus = StandardMesh(vformat, false).Torus(16, 16, 1.0f, 0.25f);
    mTorus->LocalTransform.SetUniformScale(0.1f);

    // Create a texture effect for the torus.  It uses the RedSky image that
    // the rectangle uses.
    mTorus->SetEffectInstance(geomEffect->CreateInstance(texture));

    // Create a billboard node that causes an object to always be oriented
    // the same way relative to the camera.
    mBillboard1 = new0 BillboardNode(mCamera);
    mBillboard1->AttachChild(mTorus);
    mScene->AttachChild(mBillboard1);

    // The billboard rotation is about its model-space up-vector (0,1,0).  In
    // this application, world-space up is (0,0,1).  Locally rotate the
    // billboard so it's up-vector matches the world's.
    mBillboard1->LocalTransform.SetTranslate(APoint(0.25f, 0.0f, 0.25f));
    mBillboard1->LocalTransform.SetRotate(HMatrix(AVector::UNIT_X,
        Mathf::HALF_PI));

#ifdef DEMONSTRATE_VIEWPORT_BOUNDING_RECTANGLE
    // The screen camera is designed to map (x,y,z) in [0,1]^3 to (x',y,'z')
    // in [-1,1]^2 x [0,1].
    mSSCamera = new0 Camera(false);
    mSSCamera->SetFrustum(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f);
    mSSCamera->SetFrame(APoint::ORIGIN, AVector::UNIT_Z, AVector::UNIT_Y,
        AVector::UNIT_X);

    // Create a semitransparent screen rectangle.
    VertexFormat* ssVFormat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT4, 0);
    int ssVStride = ssVFormat->GetStride();

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


示例13: Node

//---------------------------------------------------------------------------
Node Node::operator+ ( Node node )
{    
	return Node( x + node.x, y + node.y, z + node.z );
}   
开发者ID:lyq105,项目名称:mscs,代码行数:5,代码来源:Fem.cpp


示例14: Node

//----------------------------------------------------------------------------
void ClodMeshes::CreateScene ()
{
    mScene = new0 Node();
    mTrnNode = new0 Node();
    mScene->AttachChild(mTrnNode);
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    // Load the face model.
#ifdef WM5_LITTLE_ENDIAN
    std::string path = Environment::GetPathR("FacePN.wmof");
#else
    std::string path = Environment::GetPathR("FacePN.be.wmof");
#endif
    InStream inStream;
    inStream.Load(path);
    TriMeshPtr mesh = StaticCast<TriMesh>(inStream.GetObjectAt(0));
    VertexBufferAccessor vba0(mesh);

    // Remove the normals and add texture coordinates.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
    int vstride = vformat->GetStride();

    VertexBuffer* vbuffer = new0 VertexBuffer(vba0.GetNumVertices(), vstride);
    VertexBufferAccessor vba1(vformat, vbuffer);

    float xmin = Mathf::MAX_REAL, xmax = -Mathf::MAX_REAL;
    float ymin = Mathf::MAX_REAL, ymax = -Mathf::MAX_REAL;
    int i;
    for (i = 0; i < vba0.GetNumVertices(); ++i)
    {
        Float3 position = vba0.Position<Float3>(i);
        vba1.Position<Float3>(i) = position;

        float x = position[0];
        float y = position[2];
        vba1.TCoord<Float2>(0, i) = Float2(x, y);

        if (x < xmin)
        {
            xmin = x;
        }
        if (x > xmax)
        {
            xmax = x;
        }
        if (y < ymin)
        {
            ymin = y;
        }
        if (y > ymax)
        {
            ymax = y;
        }
    }

    float xmult = 1.0f/(xmax - xmin);
    float ymult = 1.0f/(ymax - ymin);
    for (i = 0; i < vba1.GetNumVertices(); ++i)
    {
        Float2 tcoord = vba1.TCoord<Float2>(0, i);
        vba1.TCoord<Float2>(0,i) = Float2(
            (tcoord[0] - xmin)*xmult,
            (tcoord[1] - ymin)*ymult);
    }

    mesh->SetVertexFormat(vformat);
    mesh->SetVertexBuffer(vbuffer);

    // Create a texture for the face.  Use the generated texture coordinates.
    Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);
    path = Environment::GetPathR("Magician.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);

#ifdef USE_CLOD_MESH
    // Create the collapse records to be shared by two CLOD meshes.
    int numRecords = 0;
    CollapseRecord* records = 0;
    CreateClodMesh ccm(mesh, numRecords, records);
    CollapseRecordArray* recordArray = new0 CollapseRecordArray(numRecords,
        records);

    mClod[0] = new0 ClodMesh(mesh, recordArray);
    mClod[0]->LocalTransform = mesh->LocalTransform;
    mClod[0]->LocalTransform.SetTranslate(mesh->LocalTransform.GetTranslate()
        - 150.0f*AVector::UNIT_X);
    mClod[0]->SetEffectInstance(effect->CreateInstance(texture));
    mTrnNode->AttachChild(mClod[0]);

    mClod[1] = new0 ClodMesh(mesh, recordArray);
    mClod[1]->LocalTransform = mesh->LocalTransform;
    mClod[1]->LocalTransform.SetTranslate(mesh->LocalTransform.GetTranslate()
        + 150.0f*AVector::UNIT_X - 100.0f*AVector::UNIT_Y);
    mClod[1]->SetEffectInstance(effect->CreateInstance(texture));
    mTrnNode->AttachChild(mClod[1]);

    mActive = mClod[0];
//.........这里部分代码省略.........
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:101,代码来源:ClodMeshes.cpp


示例15: VertexBuffer


//.........这里部分代码省略.........
    int* indices = (int*)ibuffer->GetData();

    const int bound01 = bound0*bound1;
    int j0, j1, j2, j3;
    for (i2 = 0; i2 < bound2; ++i2)
    {
        for (i1 = 0; i1 < bound1M1; ++i1)
        {
            for (i0 = 0; i0 < bound0M1; ++i0)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + 1;
                j2 = j1 + bound0;
                j3 = j2 - 1;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    for (i1 = 0; i1 < bound1; ++i1)
    {
        for (i2 = 0; i2 < bound2M1; ++i2)
        {
            for (i0 = 0; i0 < bound0M1; ++i0)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + 1;
                j2 = j1 + bound01;
                j3 = j2 - 1;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    for (i0 = 0; i0 < bound0; ++i0)
    {
        for (i1 = 0; i1 < bound1M1; ++i1)
        {
            for (i2 = 0; i2 < bound2M1; ++i2)
            {
                j0 = i0 + bound0*(i1 + bound1*i2);
                j1 = j0 + bound0;
                j2 = j1 + bound01;
                j3 = j2 - bound0;
                *indices++ = j0;
                *indices++ = j1;
                *indices++ = j2;
                *indices++ = j0;
                *indices++ = j2;
                *indices++ = j3;
            }
        }
    }

    mCube = new0 TriMesh(vformat, vbuffer, ibuffer);
    UpdateVertexBuffer();
#endif

    mNumIndices = ibuffer->GetNumElements();
    mIndices = new1<int>(mNumIndices);
    memcpy(mIndices, ibuffer->GetData(), mNumIndices*sizeof(int));

    // Create the cube effect.
#ifdef USE_PARTICLES
    std::string path = Environment::GetPathR("Disk.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);
    VisualEffectInstance* instance =
        VertexColor4TextureEffect::CreateUniqueInstance(texture,
        Shader::SF_NEAREST, Shader::SC_CLAMP_EDGE, Shader::SC_CLAMP_EDGE);
#else
    VertexColor4Effect* effect = new0 VertexColor4Effect();
    VisualEffectInstance* instance = effect->CreateInstance();
#endif

    const VisualPass* pass = instance->GetPass(0);
    AlphaState* astate = pass->GetAlphaState();
    astate->BlendEnabled = true;

    CullState* cstate = pass->GetCullState();
    cstate->Enabled = false;

    DepthState* dstate = pass->GetDepthState();
    dstate->Enabled = false;
    dstate->Writable = false;

    mCube->SetEffectInstance(instance);

    mScene = new0 Node();
    mScene->AttachChild(mCube);
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:101,代码来源:Fluids3D.cpp


示例16: new

void*
CArena::alloc (size_t nbytes)
{
    nbytes = Arena::align(nbytes == 0 ? 1 : nbytes);
    //
    // Find node in freelist at lowest memory address that'll satisfy request.
    //
    NL::iterator free_it = m_freelist.begin();

    for ( ; free_it != m_freelist.end(); ++free_it)
        if ((*free_it).size() >= nbytes)
            break;

    void* vp = 0;

    if (free_it == m_freelist.end())
    {
        const size_t N = nbytes < m_hunk ? m_hunk : nbytes;

        vp = ::operator new(N);

        m_used += N;

        m_alloc.push_back(vp);

        if (nbytes < m_hunk)
        {
            //
            // Add leftover chunk to free list.
            //
            // Insert with a hint -- should be largest block in the set.
            //
            void* block = static_cast<char*>(vp) + nbytes;

            m_freelist.insert(m_freelist.end(), Node(block, m_hunk-nbytes));
        }
    }
    else
    {
        BL_ASSERT((*free_it).size() >= nbytes);
        BL_ASSERT(m_busylist.find(*free_it) == m_busylist.end());

        vp = (*free_it).block();

        if ((*free_it).size() > nbytes)
        {
            //
            // Insert remainder of free block back into freelist.
            //
            // Insert with a hint -- right after the current block being split.
            //
            Node freeblock = *free_it;

            freeblock.size(freeblock.size() - nbytes);

            freeblock.block(static_cast<char*>(vp) + nbytes);

            m_freelist.insert(free_it, freeblock);
        }

        m_freelist.erase(free_it);
    }

    m_busylist.insert(Node(vp, nbytes));

    BL_ASSERT(!(vp == 0));

    return vp;
}
开发者ID:dwillcox,项目名称:BoxLib,代码行数:69,代码来源:CArena.cpp


示例17: DBUG_ENTER

int
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
					       const ndb_mgm_configuration 
					       &config)
{
  DBUG_ENTER("Ndb_cluster_connection_impl::init_nodes_vector");
  ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION);
  
  for(iter.first(); iter.valid(); iter.next())
  {
    Uint32 nodeid1, nodeid2, remoteNodeId, group= 5;
    const char * remoteHostName= 0, * localHostName= 0;
    if(iter.get(CFG_CONNECTION_NODE_1, &nodeid1)) continue;
    if(iter.get(CFG_CONNECTION_NODE_2, &nodeid2)) continue;

    if(nodeid1 != nodeid && nodeid2 != nodeid) continue;
    remoteNodeId = (nodeid == nodeid1 ? nodeid2 : nodeid1);

    iter.get(CFG_CONNECTION_GROUP, &group);

    {
      const char * host1= 0, * host2= 0;
      iter.get(CFG_CONNECTION_HOSTNAME_1, &host1);
      iter.get(CFG_CONNECTION_HOSTNAME_2, &host2);
      localHostName  = (nodeid == nodeid1 ? host1 : host2);
      remoteHostName = (nodeid == nodeid1 ? host2 : host1);
    }

    Uint32 type = ~0;
    if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;

    switch(type){
    case CONNECTION_TYPE_SHM:{
      break;
    }
    case CONNECTION_TYPE_SCI:{
      break;
    }
    case CONNECTION_TYPE_TCP:{
      // connecting through localhost
      // check if config_hostname is local
      if (SocketServer::tryBind(0,remoteHostName))
	group--; // upgrade group value
      break;
    }
    }
    if (m_impl.m_all_nodes.push_back(Node(group,remoteNodeId)))
    {
      DBUG_RETURN(-1);
    }
    DBUG_PRINT("info",("saved %d %d", group,remoteNodeId));
    for (int i= m_impl.m_all_nodes.size()-2;
	 i >= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group;
	 i--)
    {
      Node tmp= m_impl.m_all_nodes[i];
      m_impl.m_all_nodes[i]= m_impl.m_all_nodes[i+1];
      m_impl.m_all_nodes[i+1]= tmp;
    }
  }

  int i;
  Uint32 cur_group, i_group= 0;
  cur_group= ~0;
  for (i= (int)m_impl.m_all_nodes.size()-1; i >= 0; i--)
  {
    if (m_impl.m_all_nodes[i].group != cur_group)
    {
      cur_group= m_impl.m_all_nodes[i].group;
      i_group= i+1;
    }
    m_impl.m_all_nodes[i].next_group= i_group;
  }
  cur_group= ~0;
  for (i= 0; i < (int)m_impl.m_all_nodes.size(); i++)
  {
    if (m_impl.m_all_nodes[i].group != cur_group)
    {
      cur_group= m_impl.m_all_nodes[i].group;
      i_group= i;
    }
    m_impl.m_all_nodes[i].this_group= i_group;
  }
#if 0
  for (i= 0; i < (int)m_impl.m_all_nodes.size(); i++)
  {
    fprintf(stderr, "[%d] %d %d %d %d\n",
	   i,
	   m_impl.m_all_nodes[i].id,
	   m_impl.m_all_nodes[i].group,
	   m_impl.m_all_nodes[i].this_group,
	   m_impl.m_all_nodes[i].next_group);
  }

  do_test();
#endif
  DBUG_RETURN(0);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:98,代码来源:ndb_cluster_connection.cpp


示例18:

MSTableColumnGroup &MSTableColumnGroup::operator<<(MSTableColumnGroup &tableColumnGroup_)
{
    if (isOkToAdd(tableColumnGroup_)==MSTrue) _nodeList<<Node(tableColumnGroup_);
    return *this;
}
开发者ID:seanstickle,项目名称:aplus,代码行数:5,代码来源:MSTableColumnGroup.C


示例19: eraseAllProperties

void eraseAllProperties(Tree t)
{
    cerr << "begin eraseAllProperties" << endl;
	eraseProperties(tree(Node(unique("erase_"))), t);
    cerr << "end eraseAllProperties" << endl;
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:6,代码来源:simplify.cpp


示例20: isBoxIdent

bool isBoxIdent(Tree t)				{ return t->node() == Node(gGlobal->BOXIDENT); }
开发者ID:EBone,项目名称:Faust,代码行数:1,代码来源:boxes.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NodePath函数代码示例发布时间:2022-05-30
下一篇:
C++ No_Balise_Packets_reset_InfraLib函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap