本文整理汇总了C#中System.Entity.SetMaterialName方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.SetMaterialName方法的具体用法?C# Entity.SetMaterialName怎么用?C# Entity.SetMaterialName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.SetMaterialName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroundPlane
/// <summary>
/// This method generates a plane in an Entity which will be used as a ground
/// </summary>
private void GroundPlane()
{
plane = new Plane(Vector3.UNIT_Y, 0);
MeshPtr groundMeshPtr = MeshManager.Singleton.CreatePlane("ground",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, groundWidth,
groundHeight, groundXSegs, groundZSegs, true, 1, uTiles, vTiles,
Vector3.UNIT_Z);
groundEntity = mSceneMgr.CreateEntity("ground");
groundNode = mSceneMgr.CreateSceneNode();
groundNode.AttachObject(groundEntity);
mSceneMgr.RootSceneNode.AddChild(groundNode);
groundEntity.SetMaterialName("Meteor");
}
示例2: CreateHeart
/// <summary>
/// This method initializes the heart node and entity
/// </summary>
/// <param name="n"> A numeric tag used to determine the heart postion on sceen </param>
/// <returns></returns>
private SceneNode CreateHeart(int n)
{
lifeEntity = mSceneMgr.CreateEntity("Heart.mesh");
lifeEntity.SetMaterialName("HeartHMD");
SceneNode livesNode;
livesNode = new SceneNode(mSceneMgr);
livesNode.AttachObject(lifeEntity);
livesNode.Scale(new Vector3(0.15f, 0.15f, 0.15f));
//livesNode.Position = new Vector3(3f, 3f, -8) - n * 0.5f * Vector3.UNIT_X; ;
livesNode.Position = new Vector3(3f, 3.5f, -5.5f) - n * 0.5f * Vector3.UNIT_X; ;
livesNode.SetVisible(true);
return livesNode;
}
示例3: BeginNextTask
protected void BeginNextTask()
{
//If we're transitioning from a previous task, lets tear that shit down
if (currentRenderTask != null)
TearDownPreviousTask();
if (currentRenderTask == null && renderTasks.Count == 0)
{
mShutDown = true;
return;
}
//Dequeue the next task
currentRenderTask = renderTasks.Dequeue();
_playerEntity = mSceneMgr.CreateEntity(currentRenderTask.PlayerModelConfig.EntityName, currentRenderTask.PlayerModelConfig.ModelName);
_playerNode = mSceneMgr.RootSceneNode.CreateChildSceneNode("PlayerNode");
_playerNode.AttachObject(_playerEntity);
_playerNode._setDerivedPosition(_playerNode.Position + new Vector3(0, -0.5f * _playerEntity.BoundingRadius, 0));
//Set up name of dat animation collection
var animationCollectionName = currentRenderTask.PlayerModelConfig.EntityName;
switch (currentRenderTask.TaskType)
{
case TaskType.Item:
animationCollectionName += "_" + currentRenderTask.ItemConfig.EntityName;
break;
case TaskType.Wearable:
animationCollectionName += "_" + currentRenderTask.WearableConfig.EntityName;
break;
}
mAnimationCollection = new AnimationCollection { Name = animationCollectionName };
mStateIterator = _playerEntity.AllAnimationStates.GetAnimationStateIterator();
if (_playerEntity != null)
{
switch (currentRenderTask.TaskType)
{
case TaskType.Item:
{
_currentItem = mSceneMgr.CreateEntity(currentRenderTask.ItemConfig.EntityName,
currentRenderTask.ItemConfig.ModelName);
var ic = currentRenderTask.ItemConfig;
_playerEntity.AttachObjectToBone(currentRenderTask.PlayerModelConfig.RHandBoneName, _currentItem,
new Quaternion(ic.QuatW, ic.QuatX, ic.QuatY, ic.QuatZ),
new Vector3(ic.OffsetX, ic.OffsetY, ic.OffsetZ));
//Make player entity transparent so all we see is the item
_playerEntity.SetMaterialName("transparent_mask");
}
break;
case TaskType.Wearable:
_playerEntity.SetMaterialName(currentRenderTask.WearableConfig.Material);
break;
}
}
//_ent.SetMaterialName("Normal");
/*
var sub = _ent.GetSubEntity(0);
sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(10.0f, 0.0f, 0.0f, 0.0f));
sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 1.0f, 0.7f, 1.0f));
sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 1.0f, 1.0f, 1.0f));*/
NextAnimation();
}
示例4: CreateScene
public override void CreateScene()
{
//init spline array
for (int i = 0; i < NUM_FISH; i++)
{
fishSplines[i] = new SimpleSpline();
}
// Check prerequisites first
RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities;
if (!caps.HasCapability(Capabilities.RSC_VERTEX_PROGRAM) || !(caps.HasCapability(Capabilities.RSC_FRAGMENT_PROGRAM)))
{
throw new System.Exception("Your card does not support vertex and fragment programs, so cannot run this demo. Sorry!");
}
else
{
if (!GpuProgramManager.Singleton.IsSyntaxSupported("arbfp1") &&
!GpuProgramManager.Singleton.IsSyntaxSupported("ps_2_0") &&
!GpuProgramManager.Singleton.IsSyntaxSupported("ps_1_4")
)
{
throw new System.Exception("Your card does not support advanced fragment programs, so cannot run this demo. Sorry!");
}
}
camera.SetPosition(-50, 125, 760);
camera.SetDirection(0, 0, -1);
// Set ambient light
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
// Create a point light
Light l = sceneMgr.CreateLight("MainLight");
l.Type = Light.LightTypes.LT_DIRECTIONAL;
l.Direction = -Vector3.UNIT_Y;
Entity pEnt;
TexturePtr mTexture = TextureManager.Singleton.CreateManual("Refraction",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D,
512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET);
//RenderTexture* rttTex = mRoot.getRenderSystem().createRenderTexture( "Refraction", 512, 512 );
RenderTarget rttTex = mTexture.GetBuffer().GetRenderTarget();
{
Viewport v = rttTex.AddViewport(camera);
MaterialPtr mat = MaterialManager.Singleton.GetByName("Examples/FresnelReflectionRefraction");
mat.GetTechnique(0).GetPass(0).GetTextureUnitState(2).SetTextureName("Refraction");
v.OverlaysEnabled = false;
rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(Refraction_PreRenderTargetUpdate);
rttTex.PostRenderTargetUpdate += new RenderTargetListener.PostRenderTargetUpdateHandler(Refraction_PostRenderTargetUpdate);
}
mTexture = TextureManager.Singleton.CreateManual("Reflection",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D,
512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET);
//rttTex = mRoot.getRenderSystem().createRenderTexture( "Reflection", 512, 512 );
rttTex = mTexture.GetBuffer().GetRenderTarget();
{
Viewport v = rttTex.AddViewport(camera);
MaterialPtr mat = MaterialManager.Singleton.GetByName("Examples/FresnelReflectionRefraction");
mat.GetTechnique(0).GetPass(0).GetTextureUnitState(1).SetTextureName("Reflection");
v.OverlaysEnabled = false;
rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(Reflection_PreRenderTargetUpdate);
rttTex.PostRenderTargetUpdate += new RenderTargetListener.PostRenderTargetUpdateHandler(Reflection_PostRenderTargetUpdate);
}
// Define a floor plane mesh
reflectionPlane.normal = Vector3.UNIT_Y;
reflectionPlane.d = 0;
MeshManager.Singleton.CreatePlane("ReflectPlane",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
reflectionPlane,
1500, 1500, 10, 10, true, 1, 5, 5, Vector3.UNIT_Z);
pPlaneEnt = sceneMgr.CreateEntity("plane", "ReflectPlane");
pPlaneEnt.SetMaterialName("Examples/FresnelReflectionRefraction");
sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(pPlaneEnt);
sceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox");
// My node to which all objects will be attached
SceneNode myRootNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
// above water entities
pEnt = sceneMgr.CreateEntity( "RomanBathUpper", "RomanBathUpper.mesh" );
myRootNode.AttachObject(pEnt);
aboveWaterEnts.Add(pEnt);
pEnt = sceneMgr.CreateEntity( "Columns", "Columns.mesh" );
myRootNode.AttachObject(pEnt);
aboveWaterEnts.Add(pEnt);
SceneNode headNode = myRootNode.CreateChildSceneNode ();
pEnt = sceneMgr.CreateEntity( "OgreHead", "ogrehead.mesh" );
pEnt.SetMaterialName ("RomanBath/OgreStone");
headNode.AttachObject(pEnt);
headNode.SetPosition(-350,55,130);
headNode.Rotate(Vector3.UNIT_Y, new Degree (90));
aboveWaterEnts.Add(pEnt);
// below water entities
//.........这里部分代码省略.........
示例5: CreateThings
/// <summary>
/// create a bunch of crap
/// </summary>
void CreateThings()
{
Light light = mogreImageSource.SceneManager.CreateLight("sun2");
light.Type = Light.LightTypes.LT_DIRECTIONAL;
light.Direction = new Vector3(-0.1f, -1, 0.1f);
light.Direction.Normalise();
light.DiffuseColour = new ColourValue(1f, 1f, 1f);
light.SpecularColour = new ColourValue(1f, 1f, 1f);
light.Position = new Vector3(0, 10, 0);
light.CastShadows = true;
ponyNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
ponyEnt = sceneMgr.CreateEntity("BgPonyColtBody.mesh");
ponyNode.AttachObject(ponyEnt);
ponyNode.Position = new Vector3(0, 0, 0);
ponyEnt.SetMaterialName("BgPony");
wingsEnt = sceneMgr.CreateEntity("BgPonyColtWings.mesh");
wingsEnt.SetMaterialName("BgPonyWings");
hornEnt = sceneMgr.CreateEntity("BgPonyHorn.mesh");
hornEnt.SetMaterialName("BgPonyHorn");
eyesEnt = sceneMgr.CreateEntity("BgPonyColtEyes.mesh");
eyesEnt.SetMaterialName("BgPonyEyes");
foldedWingsEnt = sceneMgr.CreateEntity("BgPonyColtWingsFolded.mesh");
foldedWingsEnt.SetMaterialName("BgPonyWingsFolded");
hairEnts = new Entity[NUMBER_OF_HAIRSTYLES];
maneEnts = new Entity[NUMBER_OF_HAIRSTYLES];
tailEnts = new Entity[NUMBER_OF_HAIRSTYLES];
for (int a = 0; a < NUMBER_OF_HAIRSTYLES; a++) {
hairEnts[a] = sceneMgr.CreateEntity("BgPonyHair" + (a + 1) + ".mesh");
hairEnts[a].SetMaterialName("BgPonyHair_Double_" + (a + 1));
maneEnts[a] = sceneMgr.CreateEntity("BgPonyMane" + (a + 1) + ".mesh");
maneEnts[a].SetMaterialName("BgPonyHair_Double_" + (a + 1));
tailEnts[a] = sceneMgr.CreateEntity("BgPonyTail" + (a + 1) + ".mesh");
tailEnts[a].SetMaterialName("BgPonyHair_Double_" + (a + 1));
}
wingsEnt.Visible = false;
foldedWingsEnt.Visible = false;
hornEnt.Visible = false;
for (int a = 1; a < NUMBER_OF_HAIRSTYLES; a++) {
hairEnts[a].Visible = false;
maneEnts[a].Visible = false;
tailEnts[a].Visible = false;
}
AdjustBodyColour(bodyColour);
AdjustBodyAOColour(bodyAOColour);
AdjustHairColour1(hairColour1);
AdjustHairColour2(hairColour2);
AdjustHairAOColour1(hairAOColour1);
AdjustHairAOColour2(hairAOColour2);
// attach stuff
ponyEnt.AttachObjectToBone("Eyes", eyesEnt);
ponyEnt.AttachObjectToBone("Horn", hornEnt);
ponyEnt.AttachObjectToBone("Wings", wingsEnt);
ponyEnt.AttachObjectToBone("Wings", foldedWingsEnt);
for (int a = 0; a < NUMBER_OF_HAIRSTYLES; a++) {
ponyEnt.AttachObjectToBone("Hair", hairEnts[a]);
ponyEnt.AttachObjectToBone("Mane", maneEnts[a]);
ponyEnt.AttachObjectToBone("Tail", tailEnts[a]);
}
// setup animations
Skeleton skeleton = ponyEnt.Skeleton;
skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;
// set up the blink animation state with some stuff
blinkState = ponyEnt.GetAnimationState("Blink2");
blinkState.Enabled = true;
blinkState.Loop = true;
blinkState.Weight = 1;
blinkState.CreateBlendMask(skeleton.NumBones, 0f);
ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
blinkState.SetBlendMaskEntry(handle, 1f);
handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
blinkState.SetBlendMaskEntry(handle, 1f);
handle = skeleton.GetBone("EyeBrowTop.L").Handle;
blinkState.SetBlendMaskEntry(handle, 1f);
handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
blinkState.SetBlendMaskEntry(handle, 1f);
animState = ponyEnt.GetAnimationState("Stand1");
wingsState = wingsEnt.GetAnimationState("Flap1");
maneStates = new AnimationState[NUMBER_OF_HAIRSTYLES];
tailStates = new AnimationState[NUMBER_OF_HAIRSTYLES];
//.........这里部分代码省略.........
示例6: CreateScene
// Just override the mandatory create scene method
public override void CreateScene()
{
// Set ambient light
sceneMgr.AmbientLight = new ColourValue(0.2f, 0.2f, 0.2f);
// Skybox
sceneMgr.SetSkyBox(true, "Examples/MorningSkyBox");
// Create a light
Light l = sceneMgr.CreateLight("MainLight");
l.Type = Light.LightTypes.LT_DIRECTIONAL;
Vector3 dir = new Vector3(0.5f, -1, 0);
dir.Normalise();
l.Direction = dir;
l.DiffuseColour = new ColourValue(1.0f, 1.0f, 0.8f);
l.SpecularColour= new ColourValue(1.0f, 1.0f, 1.0f);
// Create a prefab plane
mPlane = new MovablePlane(Vector3.UNIT_Y, 0);
MeshManager.Singleton.CreatePlane("ReflectionPlane",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
mPlane._getDerivedPlane(), 2000, 2000,
1, 1, true, 1, 1, 1, Vector3.UNIT_Z);
mPlaneEnt = sceneMgr.CreateEntity( "Plane", "ReflectionPlane" );
// Create an entity from a model (will be loaded automatically)
Entity knotEnt = sceneMgr.CreateEntity("Knot", "knot.mesh");
// Create an entity from a model (will be loaded automatically)
Entity ogreHead = sceneMgr.CreateEntity("Head", "ogrehead.mesh");
knotEnt.SetMaterialName("Examples/TextureEffect2");
// Attach the rtt entity to the root of the scene
SceneNode rootNode = sceneMgr.RootSceneNode;
mPlaneNode = rootNode.CreateChildSceneNode();
// Attach both the plane entity, and the plane definition
mPlaneNode.AttachObject(mPlaneEnt);
mPlaneNode.AttachObject(mPlane);
mPlaneNode.Translate(0, -10, 0);
// Tilt it a little to make it interesting
mPlaneNode.Roll(new Degree(5));
rootNode.CreateChildSceneNode( "Head" ).AttachObject( ogreHead );
TexturePtr texture = TextureManager.Singleton.CreateManual( "RttTex",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
TextureType.TEX_TYPE_2D,
512, 512, 0,
PixelFormat.PF_R8G8B8,
(int) TextureUsage.TU_RENDERTARGET );
RenderTarget rttTex = texture.GetBuffer().GetRenderTarget();
mReflectCam = sceneMgr.CreateCamera("ReflectCam");
mReflectCam.NearClipDistance = camera.NearClipDistance;
mReflectCam.FarClipDistance = camera.FarClipDistance;
mReflectCam.AspectRatio =
(float)window.GetViewport(0).ActualWidth /
(float)window.GetViewport(0).ActualHeight;
mReflectCam.FOVy = camera.FOVy;
Viewport v = rttTex.AddViewport( mReflectCam );
v.SetClearEveryFrame(true);
v.BackgroundColour = ColourValue.Black;
MaterialPtr mat = MaterialManager.Singleton.Create("RttMat",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
TextureUnitState t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RustedMetal.jpg");
t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RttTex");
// Blend with base texture
t.SetColourOperationEx(LayerBlendOperationEx.LBX_BLEND_MANUAL,
LayerBlendSource.LBS_TEXTURE,
LayerBlendSource.LBS_CURRENT,
ColourValue.White,
ColourValue.White, 0.25f);
t.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_CLAMP);
t.SetProjectiveTexturing(true, mReflectCam);
rttTex.PostRenderTargetUpdate += postRenderTargetUpdate;
rttTex.PreRenderTargetUpdate += preRenderTargetUpdate;
// set up linked reflection
mReflectCam.EnableReflection(mPlane);
// Also clip
mReflectCam.EnableCustomNearClipPlane(mPlane);
// Give the plane a texture
mPlaneEnt.SetMaterialName("RttMat");
// Add a whole bunch of extra transparent entities
Entity cloneEnt;
for (int n = 0; n < 10; ++n)
{
// Create a new node under the root
SceneNode node = sceneMgr.CreateSceneNode();
// Random translate
Vector3 nodePos;
nodePos.x = Mogre.Math.SymmetricRandom() * 750.0f;
nodePos.y = Mogre.Math.SymmetricRandom() * 100.0f + 25;
//.........这里部分代码省略.........