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


C++ Renderable::GetVertexBuffer方法代码示例

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


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

示例1: Update

//----------------------------------------------------------------------------
bool SkinController::Update (double applicationTime)
{
	if (!Controller::Update(applicationTime))
	{
		return false;
	}

	// 获得要访问的VertexBuffer
	Renderable* renderable = StaticCast<Renderable>(mObject);
	assertion(mNumVertices == renderable->GetVertexBuffer()->GetNumElements(),
		"Controller must have the same number of vertices as the buffer\n");
	VertexBufferAccessor vba(renderable);

	// skin中的网格的顶点在网格的坐标系(世界坐标系)中。mOffsets记录顶点相对各
	// 个骨骼的位置,左乘骨骼变换矩阵得到该骨骼下的网格坐标系位置。

	renderable->WorldTransform = Transform::IDENTITY;
	renderable->WorldTransformIsCurrent = true;

	// 计算skin顶点位置
	for (int vertex = 0; vertex < mNumVertices; ++vertex)
	{
		APoint position = APoint::ORIGIN;
		for (int bone = 0; bone < mNumBones; ++bone)
		{
			float weight = mWeights[vertex][bone];
			if (weight != 0.0f)
			{
				APoint offset = mOffsets[vertex][bone];
				APoint worldOffset = mBones[bone]->WorldTransform*offset;
				position += weight*worldOffset;
			}
		}
		vba.Position<Float3>(vertex) = position;
	}

	renderable->UpdateModelSpace(Renderable::GU_NORMALS);
	Renderer::UpdateAll(renderable->GetVertexBuffer());
	return true;
}
开发者ID:ascetic85,项目名称:Phoenix3d,代码行数:41,代码来源:PX2SkinController.cpp

示例2: Update

//----------------------------------------------------------------------------
bool SkinController::Update(double applicationTime, double elapsedTime)
{
	if (!Controller::Update(applicationTime, elapsedTime))
	{
		return false;
	}

	// 获得要访问的VertexBuffer
	Renderable* renderable = StaticCast<Renderable>(mObject);
	renderable->WorldTransform = Transform::IDENTITY;
	renderable->WorldTransformIsCurrent = true;
	renderable->IsSkinCtrlSetWroldTrans = true;

	if (mIsUseCPU)
	{
		assertion(mNumVertices == renderable->GetVertexBuffer()->GetNumElements(),
			"Controller must have the same number of vertices as the buffer\n");
		VertexBufferAccessor vba(renderable);

		if (!mOriginPoses)
		{
			mOriginPoses = new1<APoint>(mNumVertices);
			for (int vertex=0; vertex<mNumVertices; ++vertex)
			{
				mOriginPoses[vertex] = vba.Position<Float3>(vertex);
			}
		}

		// skin中的网格的顶点在网格的坐标系(世界坐标系)中。mOffsets记录顶点相对各
		// 个骨骼的位置,左乘骨骼变换矩阵得到该骨骼下的网格坐标系位置。

		// 计算skin顶点位置
		for (int vertex = 0; vertex < mNumVertices; ++vertex)
		{
			APoint position = APoint::ORIGIN;
			for (int bone = 0; bone < mNumBones; ++bone)
			{
				float weight = mWeights[vertex][bone];

				if (weight != 0.0f)
				{
					APoint offset = mOffsets[vertex][bone];
					APoint worldOffset;

					worldOffset = mBones[bone]->WorldTransform*offset;

					position += weight*worldOffset;
				}
			}
			vba.Position<Float3>(vertex) = position;
		}

		//renderable->  (Renderable::GU_NORMALS);
		Renderer::UpdateAll(renderable->GetVertexBuffer());
	}
	else
	{
		for (int bone = 0; bone < mNumBones; ++bone)
		{
			if (mBones[bone])
			{
				const HMatrix &boneMat = mBones[bone]->WorldTransform.Matrix();
				mGPUMatrixs[bone] = boneMat * mTMMatrixs[bone];
			}
		}
	}

	return true;
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:70,代码来源:PX2SkinController.cpp


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