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


C++ SMeshBuffer::getIndexCount方法代码示例

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


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

示例1: drawFrame

void drawFrame()
{
    u32 i,color = 0;
    Matrix4 rotX,rotY;
    Vector4 objEyePos,objLightPos;
    Matrix4 viewMatrix,modelMatrix,modelMatrixIT,modelViewMatrix;
    Point3 lightPos = Point3(250.0f,150.0f,150.0f);
    f32 globalAmbientColor[3] = {0.1f,0.1f,0.1f};
    f32 lightColor[3] = {0.95f,0.95f,0.95f};
    f32 materialColorDiffuse[3] = {0.5f,0.0f,0.0f};
    f32 materialColorSpecular[3] = {0.7f,0.6f,0.6f};
    f32 shininess = 17.8954f;
    static f32 rot = 0.0f;
    SMeshBuffer *mesh = NULL;

    setTexture();
    setDrawEnv();

    rsxSetClearColor(context,color);
    rsxSetClearDepthValue(context,0xffff);
    rsxClearSurface(context,GCM_CLEAR_R |
                    GCM_CLEAR_G |
                    GCM_CLEAR_B |
                    GCM_CLEAR_A |
                    GCM_CLEAR_S |
                    GCM_CLEAR_Z);

    rsxZControl(context,0,1,1);

    for(i=0; i<8; i++)
        rsxSetViewportClip(context,i,display_width,display_height);

    viewMatrix = Matrix4::lookAt(eye_pos,eye_dir,up_vec);

    mesh = sphere;
    rotX = Matrix4::rotationX(DEGTORAD(30.0f));
    rotY = Matrix4::rotationY(DEGTORAD(rot));
    modelMatrix = rotX*rotY;
    modelMatrixIT = inverse(modelMatrix);
    modelViewMatrix = transpose(viewMatrix*modelMatrix);

    objEyePos = modelMatrixIT*eye_pos;
    objLightPos = modelMatrixIT*lightPos;

    wait_signal_spu();

    rsxBindVertexArrayAttrib(context,vertexPosition_id,mesh->pos_off,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);
    rsxBindVertexArrayAttrib(context,vertexNormal_id,mesh->nrm_off,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);
    rsxBindVertexArrayAttrib(context,vertexTexcoord_id,mesh->uv_off,sizeof(S3DVertex),2,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);

    rsxLoadVertexProgram(context,vpo,vp_ucode);
    rsxSetVertexProgramParameter(context,vpo,projMatrix_id,(float*)&P);
    rsxSetVertexProgramParameter(context,vpo,modelViewMatrix_id,(float*)&modelViewMatrix);

    rsxSetFragmentProgramParameter(context,fpo,eyePosition_id,(float*)&objEyePos,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,globalAmbient_id,globalAmbientColor,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,lightPosition_id,(float*)&objLightPos,fp_offset);
    //rsxSetFragmentProgramParameter(context,fpo,lightColor_id,lightColor,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,shininess_id,&shininess,fp_offset);

    rsxSetFragmentProgramParameter(context,fpo,Kd_id,materialColorDiffuse,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,Ks_id,materialColorSpecular,fp_offset);

    rsxLoadFragmentProgramLocation(context,fpo,fp_offset,GCM_LOCATION_RSX);

    rsxSetUserClipPlaneControl(context,GCM_USER_CLIP_PLANE_DISABLE,
                               GCM_USER_CLIP_PLANE_DISABLE,
                               GCM_USER_CLIP_PLANE_DISABLE,
                               GCM_USER_CLIP_PLANE_DISABLE,
                               GCM_USER_CLIP_PLANE_DISABLE,
                               GCM_USER_CLIP_PLANE_DISABLE);

    rsxDrawIndexArray(context,GCM_TYPE_TRIANGLES,mesh->ind_off,mesh->getIndexCount(),GCM_INDEX_TYPE_32B,GCM_LOCATION_RSX);

    mesh = donut;
    rotX = Matrix4::rotationX(DEGTORAD(rot));
    rotY = Matrix4::rotationY(DEGTORAD(30.0f));
    modelMatrix = rotX*rotY;
    modelMatrix.setTranslation(Vector3(3.0f,5.0f,-8.0f));

    modelMatrixIT = inverse(modelMatrix);
    modelViewMatrix = transpose(viewMatrix*modelMatrix);

    objEyePos = modelMatrixIT*eye_pos;
    objLightPos = modelMatrixIT*lightPos;

    rsxBindVertexArrayAttrib(context,vertexPosition_id,mesh->pos_off,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);
    rsxBindVertexArrayAttrib(context,vertexNormal_id,mesh->nrm_off,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);
    rsxBindVertexArrayAttrib(context,vertexTexcoord_id,mesh->uv_off,sizeof(S3DVertex),2,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX);

    rsxLoadVertexProgram(context,vpo,vp_ucode);
    rsxSetVertexProgramParameter(context,vpo,projMatrix_id,(float*)&P);
    rsxSetVertexProgramParameter(context,vpo,modelViewMatrix_id,(float*)&modelViewMatrix);

    rsxSetFragmentProgramParameter(context,fpo,eyePosition_id,(float*)&objEyePos,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,globalAmbient_id,globalAmbientColor,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,lightPosition_id,(float*)&objLightPos,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,lightColor_id,lightColor,fp_offset);
    rsxSetFragmentProgramParameter(context,fpo,shininess_id,&shininess,fp_offset);

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

示例2: crosses


//.........这里部分代码省略.........
        }
    };

    Visitor visitor;
    tree.triangulate(triangles, section, min_height, max_height, &visitor);
    //tree.sweep(triangles, section, &visitor);

   //cout << "num triangle points: " << triangles.size() << endl;

    vector<QuadTreePtr> leaves;
    tree.dumpLeaves(leaves);

    //cout << "num leaves: " << leaves.size() << endl;

