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


C++ Surface::SetName方法代码示例

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


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

示例1: if

bool
TerrainPatch::BuildDetailLevel(int level)
{
	int i, j;

	int detail_size = 1 << level;
	int ds1 = detail_size+1;

	if (detail_size > PATCH_SIZE)
	return false;

	Model* model   = new(__FILE__,__LINE__) Model;
	detail_levels[level] = model;

	model->SetLuminous(luminous);
	model->SetDynamic(true);

	const int   NUM_STRIPS        = 4;
	const int   NUM_INDICES_TRI   = 3;
	const int   NUM_INDICES_QUAD  = 6;

	int nverts     = ds1*ds1 + ds1*2*NUM_STRIPS;
	int npolys     = detail_size*detail_size*2;
	int strip_len  = detail_size;
	int total      = npolys + strip_len*NUM_STRIPS;

	if (water) {
		nverts      = ds1*ds1;
		strip_len   = 0;
		total       = npolys;
	}

	Surface*    s     = new(__FILE__,__LINE__) Surface;
	VertexSet*  vset  = 0;

	if (s) {
		s->SetName("default");
		s->CreateVerts(nverts);
		s->CreatePolys(total);
		s->AddIndices(npolys*NUM_INDICES_TRI + strip_len*NUM_STRIPS*NUM_INDICES_QUAD);

		vset = s->GetVertexSet();
		if (!water)
		vset->CreateAdditionalTexCoords();

		ZeroMemory(vset->loc,      nverts * sizeof(Vec3));
		ZeroMemory(vset->diffuse,  nverts * sizeof(DWORD));
		ZeroMemory(vset->specular, nverts * sizeof(DWORD));
		ZeroMemory(vset->tu,       nverts * sizeof(float));
		ZeroMemory(vset->tv,       nverts * sizeof(float));
		if (!water) {
			ZeroMemory(vset->tu1,      nverts * sizeof(float));
			ZeroMemory(vset->tv1,      nverts * sizeof(float));
		}
		ZeroMemory(vset->rw,       nverts * sizeof(float));

		// initialize vertices
		Vec3*  pVert   = vset->loc;
		float* pTu     = vset->tu;
		float* pTv     = vset->tv;
		float* pTu1    = vset->tu1;
		float* pTv1    = vset->tv1;
		DWORD* pSpec   = vset->specular;

		int    dscale  = (PATCH_SIZE-1)/detail_size;
		double dt      = 0.0625 / (ds1-1); // terrain texture scale
		double dtt     = 2.0000 / (ds1-1); // tile texture scale
		double tu0     = (double) rect.x / rect.w / 16.0 + 1.0/16.0;
		double tv0     = (double) rect.y / rect.h / 16.0;

		// surface verts
		for (i = 0; i < ds1; i++) {
			for (j = 0; j < ds1; j++) {
				*pVert   = Vec3((float) (j* scale * dscale - (HALF_PATCH_SIZE*scale)),
				(float) (heights[i*dscale*PATCH_SIZE + j*dscale]),
				(float) (i* scale * dscale - (HALF_PATCH_SIZE*scale)));

				if (level >= 2) {
					*pTu++   = (float) (-j*dtt);
					*pTv++   = (float) ( i*dtt);

					if (level >= 4 && !water) {
						*pTu1++  = (float) (-j*dtt*3);
						*pTv1++  = (float) ( i*dtt*3);
					}

					*pSpec++ = BlendValue(pVert->y);
				}

				else {
					*pTu++   = (float) (tu0 - j*dt);
					*pTv++   = (float) (tv0 + i*dt);
				}

				pVert++;
			}
		}

		if (!water) {
			// strip 1 & 2 verts
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:TerrainPatch.cpp

示例2: new

void
Hoop::CreatePolys()
{
    Material* mtl = new(__FILE__,__LINE__) Material;

    mtl->tex_diffuse   = hoop_texture;
    mtl->blend         = Material::MTL_ADDITIVE;

    int w = width /2;
    int h = height/2;

    model     = new(__FILE__,__LINE__) Model;
    own_model = 1;

    Surface* surface = new(__FILE__,__LINE__) Surface;

    surface->SetName("hoop");
    surface->CreateVerts(4);
    surface->CreatePolys(2);

    VertexSet*  vset  = surface->GetVertexSet();
    Poly*       polys = surface->GetPolys();

    ZeroMemory(polys, sizeof(Poly) * 2);

    for (int i = 0; i < 4; i++) {
        int   x = w;
        int   y = h;
        float u = 0;
        float v = 0;

        if (i == 0 || i == 3)
        x = -x;
        else
        u = 1;

        if (i < 2)
        y = -y;
        else
        v = 1;

        vset->loc[i]   = Vec3(x, y, 0);
        vset->nrm[i]   = Vec3(0, 0, 0);

        vset->tu[i]    = u;
        vset->tv[i]    = v;
    }

    for (int i = 0; i < 2; i++) {
        Poly& poly        = polys[i];

        poly.nverts       = 4;
        poly.vertex_set   = vset;
        poly.material     = mtl;

        poly.verts[0]     = i ? 3 : 0;
        poly.verts[1]     = i ? 2 : 1;
        poly.verts[2]     = i ? 1 : 2;
        poly.verts[3]     = i ? 0 : 3;

        poly.plane        = Plane(vset->loc[poly.verts[0]],
        vset->loc[poly.verts[2]],
        vset->loc[poly.verts[1]]);

        surface->AddIndices(6);
    }

    // then assign them to cohesive segments:
    Segment* segment = new(__FILE__,__LINE__) Segment;
    segment->npolys   = 2;
    segment->polys    = &polys[0];
    segment->material = segment->polys->material;

    surface->GetSegments().append(segment);

    model->AddSurface(surface);


    SetLuminous(true);
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:80,代码来源:Hoop.cpp


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