本文整理汇总了C#中System.Entity.AddTrait方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.AddTrait方法的具体用法?C# Entity.AddTrait怎么用?C# Entity.AddTrait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.AddTrait方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start()
{
_alternateCamera = this.SceneGraph.CreateSceneObject("Alternate Camera");
CommonDemoResources.Create (Platform, Engine);
_alternateCamera.AddTrait<CameraTrait>();
_alternateCamera.Transform.Position = new Vector3(0.65f, 1f, -2.50f) * 3;
_alternateCamera.Transform.LookAt(Vector3.Zero);
_objects = RandomObjectHelper.Generate(this);
var landmarkGo = this.CreateLandmark();
_objects.Add(landmarkGo);
_returnScene = this;
this.Engine.InputEventSystem.Tap += this.OnTap;
}
示例2: Start
public override void Start()
{
this.Configuration.BackgroundColour = Rgba32.DarkSlateGrey;
//var goBoardMesh = new CubePrimitive (this.Platform.Graphics).Mesh;
MeshAsset mushMeshAsset0 = this.Engine.Assets.Load<MeshAsset> ("assets/big_mushroom.bba");
vb0 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset0.VertexDeclaration, mushMeshAsset0.VertexData.Length);
ib0 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset0.IndexData.Length);
vb0.SetDataEx (mushMeshAsset0.VertexData);
ib0.SetData (mushMeshAsset0.IndexData);
var mushMesh0 = new Mesh (vb0, ib0);
MeshAsset mushMeshAsset1 = this.Engine.Assets.Load<MeshAsset> ("assets/small_mushroom_1.bba");
vb1 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset1.VertexDeclaration, mushMeshAsset1.VertexData.Length);
ib1 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset1.IndexData.Length);
vb1.SetDataEx (mushMeshAsset1.VertexData);
ib1.SetData (mushMeshAsset1.IndexData);
var mushMesh1 = new Mesh (vb1, ib1);
MeshAsset mushMeshAsset2 = this.Engine.Assets.Load<MeshAsset> ("assets/small_mushroom_2.bba");
vb2 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset2.VertexDeclaration, mushMeshAsset2.VertexData.Length);
ib2 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset2.IndexData.Length);
vb2.SetDataEx (mushMeshAsset2.VertexData);
ib2.SetData (mushMeshAsset2.IndexData);
var mushMesh2 = new Mesh (vb2, ib2);
// set up the debug renderer
ShaderAsset unlitShaderAsset = this.Engine.Assets.Load<ShaderAsset> ("assets/pixel_lit.bba");
shader = this.Platform.Graphics.CreateShader (unlitShaderAsset);
TextureAsset woodTexAsset = this.Engine.Assets.Load <TextureAsset> ("assets/toadstool_diffuse.bba");
woodTex = this.Platform.Graphics.CreateTexture (woodTexAsset);
mush0 = SceneGraph.CreateSceneObject ("mush0");
mush0.Transform.LocalPosition = new Vector3 (0f, 0f, 0f);
mush0.Transform.LocalScale = new Vector3 (1f, 1f, 1f);
mush1 = SceneGraph.CreateSceneObject ("mush1");
mush1.Transform.LocalPosition = new Vector3 (0.8f, 0f, 0.8f);
mush1.Transform.LocalScale = new Vector3 (1f, 1f, 1f);
mush2 = SceneGraph.CreateSceneObject ("mush2");
mush2.Transform.LocalPosition = new Vector3 (0.5f, 0f, 0f);
mush2.Transform.LocalScale = new Vector3 (1f, 1f, 1f);
var mat = new Material ("Default", shader);
mat.SetTexture ("TextureSampler", woodTex);
MeshRendererTrait meshRendererTrait0 = mush0.AddTrait<MeshRendererTrait> ();
meshRendererTrait0.Material = mat;
meshRendererTrait0.Mesh = mushMesh0;
meshRendererTrait0.CullMode = CullMode.None;
MeshRendererTrait meshRendererTrait1 = mush1.AddTrait<MeshRendererTrait> ();
meshRendererTrait1.Material = mat;
meshRendererTrait1.Mesh = mushMesh1;
meshRendererTrait1.CullMode = CullMode.None;
MeshRendererTrait meshRendererTrait2 = mush2.AddTrait<MeshRendererTrait> ();
meshRendererTrait2.Material = mat;
meshRendererTrait2.Mesh = mushMesh2;
meshRendererTrait2.CullMode = CullMode.None;
returnScene = this;
var t = SceneGraph.CreateSceneObject ("T");
t.Transform.LocalPosition = new Vector3 (0, 1f, 0);
Entity camSo = SceneGraph.CreateSceneObject ("Scene X Camera");
camSo.AddTrait<CameraTrait>();
var lookatTrait = camSo.AddTrait<LookAtSubjectTrait>();
lookatTrait.Subject = t.Transform;
var orbitTrait = camSo.AddTrait<OrbitAroundSubjectTrait>();
orbitTrait.CameraSubject = Transform.Origin;
camSo.Transform.LocalPosition = new Vector3(6f,3f,6f);
this.RuntimeConfiguration.SetRenderPassCameraTo("Debug", camSo);
this.RuntimeConfiguration.SetRenderPassCameraTo("Default", camSo);
this.Engine.InputEventSystem.Tap += this.OnTap;
}
示例3: Start
public override void Start()
{
CommonDemoResources.Create (Platform, Engine);
var lines = Engine.Assets.Load <TextAsset> ("assets/airports.bba")
.Text
.Split ('\n')
.ToList ();
foreach (var line in lines)
{
string[] items = line.Split(',');
if (items.Length == 11)
{
airports.Add(new Airport(items));
}
}
airports.Shuffle ();
airports = airports.GetRange (0, 250);
Console.WriteLine("num airports: " + airports.Count);
this.Configuration.BackgroundColour = Rgba32.Red;
returnScene = this;
float radius = 1.5f;
// create a sprite
var sphereMesh = new SpherePrimitive(this.Platform.Graphics);
var mat = new Material("Default",CommonDemoResources.VertexLitShader);
mat.SetColour("MaterialColour", Rgba32.LightGrey);
earthGo = this.SceneGraph.CreateSceneObject("earth");
Entity camSo = SceneGraph.CreateSceneObject ("Scene 5 Camera");
camSo.AddTrait<CameraTrait>();
var lookatTrait = camSo.AddTrait<LookAtSubjectTrait>();
lookatTrait.Subject = Transform.Origin;
var orbitTrait = camSo.AddTrait<OrbitAroundSubjectTrait>();
orbitTrait.CameraSubject = Transform.Origin;
camSo.Transform.LocalPosition = new Vector3(10f,4f,10f);
this.RuntimeConfiguration.SetRenderPassCameraTo("Debug", camSo);
this.RuntimeConfiguration.SetRenderPassCameraTo("Default", camSo);
earthGo.Transform.LocalScale = new Vector3(2 * radius, 2 * radius, 2 * radius);
var mr = earthGo.AddTrait<MeshRendererTrait>();
mr.Mesh = sphereMesh.Mesh;
mr.Material = mat;
//var mat2 = new Material("Default", CommonDemoResources.UnlitShader);
//mat2.SetColour("MaterialColour", Rgba32.Blue);
foreach (var airport in airports)
{
var so = this.SceneGraph.CreateSceneObject(airport.Iata);
so.Transform.Parent = earthGo.Transform;
var sodr = so.AddTrait<DebugRendererTrait>();
//sodr.RenderPass = "Default";
sodr.Colour = Rgba32.Blue;
//var somr = so.AddTrait<MeshRenderer>();
//somr.Mesh = sphereMesh;
//somr.Material = mat2;
var lat = airport.Latitude;
var lon = airport.Longitude;
Vector3 pos = new Vector3(
radius * Maths.Cos(Maths.ToRadians(lat)),
radius * Maths.Sin(Maths.ToRadians(lat)),
0f);
Single t = Maths.ToRadians (lon);
Matrix44 rot; Matrix44.CreateRotationY(ref t, out rot);
Vector3 r; Vector3.Transform(ref pos, ref rot, out r);
so.Transform.Position = r;
so.Transform.LocalScale = new Vector3(0.015f, 0.015f, 0.015f);
}
this.Engine.InputEventSystem.Tap += this.OnTap;
}
示例4: Start
public override void Start()
{
this.Configuration.BackgroundColour = Rgba32.LightSlateGrey;
CommonDemoResources.Create (Platform, Engine);
returnScene = this;
// create a sprite
var billboard = new BillboardPrimitive(this.Platform.Graphics);
billboardGo = this.SceneGraph.CreateSceneObject("billboard");
var mr = billboardGo.AddTrait<MeshRendererTrait>();
mr.Mesh = billboard.Mesh;
mr.Material = new Material("Default", CommonDemoResources.UnlitShader);
mr.Material.SetColour("MaterialColour", RandomGenerator.Default.GetRandomColour());
target = billboardGo.Transform;
markerGo = this.SceneGraph.CreateSceneObject ("marker");
markerGo.Transform.LocalScale = new Vector3 (0.05f, 0.05f, 0.05f);
var markerMR = markerGo.AddTrait<MeshRendererTrait> ();
markerMR.Mesh = new CubePrimitive(this.Platform.Graphics).Mesh;
markerMR.Material = new Material("Default", CommonDemoResources.UnlitShader);
markerMR.Material.SetColour("MaterialColour", Rgba32.Red);
cam = this.CameraManager.GetRenderPassCamera ("Default");
this.SceneGraph.DestroySceneObject(this.CameraManager.GetRenderPassCamera ("Debug"));
this.SceneGraph.DestroySceneObject(this.CameraManager.GetRenderPassCamera ("Gui"));
this.RuntimeConfiguration.SetRenderPassCameraTo ("Debug", cam);
cam.Transform.Position = new Vector3(2, 1, 5);
cam.RemoveTrait<OrbitAroundSubjectTrait> ();
las = cam.GetTrait<LookAtSubjectTrait> ();
las.Subject = billboardGo.Transform;
this.Engine.InputEventSystem.Tap += this.OnTap;
}
示例5: Start
public override void Start()
{
this.Configuration.BackgroundColour = Rgba32.DarkSlateGrey;
MeshAsset meshAsset = this.Engine.Assets.Load<MeshAsset> ("assets/darius.bba");
vb = Platform.Graphics.CreateVertexBuffer (meshAsset.VertexDeclaration, meshAsset.VertexData.Length);
ib = Platform.Graphics.CreateIndexBuffer (meshAsset.IndexData.Length);
vb.SetDataEx (meshAsset.VertexData);
ib.SetData (meshAsset.IndexData);
var mushMesh0 = new Mesh (vb, ib);
// set up the debug renderer
ShaderAsset unlitShaderAsset = this.Engine.Assets.Load<ShaderAsset> ("assets/vertex_lit.bba");
shader = this.Platform.Graphics.CreateShader (unlitShaderAsset);
TextureAsset texAsset = this.Engine.Assets.Load <TextureAsset> ("assets/darius_tex.bba");
tex = this.Platform.Graphics.CreateTexture (texAsset);
entity = SceneGraph.CreateSceneObject ("entity");
entity.Transform.LocalPosition = new Vector3 (0f, 0f, 0f);
entity.Transform.LocalScale = new Vector3 (0.1f, 0.1f, 0.1f);
var mat = new Material ("Default", shader);
mat.SetTexture ("TextureSampler", tex);
MeshRendererTrait meshRendererTrait0 = entity.AddTrait<MeshRendererTrait> ();
meshRendererTrait0.Material = mat;
meshRendererTrait0.Mesh = mushMesh0;
meshRendererTrait0.CullMode = CullMode.None;
returnScene = this;
var t = SceneGraph.CreateSceneObject ("T");
t.Transform.LocalPosition = new Vector3 (0, 2.3f, 0);
Entity camSo = SceneGraph.CreateSceneObject ("Scene X Camera");
camSo.AddTrait<CameraTrait> ();
var lookatTrait = camSo.AddTrait<LookAtSubjectTrait> ();
lookatTrait.Subject = t.Transform;
var orbitTrait = camSo.AddTrait<OrbitAroundSubjectTrait> ();
orbitTrait.CameraSubject = Transform.Origin;
camSo.Transform.LocalPosition = new Vector3 (-7f,3f,1f);
this.RuntimeConfiguration.SetRenderPassCameraTo("Debug", camSo);
this.RuntimeConfiguration.SetRenderPassCameraTo("Default", camSo);
this.Engine.InputEventSystem.Tap += this.OnTap;
}