/*
    for (QuadTreePtr p1 : leaves)
        for (QuadTreePtr p2 : leaves)
            if (p1 != p2)
                if (p1->isAdjacent(p2))
                    if (!visitor.has(p1, p2))
                    {
                        auto sz1 = p1->region.getSize();
                        auto sz2 = p2->region.getSize();
                        auto c1 = p1->region.getCenter();
                        auto c2 = p2->region.getCenter();
                        char const* path1 = p1->getPath().c_str();
                        char const* path2 = p2->getPath().c_str();
                        cout << path1 << endl;
                        cout << path2 << endl;
                        cout << "Missing pair of adjacent vertices." << endl;
                    }

    float x1 = section.UpperLeftCorner.X;
    float x2 = section.LowerRightCorner.X;
    float y1 = section.UpperLeftCorner.Y;
    float y2 = section.LowerRightCorner.Y;
*/
    /*
        d---c
        | / |
        a---b
    */

    /*
    S3DVertex sa;
    sa.Pos = vector3df(x1, y1, 0);
    PsblVertPtr a = new PossibleVertex(sa);

    S3DVertex sb;
    sb.Pos = vector3df(x2, y1, 0);
    PsblVertPtr b = new PossibleVertex(sb);

    S3DVertex sc;
    sc.Pos = vector3df(x2, y2, 0);
    PsblVertPtr c = new PossibleVertex(sc);

    S3DVertex sd;
    sd.Pos = vector3df(x1, y2, 0);
    PsblVertPtr d = new PossibleVertex(sd);

    // a-b-c
    // a-c-d
    triangles.push_back(a);
    triangles.push_back(b);
    triangles.push_back(c);

    triangles.push_back(a);
    triangles.push_back(c);
    triangles.push_back(d);

    triangles.push_back(c);
    triangles.push_back(b);
    triangles.push_back(a);

    triangles.push_back(d);
    triangles.push_back(c);
    triangles.push_back(a);
    */

	SMeshBuffer* buffer = new SMeshBuffer();

    for (auto pv : triangles)
        pv->addToMeshBuf(buffer, vector3df());

    if (buffer->getIndexCount() % 3 > 0)
        throw std::logic_error("SurfaceQuadTree triangulation added a 'triangle' with less than 3 vertices in it.");

    //cout << "num vertices " << buffer->getVertexCount() << endl;
    //cout << "num indices " << buffer->getIndexCount() << endl;

	buffer->recalculateBoundingBox();
	buffer->setHardwareMappingHint(EHM_STATIC);

	SMesh* mesh = new SMesh();
	mesh->addMeshBuffer(buffer);
	mesh->recalculateBoundingBox();
	buffer->drop();

	return mesh;
}
开发者ID:Habaut,项目名称:GameBindings,代码行数:101,代码来源:HillMesh.cpp


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