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


C++ Storm3D_Scene::AddPolyCounter方法代码示例

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


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

示例1:

void Storm3D_TerrainLod::render(Storm3D_Scene &scene, int subMask, float range, float rangeX1, float rangeY1, float rangeX2, float rangeY2)
{
	IDirect3DDevice9 &device = *data->storm.GetD3DDevice();

	int lod = data->getLOD(range);

	bool lodX1 = data->getLOD(rangeX1) > lod;
	bool lodY1 = data->getLOD(rangeY1) > lod;
	bool lodX2 = data->getLOD(rangeX2) > lod;
	bool lodY2 = data->getLOD(rangeY2) > lod;

	int index = 0;
	if(lodX1)
		index += 1;
	if(lodX2)
		index += 2;
	if(lodY1)
		index += 4;
	if(lodY2)
		index += 8;

	// Render as whole
	if(subMask == -1)
	{
		LodIndexBuffer &indexBuffer = data->lodBuffers[lod].fullBuffers[index];
		indexBuffer.indexBuffer.render(device, indexBuffer.faceAmount, data->maxVertex);

		scene.AddPolyCounter(indexBuffer.faceAmount);
	}
	else
	{
		LodIndexBuffer &indexBuffer = data->lodBuffers[lod].centerBuffers[subMask];
		indexBuffer.indexBuffer.render(device, indexBuffer.faceAmount, data->maxVertex);

		scene.AddPolyCounter(indexBuffer.faceAmount);

		LodIndexBuffer &linkBuffer = data->lodBuffers[lod].linkBuffers[index];
		linkBuffer.indexBuffer.render(device, linkBuffer.faceAmount, data->maxVertex);

		scene.AddPolyCounter(linkBuffer.faceAmount);
	}
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:42,代码来源:storm3d_terrain_lod.cpp

示例2: renderProjection

	void renderProjection(Storm3D_Scene &scene, Storm3D_Spotlight *spot)
	{
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);

		if(!decals.empty())
		{
			glDepthMask(GL_FALSE);
			glEnable(GL_BLEND);
			glDisable(GL_ALPHA_TEST);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE);

			D3DXMATRIX tm;

			int materialIndex = 0;
			int startIndex = 0;
			int endIndex = 0;

			if(spot->getType() == IStorm3D_Spotlight::Point)
				pointVertexShader.apply();
			else if(spot->getType() == IStorm3D_Spotlight::Directional)
				dirVertexShader.apply();
			else if(spot->getType() == IStorm3D_Spotlight::Flat)
				flatVertexShader.apply();

			vertices.apply(0);
			int prevBindOffs = 0;

			Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);
			Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(0.75f);

			for(;;)
			{
				materialIndex = decals[startIndex]->materialIndex;
				materials[materialIndex].applyProjection(spot->getColorMultiplier());

				int decalAmount = decals.size();
				for(int i = startIndex + 1; i < decalAmount; ++i)
				{
					if(decals[i]->materialIndex != materialIndex)
						break;

					endIndex = i;
				}

				int renderAmount = endIndex - startIndex + 1;

				if (prevBindOffs != startIndex * 4) {
					vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
					prevBindOffs = startIndex * 4;
				}
				indices.render(renderAmount * 2, renderAmount * 4);
				startIndex = ++endIndex;

				scene.AddPolyCounter(renderAmount * 2);
				if(startIndex >= decalAmount)
					break;
			}

			Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(1.f);

			glBlendFunc(GL_ONE, GL_ONE);
			glEnable(GL_BLEND);
		}

		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
	}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:68,代码来源:storm3d_terrain_decalsystem.cpp

