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


C++ TriMesh::SetMaterialInstance方法代码示例

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


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

示例1: SetAreaType

//----------------------------------------------------------------------------
void TriggerActor::SetAreaType(AreaType type)
{
	mAreaType = type;

	CreateGetHelpNode()->DetachChild(mAreaMovable);

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
	if (AT_SPHERE == mAreaType)
	{
		StandardMesh stdMesh(vf);
		stdMesh.SetVertexColor(Float4(1.0f, 1.0f, 0.0f, 1.0f));
		TriMesh *mesh = stdMesh.Sphere(16, 16, 1.0f);
		VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
		mtl->GetWireProperty(0, 0)->Enabled = true;
		mtl->GetCullProperty(0, 0)->Enabled = false;
		mesh->LocalTransform.SetUniformScale(0.5f);
		mesh->SetMaterialInstance(mtl->CreateInstance());
		mAreaMovable = mesh;
	}
	else if (AT_BOX == mAreaType)
	{
		StandardMesh stdMesh(vf);
		stdMesh.SetVertexColor(Float4(1.0f, 1.0f, 0.0f, 1.0f));
		TriMesh *mesh = stdMesh.Box(1, 1, 1);
		VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
		mtl->GetWireProperty(0, 0)->Enabled = true;
		mtl->GetCullProperty(0, 0)->Enabled = false;
		mesh->LocalTransform.SetUniformScale(0.5f);
		mesh->SetMaterialInstance(mtl->CreateInstance());
		mAreaMovable = mesh;
	}

	CreateGetHelpNode()->AttachChild(mAreaMovable);
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:35,代码来源:PX2TriggerActor.cpp

示例2: CreateSphere

//----------------------------------------------------------------------------
void EditMap::CreateSphere (PX2::APoint pos)
{
	PX2::Texture2D *tex = DynamicCast<PX2::Texture2D>(
		ResourceManager::GetSingleton().BlockLoad("ToolRes/images/default.png"));
	if (!tex)
		return;

	StandardMesh stdMesh(mVertexFormat);
	TriMesh *mesh = stdMesh.Sphere(16, 16, 1);
	mesh->SetName("NoName");

	//Texture2DMaterialPtr material = new0 Texture2DMaterial;
	//mesh->SetMaterialInstance(material->CreateInstance(tex));

	StandardESMaterial_DefaultPtr mtl = new0 StandardESMaterial_Default();
	mesh->SetMaterialInstance(mtl->CreateInstance(tex, 0 ,0));

	ActorPtr actor = new0 Actor();
	actor->SetName("NoName");
	actor->SetMovable(mesh);
	actor->SetPosition(pos);
	actor->ComeInToEventWorld();

	AddActor(actor);

	ActorAddDeleteCommand *command = new0 ActorAddDeleteCommand(actor);
	EditSystem::GetSingleton().GetCM()->PushUnDo(command);
}
开发者ID:manyxu,项目名称:Phoenix3D_2.0,代码行数:29,代码来源:PX2EditMap.cpp

示例3: stdMesh

//----------------------------------------------------------------------------
Character::Character() :
mAnimType(AT_SKELETON),
mDefaultAnimID(0),
mBaseHPCurLevel(0.0f),
mIsDieDoDelete(true),
mBaseAPCurLevel(0.0f),
mIsDead(false),
mIsMovableAutoWorldBound(true),
mMovableAutoWorldBoundRadius(2.0f)
{
	SetName("Chara");

	PX2_INIT_PM_F(HP);
	PX2_INIT_PM_F(AP);

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
	StandardMesh stdMesh(vf);
	stdMesh.SetVertexColor(Float4(1.0f, 0.0f, 0.0f, 1.0f));
	TriMesh *mesh = stdMesh.Box(0.5f, 0.5f, 0.5f);
	PX2::VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
	mtl->GetWireProperty(0, 0)->Enabled = true;
	mtl->GetCullProperty(0, 0)->Enabled = false;
	mesh->LocalTransform.SetUniformScale(0.5f);
	mesh->SetMaterialInstance(mtl->CreateInstance());
	CreateGetHelpNode()->DetachAllChildren();
	CreateGetHelpNode()->AttachChild(mesh);
	CreateGetHelpNode()->SetParentTransformIngore(false, false, true);
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:29,代码来源:PX2Character.cpp

示例4: CreateSphere

//----------------------------------------------------------------------------
void EditMap::CreateSphere (PX2::APoint pos)
{
	PX2::Texture2D *tex = DynamicCast<PX2::Texture2D>(
		ResourceManager::GetSingleton().BlockLoad("ToolRes/images/default.png"));
	if (!tex)
		return;

	StandardMesh stdMesh(mVertexFormat);
	TriMesh *mesh = stdMesh.Sphere(16, 16, 1);
	mesh->SetName("NoName");

	Texture2DMaterialPtr material = new0 Texture2DMaterial;
	mesh->SetMaterialInstance(material->CreateInstance(tex));

	ActorPtr actor = new0 Actor();
	actor->SetName("NoName");
	actor->SetMovable(mesh);
	actor->SetPosition(pos);
	actor->ComeInToEventWorld();

	AddActor(actor);

	Event *event = 0;
	event = EditorEventSpace::CreateEventX
		(EditorEventSpace::AddActor);
	event->SetData<Actor*>(actor);
	EventWorld::GetSingleton().BroadcastingLocalEvent(event);

	ActorAddDeleteCommand *command = new0 ActorAddDeleteCommand(actor);
	EditSystem::GetSingleton().GetCM()->PushUnDo(command);
}
开发者ID:ascetic85,项目名称:Phoenix3d,代码行数:32,代码来源:PX2EditMap.cpp

示例5: stdMesh

//----------------------------------------------------------------------------
LightActor::LightActor ()
	:
mLightType(LT_POINT),
mRange(2.0f),
mColor(Float3::MakeColor(128, 128, 128))
{
	mLight = new0 Light(Light::LT_POINT);
	LightNode *lightNode = new0 LightNode(mLight);
	SetMovable(lightNode);

	VertexFormat *vf = VertexFormat::Create(3,
		VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
		VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0,
		VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);

	Node *helpNode = new0 Node ();

	PX2::VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
	mtl->GetWireProperty(0, 0)->Enabled = true;
	mtl->GetCullProperty(0, 0)->Enabled = false;
	MaterialInstancePtr mtlInst = mtl->CreateInstance();

	StandardMesh stdMesh(vf);
	stdMesh.SetVertexColor(Float4(0.0f,1.0f,0.0f,1.0f));

	TriMesh *mesh = stdMesh.Octahedron();
	mesh->LocalTransform.SetUniformScale(0.5f);
	mesh->SetMaterialInstance(mtlInst);
	helpNode->AttachChild(mesh);

	TriMesh *box = stdMesh.Box(0.005f, 0.005f, 5.0f);
	box->LocalTransform.SetTranslate(APoint(0.0f, 0.0f, -5.5f));
	box->SetMaterialInstance(mtlInst);
	helpNode->AttachChild(box);

	SetHelpMovable(helpNode);
	ShowHelpMovable(true);

	SetColor(mColor);
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:41,代码来源:PX2LightActor.cpp

示例6: stdMesh

//----------------------------------------------------------------------------
LightActor::LightActor()
{
	SetName("LightActor");

	mLight = new0 Light(Light::LT_POINT);
	mLightNode = new0 LightNode(mLight);
	SetMovable(mLightNode);

	Node *helpNode = new0 Node();

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);

	PX2::VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
	mtl->GetWireProperty(0, 0)->Enabled = true;
	mtl->GetCullProperty(0, 0)->Enabled = false;
	MaterialInstancePtr mtlInst = mtl->CreateInstance();

	StandardMesh stdMesh(vf);
	stdMesh.SetVertexColor(Float4(1.0f, 1.0f, 0.0f, 1.0f));

	TriMesh *mesh = stdMesh.Octahedron();
	mesh->LocalTransform.SetUniformScale(0.5f);
	mesh->SetMaterialInstance(mtlInst);
	helpNode->AttachChild(mesh);

	TriMesh *box = stdMesh.Box(0.005f, 0.005f, 5.0f);
	box->LocalTransform.SetTranslate(APoint(0.0f, 0.0f, -5.5f));
	box->SetMaterialInstance(mtlInst);
	helpNode->AttachChild(box);

	CreateGetHelpNode()->AttachChild(helpNode);
	CreateGetHelpNode()->SetParentTransformIngore(false, false, true);

	WorldBoundIsCurrent = true;
	SetRadius(1.0f);
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:37,代码来源:PX2LightActor.cpp

示例7: stdMesh

//----------------------------------------------------------------------------
PX2::Node *GeoObjFactory::CreateScaleCtrl_O()
{
	// node
	PX2::Node *node = new0 Node;
	node->LocalTransform.SetUniformScale(2.0f);
	node->SetName("Scale");

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
	StandardMesh stdMesh(vf);
	VertexBuffer *vBufferTemp = 0;
	VertexBufferAccessor vbaTemp;

	// x
	PX2::Node *nodeX = new0 Node;
	nodeX->SetName("Scale_X");

	VertexBuffer *vBufferX = new0 VertexBuffer(6, vf->GetStride());
	VertexBufferAccessor vbaX(vf, vBufferX);

	vbaX.Position<Float3>(0) = Float3(0.25f, 0.0f, 0.0f);
	vbaX.Position<Float3>(1) = Float3(1.125f, 0.0f, 0.0f);
	vbaX.Color<Float4>(0, 0) = Float4(1.0f, 0.0f, 0.0f, 1.0f);
	vbaX.Color<Float4>(0, 1) = Float4(1.0f, 0.0f, 0.0f, 1.0f);

	vbaX.Position<Float3>(2) = Float3(0.5f, 0.0f, 0.0f);
	vbaX.Position<Float3>(3) = Float3(0.5f, 0.5f, 0.0f);
	vbaX.Color<Float4>(0, 2) = Float4(0.0f, 1.0f, 0.0f, 1.0f);
	vbaX.Color<Float4>(0, 3) = Float4(0.0f, 1.0f, 0.0f, 1.0f);

	vbaX.Position<Float3>(4) = Float3(0.5f, 0.0f, 0.0f);
	vbaX.Position<Float3>(5) = Float3(0.5f, 0.0f, 0.5f);
	vbaX.Color<Float4>(0, 4) = Float4(0.0f, 0.0f, 1.0f, 1.0f);
	vbaX.Color<Float4>(0, 5) = Float4(0.0f, 0.0f, 1.0f, 1.0f);

	Polysegment *polysegmentX = new0 PX2::Polysegment(vf, vBufferX,
		false);
	polysegmentX->SetMaterialInstance(
		VertexColor4Material::CreateUniqueInstance());
	nodeX->AttachChild(polysegmentX);

	TriMesh *meshX = stdMesh.Box(0.06f, 0.06f, 0.06f);
	meshX->SetMaterialInstance(VertexColor4Material::CreateUniqueInstance());
	//meshX->GetMaterialInstance()->GetPass(0)->GetWireProperty()->Enabled = true;
	meshX->LocalTransform.SetTranslate(APoint(1.125f, 0.0f, 0.0f));
	vBufferTemp = meshX->GetVertexBuffer();
	vbaTemp.ApplyTo(vf, vBufferTemp);
	for (int i = 0; i < vBufferTemp->GetNumElements(); i++)
	{
		vbaTemp.Color<Float4>(0, i) = Float4(1.0f, 0.0f, 0.0f, 1.0f);
	}
	nodeX->AttachChild(meshX);

	// y
	PX2::Node *nodeY = new0 PX2::Node;
	nodeX->SetName("Scale_Y");

	VertexBuffer *vBufferY = new0 VertexBuffer(6, vf->GetStride());
	VertexBufferAccessor vbaY(vf, vBufferY);

	vbaY.Position<Float3>(0) = Float3(0.0f, 0.25f, 0.0f);
	vbaY.Position<Float3>(1) = Float3(0.0f, 1.125f, 0.0f);
	vbaY.Color<Float4>(0, 0) = Float4(0.0f, 1.0f, 0.0f, 1.0f);
	vbaY.Color<Float4>(0, 1) = Float4(0.0f, 1.0f, 0.0f, 1.0f);

	vbaY.Position<Float3>(2) = Float3(0.0f, 0.5f, 0.0f);
	vbaY.Position<Float3>(3) = Float3(0.5f, 0.5f, 0.0f);
	vbaY.Color<Float4>(0, 2) = Float4(1.0f, 0.0f, 0.0f, 1.0f);
	vbaY.Color<Float4>(0, 3) = Float4(1.0f, 0.0f, 0.0f, 1.0f);

	vbaY.Position<Float3>(4) = Float3(0.0f, 0.5f, 0.0f);
	vbaY.Position<Float3>(5) = Float3(0.0f, 0.5f, 0.5f);
	vbaY.Color<Float4>(0, 4) = Float4(0.0f, 0.0f, 1.0f, 1.0f);
	vbaY.Color<Float4>(0, 5) = Float4(0.0f, 0.0f, 1.0f, 1.0f);

	Polysegment *polysegmentY = new0 PX2::Polysegment(vf, vBufferY,
		false);
	polysegmentY->SetMaterialInstance(
		VertexColor4Material::CreateUniqueInstance());
	nodeY->AttachChild(polysegmentY);

	TriMesh *meshY = stdMesh.Box(0.06f, 0.06f, 0.06f);
	meshY->SetMaterialInstance(VertexColor4Material::CreateUniqueInstance());
	//meshY->GetMaterialInstance()->GetPass(0)->GetWireProperty()->Enabled = true;
	meshY->LocalTransform.SetTranslate(APoint(0.0f, 1.125f, 0.0f));
	vBufferTemp = meshY->GetVertexBuffer();
	vbaTemp.ApplyTo(vf, vBufferTemp);
	for (int i = 0; i < vBufferTemp->GetNumElements(); i++)
	{
		vbaTemp.Color<Float4>(0, i) = Float4(0.0f, 1.0f, 0.0f, 1.0f);
	}
	nodeY->AttachChild(meshY);

	// z
	PX2::Node *nodeZ = new0 PX2::Node();
	nodeX->SetName("Scale_Z");

	VertexBuffer *vBufferZ = new0 VertexBuffer(6, vf->GetStride());
	VertexBufferAccessor vbaZ(vf, vBufferZ);

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

示例8: if


//.........这里部分代码省略.........
	}
	if (mTextureCoordMap)
	{
		if (1 == mNumTexcoordToExport)
		{
			vFormat->Add(VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
		}
		else if (2 == mNumTexcoordToExport)
		{
			vFormat->Add(VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
			vFormat->Add(VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 1);
		}
	}
	if (mExportSkin)
	{
		vFormat->Add(VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT4, 1);
		vFormat->Add(VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT4, 2);
	}

	vFormat->Create();

	PX2::VertexBuffer *vBuffer = new0 PX2::VertexBuffer(mVertexMapQuantity, 
		vFormat->GetStride());

	VertexBufferAccessor vBA(vFormat, vBuffer);

	for (int i=0; i<mVertexMapQuantity; i++)
	{
		vBA.Position<Float3>(i) = mVertexMap[i];

		if (mNormalMap)
		{
			vBA.Normal<Float3>(i) = mNormalMap[i];
		}

		if (mColorMap)
		{
			vBA.Color<Float4>(0, i) = Float4(mColorMap[i][0], mColorMap[i][1],
				mColorMap[i][2], mColorMap[i][3]);
		}
		else
		{
			if (mExportColor)
				vBA.Color<Float4>(0, i) = Float4::WHITE;
		}

		if (mAlphaMap)
		{
			vBA.Color<Float4>(0, i) = Float4(mColorMap[i][0], mColorMap[i][1],
				mColorMap[i][2], mAlphaMap[i]);
		}

		if (mTextureCoordMap)
		{
			if (mNumTexcoordToExport == 1)
			{
				vBA.TCoord<Float2>(0, i) = Float2(mTextureCoordMap[i][0], 1.0f-mTextureCoordMap[i][1]);
			}
			else if (mNumTexcoordToExport == 2)
			{
				Float2 texCoord0 = Float2(mTextureCoordMap[i][0], 1.0f-mTextureCoordMap[i][1]);

				vBA.TCoord<Float2>(0, i) = texCoord0;

				if (mTextureCoordMap1)
				{
					vBA.TCoord<Float2>(1, i) = Float2(mTextureCoordMap1[i][0], 1.0f-mTextureCoordMap1[i][1]);
				}
				else
				{
					vBA.TCoord<Float2>(1, i) = texCoord0;
				}
			}
		}
	}
	
	// IndexBuffer
	IndexBuffer *iBuffer = new0 IndexBuffer(3*mFQuantity, 2);
	unsigned short *iData = (unsigned short*)iBuffer->GetData();
	for (int i=0; i<(int)3*mFQuantity; i++)
	{
		iData[i] = (unsigned short)mVFace[i];
	}

	// 创建Mesh
	TriMesh *triMesh = new0 TriMesh(vFormat, vBuffer, iBuffer);
	triMesh->UpdateModelSpace(Renderable::GU_MODEL_BOUND_ONLY);
	if (mExportTargentBinormal)
	{
		triMesh->UpdateModelSpace(Renderable::GU_USE_GEOMETRY);
	}

	MaterialInstance *mi = 0;
	mi = mMaterialInstance;

	triMesh->SetMaterialInstance(mi);
	triMesh->SetShine(mShine);

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


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