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


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

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


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

示例1: if


//.........这里部分代码省略.........
			WORD*   v      = p->verts;

			plane = Plane(vset->loc[v[0]] + loc,
			vset->loc[v[1]] + loc,
			vset->loc[v[2]] + loc);
		}

		s->Normalize();

		// create continguous segments for each material:
		// sort the polys by material index:
		qsort((void*) s->GetPolys(), s->NumPolys(), sizeof(Poly), mcomp);

		// then assign them to cohesive segments:
		Segment* segment = 0;
		Poly*    spolys  = s->GetPolys();

		for (int n = 0; n < s->NumPolys(); n++) {
			if (segment && segment->material == spolys[n].material) {
				segment->npolys++;
			}
			else {
				segment = 0;
			}

			if (!segment) {
				segment = new(__FILE__,__LINE__) Segment;

				segment->npolys   = 1;
				segment->polys    = &spolys[n];
				segment->material = segment->polys->material;
				segment->model    = model;

				s->GetSegments().append(segment);
			}
		}

		Solid::EnableCollision(false);
		model->AddSurface(s);
		Solid::EnableCollision(true);

		// copy vertex normals:
		const Vec3B* tnorms = terrain->Normals();

		for (i = 0; i < ds1; i++) {
			for (j = 0; j < ds1; j++) {

				if (water) {
					vset->nrm[i*ds1+j] = Point(0,1,0);
				}

				// blend adjacent normals:
				else if (dscale > 1) {
					Point normal;

					// but don't blend more than 16 normals per vertex:
					int step = 1;
					if (dscale > 4)
					step = dscale / 4;

					for (int dy = -dscale/2; dy < dscale/2; dy += step) {
						for (int dx = -dscale/2; dx < dscale/2; dx += step) {
							int ix = rect.x + (ds1-1-j)*dscale + dx;
							int iy = rect.y + i*dscale + dy;

							if (ix < 0)                ix = 0;
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:67,代码来源: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::GetSegments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。