示例3: renderShadows


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

		createIndexBuffers();

		int renderAmount = 0;
		if(!shadowDecals.empty())
		{
			IStorm3D_Camera *camera = scene.GetCamera();
			Storm3D_Camera *stormCamera = reinterpret_cast<Storm3D_Camera *> (camera);
			Frustum frustum = stormCamera->getFrustum();

			shadowVertices.create(shadowDecals.size() * 4, VERTEX_SIZE, true);

			int rawSize = shadowDecals.size() * 4 * VERTEX_SIZE;
			void *ramBuffer = malloc(rawSize);
			void *lockPointer = shadowVertices.lock();
			VXFORMAT_DECAL *buffer = reinterpret_cast<VXFORMAT_DECAL *> (ramBuffer);

			float inverseRange =1.f / fogRange;
			for(unsigned int i = 0; i < shadowDecals.size(); ++i)
			{
				const StormDecal &decal = shadowDecals[i];
				Sphere sphere(decal.position, decal.getRadius());
				if(frustum.visibility(sphere))
				{
					float factor = decal.position.y - fogEnd;
					factor *= inverseRange;
					if(factor < 0.f)
						factor = 0.f;
					if(factor > 1.f)
						factor = 1.f;
					factor = 1.f - factor;

					COL color = decal.light;
					color.r += factor * (1.f - color.r);
					color.g += factor * (1.f - color.g);
					color.b += factor * (1.f - color.b);

					DWORD vertexColor = color.GetAsD3DCompatibleARGB() & 0x00FFFFFF;

					DWORD oldColor = decal.vertexColor;
					decal.vertexColor = vertexColor;
					decal.insert(buffer);
					decal.vertexColor = oldColor;

					buffer += 4;
					++renderAmount;
				}
			}

			if(renderAmount)
			{
				if(renderAmount > STORM_MAX_DECAL_AMOUNT)
					renderAmount = STORM_MAX_DECAL_AMOUNT;
				memcpy(lockPointer, ramBuffer, renderAmount * 4 * VERTEX_SIZE);
			}

			free(ramBuffer);
			shadowVertices.unlock();
		}

		D3DXMATRIX tm;

		frozenbyte::storm::VertexShader::disable();
		frozenbyte::storm::PixelShader::disable();
		Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);

		applyFVF(DECAL_FVF, VERTEX_SIZE);
		glActiveTexture(GL_TEXTURE0);
		glClientActiveTexture(GL_TEXTURE0);
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
		glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
		glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
		glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);
		glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PRIMARY_COLOR);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
		glActiveTexture(GL_TEXTURE1);
		glClientActiveTexture(GL_TEXTURE1);
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_TEXTURE_3D);
		glDisable(GL_TEXTURE_CUBE_MAP);

		glDepthMask(GL_FALSE);
		glEnable(GL_BLEND);
		glDisable(GL_ALPHA_TEST);
		glBlendFunc(GL_ZERO, GL_SRC_COLOR);

		if(renderAmount && shadowMaterial)
		{
			shadowVertices.apply(0);
			shadowMaterial->applyShadow();

			indices.render(renderAmount * 2, renderAmount * 4);
			scene.AddPolyCounter(renderAmount * 2);
		}

		glDepthMask(GL_TRUE);
		glDisable(GL_BLEND);
		shadowDecals.clear();
	}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:101,代码来源:storm3d_terrain_decalsystem.cpp

示例4: render

	void render(Storm3D_Scene &scene)
	{
		findDecals(scene);

		createIndexBuffers();
		createVertexBuffers();

		// Render
		if(!decals.empty())
		{
			glDepthMask(GL_FALSE);
			glEnable(GL_BLEND);
			glDisable(GL_ALPHA_TEST);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			D3DXMATRIX tm;

			pixelShader.apply();
			vertexShader.apply();
			vertices.apply(0);
			// ugly HACK!
			int prevBindOffs = 0;
			Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);

			float outfactor[4] = { outFactor.r, outFactor.g, outFactor.b, 1.0f };
			glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 8, outfactor);
			float infactor[4] = { inFactor.r, inFactor.g, inFactor.b, 1.0f };
			glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 9, infactor);

			int materialIndex = 0;
			int startIndex = 0;
			int endIndex = 0;

			for(;;)
			{
				materialIndex = decals[startIndex]->materialIndex;
				materials[materialIndex].apply();

				int decalAmount = decals.size();
				for(int i = startIndex + 1; i < decalAmount; ++i)
				{
					if(decals[i]->materialIndex != materialIndex)
						break;

					endIndex = i;
				}

				int renderAmount = endIndex - startIndex + 1;

				if (prevBindOffs != startIndex * 4) {
					vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
					prevBindOffs = startIndex * 4;
				}
				indices.render(renderAmount * 2, renderAmount * 4);
				startIndex = ++endIndex;

				scene.AddPolyCounter(renderAmount * 2);
				if(startIndex >= decalAmount)
					break;
			}

			glDisable(GL_BLEND);
		}
	}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:64,代码来源:storm3d_terrain_decalsystem.cpp


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