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


C++ CreateMesh函数代码示例

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


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

示例1: Load

void Load() {
 /* Load shader */
 char shaderName_vsh[] = "Shader.vsh";
 char shaderName_fsh[] = "Shader.fsh";
 CompileShader(&g_Shader, shaderName_vsh, shaderName_fsh);
 
 /* Load mesh */
 CreateMesh(&g_Mesh[0], kCommonMesh_Cube);
 CreateMesh(&g_Mesh[1], kCommonMesh_Square);
 
 // Cube
 g_Cube.mesh = &g_Mesh[0];
 DefaultTransform(&g_Cube.transform);
 g_Cube.transform.position.z = 40.0f;
 g_Cube.transform.axis = GLKVector3Make(0.0f, 1.0f, 0.0f);
 //g_Cube.transform.scale = GLKVector3Make(10.0f, 10.0f, 10.0f);
 g_Cube.transform.angle = 0.0f;
 g_Cube.transform.parent = &g_WorldTrans;
 g_Cube.color = GLKVector4Make(0.4f, 0.6f, 0.7f, 0.8f);
 
 // Mask
 g_Mask.mesh = &g_Mesh[1];
 DefaultTransform(&g_Mask.transform);
 g_Mask.transform.position = GLKVector3Make(0.0f, 2.0f, 40.0f);
 g_Mask.transform.axis = GLKVector3Make(1.0f, 0.0f, 0.0f);
 g_Mask.transform.angle = 90.0f;
 g_Mask.transform.scale = GLKVector3Make(2.0f, 2.0f, 1.0f);
 g_Mask.transform.parent = &g_WorldTrans;
 g_Mask.color = GLKVector4Make(0.0f, 0.0f, 0.0f, 0.8f);
 
 /* Set gl states */
 glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
 glEnable(GL_DEPTH_TEST);
}
开发者ID:chunkyguy,项目名称:EWOGL,代码行数:34,代码来源:Loop.c

示例2: main

int main(int argc, char **argv)
{
  MPI_Comm       comm;
  DM             dm;
  AppCtx         options;
  PetscErrorCode ierr;

  ierr = PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
  comm = PETSC_COMM_WORLD;
  ierr = ProcessOptions(comm, &options);CHKERRQ(ierr);
  ierr = CreateMesh(comm, &options, &dm);CHKERRQ(ierr);

  switch (options.test) {
    case 0: ierr = test0(dm, &options);CHKERRQ(ierr); break;
    case 1: ierr = test1(dm, &options);CHKERRQ(ierr); break;
    case 2: ierr = test2(dm, &options);CHKERRQ(ierr); break;
    case 3: ierr = test3(dm, &options);CHKERRQ(ierr); break;
    case 4: ierr = test4(dm, &options);CHKERRQ(ierr); break;
    case 5: ierr = test5(dm, &options);CHKERRQ(ierr); break;
    case 6: ierr = test6(dm, &options);CHKERRQ(ierr); break;
    case 7: ierr = test7(dm, &options);CHKERRQ(ierr); break;
    case 8: ierr = test8(dm, &options);CHKERRQ(ierr); break;
    default: SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "No such test: %D", options.test);
  }

  ierr = DMDestroy(&dm);CHKERRQ(ierr);
  ierr = PetscFinalize();
  return ierr;
}
开发者ID:firedrakeproject,项目名称:petsc,代码行数:29,代码来源:ex25.c

示例3: main

int main(int argc, char **argv)
{
  DM             dm;   /* Problem specification */
  SNES           snes; /* Nonlinear solver */
  Vec            u;    /* Solutions */
  AppCtx         user; /* User-defined work context */
  PetscErrorCode ierr;

  ierr = PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
  ierr = ProcessOptions(PETSC_COMM_WORLD, &user);CHKERRQ(ierr);
  /* Primal system */
  ierr = SNESCreate(PETSC_COMM_WORLD, &snes);CHKERRQ(ierr);
  ierr = CreateMesh(PETSC_COMM_WORLD, &user, &dm);CHKERRQ(ierr);
  ierr = SNESSetDM(snes, dm);CHKERRQ(ierr);
  ierr = SetupFE(dm, user.dim, user.simplex, "displacement", SetupPrimalProblem, &user);CHKERRQ(ierr);
  ierr = DMCreateGlobalVector(dm, &u);CHKERRQ(ierr);
  ierr = VecSet(u, 0.0);CHKERRQ(ierr);
  ierr = PetscObjectSetName((PetscObject) u, "displacement");CHKERRQ(ierr);
  ierr = DMPlexSetSNESLocalFEM(dm, &user, &user, &user);CHKERRQ(ierr);
  ierr = SNESSetFromOptions(snes);CHKERRQ(ierr);
  ierr = DMSNESCheckFromOptions(snes, u, NULL, NULL);CHKERRQ(ierr);
  ierr = SNESSolve(snes, NULL, u);CHKERRQ(ierr);
  ierr = SNESGetSolution(snes, &u);CHKERRQ(ierr);
  ierr = VecViewFromOptions(u, NULL, "-displacement_view");CHKERRQ(ierr);
  /* Cleanup */
  ierr = VecDestroy(&u);CHKERRQ(ierr);
  ierr = SNESDestroy(&snes);CHKERRQ(ierr);
  ierr = DMDestroy(&dm);CHKERRQ(ierr);
  ierr = PetscFinalize();
  return ierr;
}
开发者ID:firedrakeproject,项目名称:petsc,代码行数:31,代码来源:ex17.c

示例4: fopen

    sint CRenderer::LoadMesh( const char* szFilename )
    {        
        /********************* File Format ***********************\
        float   fVertexSize
        float   fVertexCount
        uint    nIndexSize
        uint    nIndexCount
        float   fVerts[]
        uint    nIndices[]
        \*********************************************************/
        uint nVertexStride;
        uint nVertexCount; 
        uint nIndexSize; 
        uint nIndexCount; 
        byte* pData;
    
        FILE* pFile = fopen( szFilename, "rb" );
        fread( &nVertexStride, sizeof( nVertexStride ), 1, pFile );
        fread( &nVertexCount, sizeof( nVertexCount ), 1, pFile );
        fread( &nIndexSize, sizeof( nIndexSize ), 1, pFile );
        nIndexSize = (nIndexSize == 32 ) ? 4 : 2;
        fread( &nIndexCount, sizeof( nIndexCount ), 1, pFile );

        pData   = new byte[ (nVertexStride * nVertexCount) + (nIndexCount * nIndexSize) ];

        fread( pData, nVertexStride, nVertexCount, pFile );
        fread( pData + (nVertexStride * nVertexCount), nIndexSize, nIndexCount, pFile );
        fclose( pFile );

        sint nMesh = CreateMesh( nVertexStride, nVertexCount, nIndexSize, nIndexCount, pData, pData + (nVertexStride * nVertexCount) );
        
        delete [] pData;
        
        return nMesh;
    }
开发者ID:10n1,项目名称:RiotPrototype,代码行数:35,代码来源:Renderer.cpp

示例5: CreateMesh

class FMesh* FPrimitiveBuilder::GenerateDisc(int SubdivisionNumber, class FTexture* Texture, const glm::mat4& Transform, const glm::vec4& Colour /*= glm::vec4(1.0f)*/)
{
	FMesh* Mesh = CreateMesh(Texture, Colour);

	const float kHalfCubeSize = 0.5f;
	float Theta = 0.0f;
	float DeltaTheta = (float) ((2 * M_PI) / SubdivisionNumber);
	for (int i = 0; i < SubdivisionNumber; i++)
	{
		float PreviousTheta = Theta;
		Theta += DeltaTheta;

		glm::vec3 Positions[3] = 
		{
			glm::vec3(cos(PreviousTheta), sin(PreviousTheta), 0.0f),
			glm::vec3(0.0f, 0.0f, 0.0f),
			glm::vec3(cos(Theta), sin(Theta), 0.0f)
		};

		glm::vec3 Normal(0.0f, 0.0f, 1.0f);

		for (int k = 0; k < 3; k++)
		{
			Mesh->AddVertexData(Positions[k], Normal, glm::vec2(Positions[k].x * 0.5f + 0.5f, Positions[k].y * 0.5f + 0.5f));
		}
	}

	Mesh->TransformVertices(Transform);
	return Mesh;
}
开发者ID:subr3v,项目名称:2nd-Year-University-Projects,代码行数:30,代码来源:PrimitiveBuilder.cpp

示例6: RegisterComponent

    /*!
    * @brief Initilize everything SDL needs at the start
    */
    void GLGraphics::Init(void) //Initilize SDL
    {
      // Register the components needed for graphics.
      RegisterComponent(MC_Transform);
      RegisterComponent(MC_Sprite);

      CreateMesh();

      // Create the default shader.
      ShaderPtr defaultShader(new GLShader());

      // Load the shader files for the default shader.
      defaultShader->LoadShaderFile("dvert.glsl", "dfrag.glsl", 0);

      // Compile the shaders.
      defaultShader->Compile();

      // Find the variables in the shaders that will be modified by the end-users.
      defaultShader->FindUniforms("model");
      defaultShader->FindUniforms("view");
      defaultShader->FindUniforms("proj");
      defaultShader->FindUniforms("color");
      
      

      // Add the shader to the ShaderMap.
      addShader("Box", defaultShader);

    }
开发者ID:JohannesMP,项目名称:AlJeEngine,代码行数:32,代码来源:GLGraphics.cpp

示例7: CreateScene

bool CreateScene(KFbxSdkManager *pSdkManager, KFbxScene* pScene)
{
    // create scene info
    KFbxDocumentInfo* sceneInfo = KFbxDocumentInfo::Create(pSdkManager,"SceneInfo");
    sceneInfo->mTitle = "Mesh";
    sceneInfo->mSubject = "Mesh thing";
    sceneInfo->mAuthor = "Team opennirospcleigenubuntuvmware";
    sceneInfo->mRevision = "0.1";
    sceneInfo->mKeywords = "mesh";
    sceneInfo->mComment = "none";

    // we need to add the sceneInfo before calling AddThumbNailToScene because
    // that function is asking the scene for the sceneInfo.
    pScene->SetSceneInfo(sceneInfo);

    KFbxNode* lPatch = CreateMesh(pScene, "Patch");
    KFbxNode* lSkeletonRoot = CreateSkeleton(pScene, "Skeleton");


    // Build the node tree.
    KFbxNode* lRootNode = pScene->GetRootNode();
    lRootNode->AddChild(lPatch);
    lRootNode->AddChild(lSkeletonRoot);

/*
	// Store poses
    LinkPatchToSkeleton(pScene, lPatch, lSkeletonRoot);
    StoreBindPose(pScene, lPatch, lSkeletonRoot);
    StoreRestPose(pScene, lSkeletonRoot);

	// Animation
    AnimateSkeleton(pScene, lSkeletonRoot);
*/
    return true;
}
开发者ID:gimlids,项目名称:BodyScanner,代码行数:35,代码来源:MakeMesh.cpp

示例8: main

int main() {

    Window window;
    Camera camera(window.GetAspectRatio(), glm::vec3(2.0, 2.0, 1.0));
    Mesh* sphereMesh = CreateMesh("sphere.obj", "sphere");
    Shader defaultShader("Shaders/defaultShader.vert", "Shaders/defaultShader.frag", "defaultShader");
    SetupMesh(sphereMesh, defaultShader);
    do {
        window.Clear();

        DrawMesh(*sphereMesh, camera, defaultShader);
        camera.front = sphereMesh->position;
        sphereMesh->rotY -= 0.016;
        {
            if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_W) == GLFW_PRESS) {
                sphereMesh->position.x -= 0.16;
            }
            else if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_S) == GLFW_PRESS) {
                sphereMesh->position.x += 0.16;
            }
            if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_A) == GLFW_PRESS) {
                sphereMesh->position.z += 0.16;
            }
            else if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_D) == GLFW_PRESS) {
                sphereMesh->position.z -= 0.16;
            }
        }
        window.Update();
    } while (!window.Closed() && glfwGetKey(window.GetWindowInstance(), GLFW_KEY_ESCAPE) != GLFW_PRESS);
    delete sphereMesh;
}
开发者ID:Raf22,项目名称:Snow,代码行数:31,代码来源:main.cpp

示例9: CreateMesh

    sint CRenderer::CreateMesh( void )
    {
        // If the cube has already been created, return it
        if( m_nDefaultMesh != INVALID_HANDLE )
        {
            return m_nDefaultMesh;
        }

        //////////////////////////////////////////
        // Define the index buffer
        uint16 indices[] =
        {
            3,1,0,
            2,1,3,

            6,4,5,
            7,4,6,

            11,9,8,
            10,9,11,

            14,12,13,
            15,12,14,

            19,17,16,
            18,17,19,

            22,20,21,
            23,20,22
        };

        m_nDefaultMesh = CreateMesh( VPosNormalTex::VertexStride, 24, sizeof(uint16), ARRAY_LENGTH( indices ), GetDefaultMeshData(), indices, GFX_BUFFER_USAGE_IMMUTABLE );

        return m_nDefaultMesh;
    }
开发者ID:10n1,项目名称:RiotPrototype,代码行数:35,代码来源:Renderer.cpp

示例10: PezInitialize

const char* PezInitialize(int width, int height)
{
    BuddhaMesh = CreateMesh("buddha.ctm");
    QuadVbo = CreateQuad(-1, -1, 1, 1);
    
#ifdef LIGHTING
    DepthProgram = CreateProgram("Glass.Vertex", "Glass.Fragment.Lighting" SUFFIX);
    AbsorptionProgram = CreateProgram("Glass.Vertex.Quad", "Glass.Fragment.Blit" SUFFIX);
#else
    DepthProgram = CreateProgram("Glass.Vertex", "Glass.Fragment.Depth" SUFFIX);
    AbsorptionProgram = CreateProgram("Glass.Vertex.Quad", "Glass.Fragment.Absorption" SUFFIX);
#endif

    // Create a floating-point render target:
    GLuint textureHandle;
    glGenTextures(1, &textureHandle);
    glBindTexture(GL_TEXTURE_2D, textureHandle);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    
#ifdef LIGHTING
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 768, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
#elif defined(__IPAD__)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 768, 1024, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, 0);
#else
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, 768, 1024, 0, GL_RG, GL_FLOAT, 0);
#endif
    
    PezCheckCondition(GL_NO_ERROR == glGetError(), "This passes on Mac OS X and iOS.");
    OffscreenTexture = textureHandle;
    
    GLuint fboHandle;
    glGenFramebuffers(1, &fboHandle);
    glBindFramebuffer(GL_FRAMEBUFFER, fboHandle);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureHandle, 0);

#ifdef LIGHTING
    GLuint depthRenderbuffer;
    glGenRenderbuffers(1, &depthRenderbuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
#endif

    PezCheckCondition(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER), "This asserts on iOS and passes on Mac OS X.");
    OffscreenFbo = fboHandle;

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glBindRenderbuffer(GL_RENDERBUFFER, 0);
    
    // Set up the projection matrix:
    const float HalfWidth = 0.5;
    const float HalfHeight = HalfWidth * PEZ_VIEWPORT_HEIGHT / PEZ_VIEWPORT_WIDTH;
    ProjectionMatrix = M4MakeFrustum(-HalfWidth, +HalfWidth, -HalfHeight, +HalfHeight, 5, 20);

    return "Glass Demo";
}
开发者ID:jsj2008,项目名称:blog-source,代码行数:59,代码来源:Glass.c

示例11: CreateMesh

csPtr<iMeshWrapper> GeneralMeshBuilder::CreateMesh (
	iEngine* engine, iSector* sector, const char* name,
	const char* factoryname)
{
  iMeshFactoryWrapper* factory = engine->FindMeshFactory (factoryname);
  if (!factory) return 0;
  return CreateMesh (engine, sector, name, factory);
}
开发者ID:garinh,项目名称:cs,代码行数:8,代码来源:genmeshbuilder.cpp

示例12: CreateMesh

void Engine1D::StartSimulation(Mesh1D &mesh)
{
	this->number_of_states = this->time_length / this->time_step;
	CreateMesh(mesh);
	this->CreateTime();
	this->CreateInitialState(mesh);
	this->Solve(mesh);
}
开发者ID:ThomasThelen,项目名称:Numerical-Methods,代码行数:8,代码来源:FDMEngine.cpp

示例13: strcpy

void TextureText::SetString(const char* str)
{
	strcpy(text, str);
	//strcpy(text,TEX_TEXT_MAX_STRING_LENGTH,str);
	GenerateLetters();
	CreateMesh();

}
开发者ID:kristofe,项目名称:VolumeRenderer,代码行数:8,代码来源:TextureText.cpp

示例14: CreateSolidPlane

Mesh* CreateSolidPlane(float xSize, float zSize, int xSegments, int zSegments, const glm::mat4& transform)
{
    int numVertices = (xSegments + 1) * (zSegments + 1);

    std::vector<VertexPositionNormal> vertexData(numVertices);

    float xStep = xSize / xSegments;
    float zStep = zSize / zSegments;

    VertexPositionNormal* vertexPtr = &vertexData[0];

    float z = -0.5f * zSize;
    for (int j = 0; j <= zSegments; j++) {
        float x = -0.5f * xSize;
        for (int i = 0; i <= xSegments; i++) {
            vertexPtr->pos.x = x;
            vertexPtr->pos.y = 0;
            vertexPtr->pos.z = z;
            vertexPtr->normal.x = 0;
            vertexPtr->normal.y = 1;
            vertexPtr->normal.z = 0;
            ++vertexPtr;
            x += xStep;
        }
        z += zStep;
    }

    int numTriangles = 2 * xSegments * zSegments;

    int numElements = 3 * numTriangles;
    std::vector<unsigned> indexData(numElements);   // use 32-bit indices for large planes!!!11!!!

    unsigned* indexPtr = &indexData[0];
    unsigned e = 0;
    for (int j = 0; j < zSegments; j++) {
        for (int i = 0; i < xSegments; i++) {
            // the four corners of this "square"
            unsigned e = (xSegments + 1) * j + i;
            unsigned e1 = e;
            unsigned e2 = e + 1;
            unsigned e3 = e + xSegments + 1;
            unsigned e4 = e + xSegments + 2;
            // triangle 1
            *indexPtr++ = e1;
            *indexPtr++ = e3;
            *indexPtr++ = e4;
            // triangle 2
            *indexPtr++ = e1;
            *indexPtr++ = e4;
            *indexPtr++ = e2;
            ++e;
        }
        ++e;
    }

    return CreateMesh(GL_TRIANGLES, vertexData, indexData);
}
开发者ID:Mertank,项目名称:md5-anim,代码行数:57,代码来源:GLSH_Prefabs.cpp

示例15: CreateMesh

// Rebuild
void Chunk::RebuildMesh()
{
	m_isRebuildingMesh = true;
	if (m_pMesh != NULL)
	{
		m_pRenderer->ClearMesh(m_pMesh);
		m_pMesh = NULL;
	}

	CreateMesh();

	// Update our wall flags, so that our neighbors can check if they are surrounded
	UpdateWallFlags();
	UpdateSurroundedFlag();

	Chunk* pChunkXMinus = m_pChunkManager->GetChunk(m_gridX - 1, m_gridY, m_gridZ);
	Chunk* pChunkXPlus = m_pChunkManager->GetChunk(m_gridX + 1, m_gridY, m_gridZ);
	Chunk* pChunkYMinus = m_pChunkManager->GetChunk(m_gridX, m_gridY - 1, m_gridZ);
	Chunk* pChunkYPlus = m_pChunkManager->GetChunk(m_gridX, m_gridY + 1, m_gridZ);
	Chunk* pChunkZMinus = m_pChunkManager->GetChunk(m_gridX, m_gridY, m_gridZ - 1);
	Chunk* pChunkZPlus = m_pChunkManager->GetChunk(m_gridX, m_gridY, m_gridZ + 1);

	if (pChunkXMinus != NULL && pChunkXMinus->IsSetup() == true)
		pChunkXMinus->UpdateSurroundedFlag();
	if (pChunkXPlus != NULL && pChunkXPlus->IsSetup() == true)
		pChunkXPlus->UpdateSurroundedFlag();
	if (pChunkYMinus != NULL && pChunkYMinus->IsSetup() == true)
		pChunkYMinus->UpdateSurroundedFlag();
	if (pChunkYPlus != NULL && pChunkYPlus->IsSetup() == true)
		pChunkYPlus->UpdateSurroundedFlag();
	if (pChunkZMinus != NULL && pChunkZMinus->IsSetup() == true)
		pChunkZMinus->UpdateSurroundedFlag();
	if (pChunkZPlus != NULL && pChunkZPlus->IsSetup() == true)
		pChunkZPlus->UpdateSurroundedFlag();

	// Rebuild neighbours
	if (m_rebuildNeighours)
	{
		if (pChunkXMinus != NULL && pChunkXMinus->IsSetup() == true)
			pChunkXMinus->SetNeedsRebuild(true, false);
		if (pChunkXPlus != NULL && pChunkXPlus->IsSetup() == true)
			pChunkXPlus->SetNeedsRebuild(true, false);
		if (pChunkYMinus != NULL && pChunkYMinus->IsSetup() == true)
			pChunkYMinus->SetNeedsRebuild(true, false);
		if (pChunkYPlus != NULL && pChunkYPlus->IsSetup() == true)
			pChunkYPlus->SetNeedsRebuild(true, false);
		if (pChunkZMinus != NULL && pChunkZMinus->IsSetup() == true)
			pChunkZMinus->SetNeedsRebuild(true, false);
		if (pChunkZPlus != NULL && pChunkZPlus->IsSetup() == true)
			pChunkZPlus->SetNeedsRebuild(true, false);

		m_rebuildNeighours = false;
	}

	m_numRebuilds++;
	m_rebuild = false;
}
开发者ID:CodeMason,项目名称:Vox,代码行数:58,代码来源:Chunk.cpp


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