本文整理汇总了C#中SceneManager.CreateEntity方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateEntity方法的具体用法?C# SceneManager.CreateEntity怎么用?C# SceneManager.CreateEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SceneManager
的用法示例。
在下文中一共展示了SceneManager.CreateEntity方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ninja
public Ninja(ref SceneManager mSceneMgr, Vector3 position)
{
ent = mSceneMgr.CreateEntity("Ninja" + count.ToString(), "ninja.mesh");
ent.CastShadows = true;
node = mSceneMgr.RootSceneNode.CreateChildSceneNode("NinjaNode" + count.ToString());
node.AttachObject(ent);
node.Scale(0.5f, 0.5f, 0.5f);
node.Position = position;
name = count++.ToString();
walkSpeedFactor = 1.0f;
mAnimationState = ent.GetAnimationState("Idle1");
mAnimationState.Loop = true;
mAnimationState.Enabled = true;
mWalkList = new LinkedList<Vector3>();
//mWalkList.AddLast(new Vector3(550.0f, 0.0f, 50.0f));
//mWalkList.AddFirst(new Vector3(-100.0f, 0.0f, -200.0f));
//mWalkList.AddLast(new Vector3(0.0f, 0.0f, 25.0f));
forward = Vector3.NEGATIVE_UNIT_Z;
viewingAngle = 40;
mAnimationState = ent.GetAnimationState("Walk");
mAnimationState.Loop = true;
mAnimationState.Enabled = true;
mWalking = true;
rnd = new Random();
stoneCastle = 0;
castle = new Vector3();
castle = Vector3.ZERO;
nbStoneCastle = 0;
state = "free";
ennemySpotted = 0;
maxView = 200;
}
示例2: Stone
public Stone(ref SceneManager mSceneMgr, Vector3 position)
{
name = count.ToString();
ent = mSceneMgr.CreateEntity("stone"+name, "ogrehead.mesh");
ent.CastShadows = true;
isCarried = false;
node = mSceneMgr.RootSceneNode.CreateChildSceneNode("stoneNode"+name);
node.AttachObject(ent);
node.Position = position;
node.Scale(0.35f, 0.35f, 0.35f);
count++;
}
示例3: ClientShip
public ClientShip(World _w, SceneManager _mgr, SceneNode _parent, int _id, Vector3 _position, Quaternion _orientation)
: base(_w, _id, _position, _orientation)
{
SceneNode parent = _mgr.RootSceneNode;
if(_parent != null){
parent = _parent;
}
mesh = _mgr.CreateEntity(id.ToString(), "razor.mesh");
node = parent.CreateChildSceneNode();
node.AttachObject(mesh);
body.attachToNode(node);
}
示例4: OnLoad
public void OnLoad()
{
var dir = Directory.GetCurrentDirectory();
ResourceGroupManager.Singleton.AddResourceLocation(dir, "FileSystem");
MaterialManager.Singleton.Initialise();
_scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
_scene.ClearScene();
Bindings.MOGRE.SLSharp.Init();
Shader.DebugMode = true;
//Shader.DebugMode = true;
_shader = Shader.CreateSharedShader<SimpleShader>();
_patchEntity = _scene.CreateEntity("Box", "box.mesh");
_scene.RootSceneNode.AttachObject(_patchEntity);
var mat = _shader.ToMaterial();
var pass = mat.GetTechnique(0).GetPass(0);
pass.SetAlphaRejectSettings(CompareFunction.CMPF_GREATER_EQUAL, 128);
pass.CullingMode = CullingMode.CULL_NONE;
// SL# on OGRE: bind auto semantic to a uniform!
// (we might automate this via semantic attributes within the SL# shaders in future!)
_shader.SetAuto(() => _shader.ModelviewProjection, GpuProgramParameters.AutoConstantType.ACT_WORLDVIEWPROJ_MATRIX);
_shader.Begin();
// Set a texture
/*
var smp = _shader.Sampler(() => _shader.Texture);
smp.SetTextureName(TextureManager.Singleton.Load("test.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).Name);
smp.SetTextureName(_wang.AsTexture.Name);
smp.SetTextureFiltering(FilterOptions.FO_POINT, FilterOptions.FO_POINT, FilterOptions.FO_POINT);
*/
_patchEntity.SetMaterial(mat);
_camera = _scene.CreateCamera("MainCamera");
_camera.Position = new Vector3(0, 0, 5);
_camera.LookAt(Vector3.ZERO);
_camera.NearClipDistance = 0.0001f;
_camera.FarClipDistance = 4.0f;
_camera.AutoAspectRatio = true;
var vp = _window.AddViewport(_camera);
vp.BackgroundColour = ColourValue.Blue;
}
示例5: ForceBall
public ForceBall(SceneManager sceneManager, MogreNewt.World physicsWorld, float tempSize, int own)
{
MogreNewt.ConvexCollision col;
Mogre.Vector3 offset;
Mogre.Vector3 inertia;
unique++;
// Create the visible mesh (no physics)
ent = sceneManager.CreateEntity("forceball" + unique, "Sph.mesh");
sn = sceneManager.RootSceneNode.CreateChildSceneNode();
sn.AttachObject(ent);
Console.WriteLine("end ball create");
size = tempSize;
sn.SetScale(size, size, size);
// Create the collision hull
col = new MogreNewt.CollisionPrimitives.ConvexHull(physicsWorld, sn);
col.calculateInertialMatrix(out inertia, out offset);
// Create the physics body. This body is what you manipulate. The graphical Ogre scenenode is automatically synced with the physics body
body = new MogreNewt.Body(physicsWorld, col);
col.Dispose();
//body.setPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY);
body.attachToNode(sn);
body.setContinuousCollisionMode(1);
body.setMassMatrix(mass, mass * inertia);
body.IsGravityEnabled = true;
body.setUserData(this);
trail = sceneManager.CreateParticleSystem("awesome" + StringConverter.ToString(unique), "Char/Smoke");
trail.CastShadows = true;
trail.GetEmitter(0).EmissionRate = 100;
sn.AttachObject(trail);
Console.WriteLine("player stuff");
owner = own;
Player tempP = (Player)Program.p1;
colour = tempP.cv;
}
示例6: SpaceMarine
public SpaceMarine(ref SceneManager mSceneMgr, Vector3 position)
{
ent = mSceneMgr.CreateEntity("Robot" + count.ToString(), "robot.mesh");
ent.CastShadows = true;
node = mSceneMgr.RootSceneNode.CreateChildSceneNode("RobotNode" + count.ToString());
node.AttachObject(ent);
node.Position = position;
name = count++.ToString();
walkSpeedFactor = 1.75f;
mAnimationState = ent.GetAnimationState("Idle");
mAnimationState.Loop = true;
mAnimationState.Enabled = true;
mWalkList = new LinkedList<Vector3>();
lastPosition = position;
forward = Vector3.UNIT_X;
viewingAngle = 0.9f;
maxView = 3000;
returnPosition = Vector3.ZERO;
state = "free";
rnd = new Random();
}
示例7: SetupEntity
protected void SetupEntity(SceneManager sceneMgr, ModelBlock block)
{
// make a new one if it isn't created yet, clone an existing one
string meshName = block.GetStringProperty("mesh", null);
if (sceneMgr.HasEntity(meshName)) {
Entity = sceneMgr.GetEntity(meshName).Clone(meshName + ID);
}
else {
Entity = sceneMgr.CreateEntity(meshName, meshName);
}
if (block.FloatTokens.ContainsKey("renderingdistance"))
Entity.RenderingDistance = block.GetFloatProperty("RenderingDistance", null);
// material name
string materialName = block.GetStringProperty("material", string.Empty);
if (!string.IsNullOrWhiteSpace(materialName))
Entity.SetMaterialName(materialName);
// some other properties
ThingEnum shad = block.GetEnumProperty("CastsShadows", ThingEnum.Some);
if (Options.ShadowDetail == ShadowDetailOption.Many)
Entity.CastShadows = (shad == ThingEnum.Many || shad == ThingEnum.Some);
else if (Options.ShadowDetail == ShadowDetailOption.Some)
Entity.CastShadows = (shad == ThingEnum.Some);
else
Entity.CastShadows = false;
}
示例8: InitMogre
public void InitMogre()
{
//-----------------------------------------------------
// 1 enter ogre
//-----------------------------------------------------
root = new Root();
//-----------------------------------------------------
// 2 configure resource paths
//-----------------------------------------------------
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
// Go through all sections & settings in the file
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
// Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
while (seci.MoveNext()) {
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings) {
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
//-----------------------------------------------------
// 3 Configures the application and creates the window
//-----------------------------------------------------
bool foundit = false;
foreach (RenderSystem rs in root.GetAvailableRenderers()) {
root.RenderSystem = rs;
String rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem") {
foundit = true;
break;
}
}
if (!foundit)
return; //we didn't find it... Raise exception?
//we found it, we might as well use it!
root.RenderSystem.SetConfigOption("Full Screen", "No");
root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");
root.Initialise(false);
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = hWnd.ToString();
window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
camera = sceneMgr.CreateCamera("SimpleCamera");
camera.Position = new Vector3(0f, 0f, 100f);
// Look back along -Z
camera.LookAt(new Vector3(0f, 0f, -300f));
camera.NearClipDistance = 5;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);
Entity ent = sceneMgr.CreateEntity("ogre", "ogrehead.mesh");
SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("ogreNode");
node.AttachObject(ent);
}
示例9: Physics
public Physics(SceneManager sceneMgr)
{
// collision configuration contains default setup for memory, collision setup
collisionConf = new DefaultCollisionConfiguration();
Dispatcher = new CollisionDispatcher(collisionConf);
Broadphase = new DbvtBroadphase();
World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, null, collisionConf);
World.Gravity = new Vector3(0, -10, 0);
// create the ground
CollisionShape groundShape = new BoxShape(50, 1, 50);
CollisionShapes.Add(groundShape);
CollisionObject ground = LocalCreateRigidBody(0, Matrix4.IDENTITY, groundShape);
ground.UserObject = "Ground";
// create a few dynamic rigidbodies
float mass = 1.0f;
CollisionShape colShape = new BoxShape(1);
CollisionShapes.Add(colShape);
Vector3 localInertia = colShape.CalculateLocalInertia(mass);
var rbInfo = new RigidBodyConstructionInfo(mass, null, colShape, localInertia);
float start_x = StartPosX - ArraySizeX / 2;
float start_y = StartPosY;
float start_z = StartPosZ - ArraySizeZ / 2;
int k, i, j;
for (k = 0; k < ArraySizeY; k++)
{
for (i = 0; i < ArraySizeX; i++)
{
for (j = 0; j < ArraySizeZ; j++)
{
Matrix4 startTransform = new Matrix4();
startTransform.MakeTrans(
new Vector3(
2*i + start_x,
2*k + start_y,
2*j + start_z
)
);
// using motionstate is recommended, it provides interpolation capabilities
// and only synchronizes 'active' objects
int index = (k * ArraySizeX + i) * ArraySizeZ + j;
Entity box = sceneMgr.CreateEntity("Box" + index.ToString(), "box.mesh");
box.SetMaterialName("BoxMaterial/Active");
SceneNode boxNode = sceneMgr.RootSceneNode.CreateChildSceneNode("BoxNode" + index.ToString());
boxNode.AttachObject(box);
boxNode.Scale(new Vector3(2, 2, 2));
var mogreMotionState = new MogreMotionState(box, boxNode, startTransform);
rbInfo.MotionState = mogreMotionState;
RigidBody body = new RigidBody(rbInfo);
mogreMotionState.Body = body;
// make it drop from a height
body.Translate(new Vector3(0, 20, 0));
World.AddRigidBody(body);
}
}
}
rbInfo.Dispose();
}
示例10: MakePlane
// creates a single Y plane
public static Entity MakePlane(SceneManager mgr, float size, float tile)
{
MeshPtr mesh = MeshManager.Singleton.CreatePlane("ground",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
new Plane(Vector3.UNIT_Y, 0),
size, size, 1, 1, true, 1, tile, tile, Vector3.UNIT_Z);
// Create a ground plane
return mgr.CreateEntity("plane", "ground");
}
示例11: point3d
public SceneNode point3d(string name, int id, float x, float y, float z, SceneNode node, SceneManager sceneMgr)
{
Entity ent;
if (node == null)//point of reference 0,0,0
{
ManualObject aux = sceneMgr.CreateManualObject();
//ent = sceneMgr.CreateEntity(name + id, this.getNameEntities());
node = sceneMgr.RootSceneNode.CreateChildSceneNode(name + id + "Node", new Vector3(y, z, x));
node.AttachObject(aux);
return node;
}
else//create new point
{
float xAux = x;
float yAux = y;
SceneNode nodeAux;
ent = sceneMgr.CreateEntity(name + id, getNameEntities());
nodeAux = node.CreateChildSceneNode(name + "Node_" + id, new Vector3(yAux, z, xAux));
nodeAux.AttachObject(ent);
return nodeAux;
}
}
示例12: InitMogre
public void InitMogre()
{
//-----------------------------------------------------
// 1 enter ogre
//-----------------------------------------------------
root = new Root();
//-----------------------------------------------------
// 2 configure resource paths
//-----------------------------------------------------
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
// Go through all sections & settings in the file
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
// Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
//-----------------------------------------------------
// 3 Configures the application and creates the window
//-----------------------------------------------------
bool foundit = false;
foreach (RenderSystem rs in root.GetAvailableRenderers())
{
root.RenderSystem = rs;
String rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem")
{
foundit = true;
break;
}
}
if (!foundit)
return; //we didn't find it... Raise exception?
//we found it, we might as well use it!
root.RenderSystem.SetConfigOption("Full Screen", "No");
root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");
root.Initialise(false);
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = hWnd.ToString();
window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(1f, 1f, 1f);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
camera = sceneMgr.CreateCamera("SimpleCamera");
camera.Position = new Vector3(400f, 0f, 0f);
// Look back along -Z
camera.LookAt(new Vector3(-1f, 0f, 0f));
camera.NearClipDistance = 5;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);
material = MaterialManager.Singleton.Create("front", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow3.jpg");
material = MaterialManager.Singleton.Create("other", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow.jpg");
material = MaterialManager.Singleton.Create("back", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("back2.jpg");
Vector3 moveVector3 = new Vector3(0f,-60f,110f);
for (int i = 0; i < cubeCount; i++)
{
Cube cube = new Cube();
cube.CubeName = "cube" + i.ToString();
cube.BuildCube("front", ref sceneMgr);
ManualObject manual = sceneMgr.GetManualObject(cube.CubeName);
manual.ConvertToMesh("cubeMesh"+i.ToString());
Entity ent = sceneMgr.CreateEntity("box"+i.ToString(), "cubeMesh"+i.ToString());
//.........这里部分代码省略.........
示例13: init
public bool init()
{
// Start with a new root to get this party started
root = new Root();
// Configuration buisness
ConfigFile config = new ConfigFile();
config.Load("resources.cfg", "\t:=", true);
// Go through all our configuration settings
ConfigFile.SectionIterator itor = config.GetSectionIterator();
string secName, typeName, archName;
// Move through all of the sections
while (itor.MoveNext())
{
secName = itor.CurrentKey;
ConfigFile.SettingsMultiMap settings = itor.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
// Configure our window and set up the RenderSystem
bool found = false;
foreach (RenderSystem rs in root.GetAvailableRenderers())
{
root.RenderSystem = rs;
string rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem")
{
found = true;
break;
}
}
// If we can't find the DirectX rendering system somethign is seriously wrong
if (!found)
return false;
root.RenderSystem.SetConfigOption("Full Screen", "No");
root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");
root.Initialise(false);
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = hWnd.ToString();
window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
// Create our SceneManager
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;
// Create the camera
camMgr = new CamManager();
camMgr.Initialize(ref sceneMgr);
viewport = window.AddViewport(camMgr.mainCam);
viewport.BackgroundColour = new ColourValue(0, 0, 0, 1);
// Load our stick here
LoadModel("TEStick.mesh");
// Set up ground
Plane plane = new Plane(Mogre.Vector3.UNIT_Y, 0);
MeshManager.Singleton.CreatePlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
1500, 1500, 20, 20, true, 1, 5, 5, Mogre.Vector3.UNIT_Z);
Entity ground = sceneMgr.CreateEntity("GroundEnt", "ground");
sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ground);
ground.SetMaterialName("Examples/Rockwall");
ground.CastShadows = false;
// Set up some lights
Light pointLight = sceneMgr.CreateLight("pointLight");
pointLight.Type = Light.LightTypes.LT_POINT;
pointLight.Position = new Mogre.Vector3(0, 150, 250);
pointLight.DiffuseColour = ColourValue.White;
pointLight.SpecularColour = ColourValue.White;
Light directionalLight = sceneMgr.CreateLight("directionalLight");
directionalLight.Type = Light.LightTypes.LT_DIRECTIONAL;
directionalLight.DiffuseColour = new ColourValue(.25f, .25f, 0);
directionalLight.SpecularColour = new ColourValue(.25f, .25f, 0);
directionalLight.Direction = new Mogre.Vector3(0, -1, 1);
Light spotLight = sceneMgr.CreateLight("spotLight");
spotLight.Type = Light.LightTypes.LT_SPOTLIGHT;
spotLight.DiffuseColour = ColourValue.White;
spotLight.SpecularColour = ColourValue.White;
spotLight.Direction = new Mogre.Vector3(-1, -1, 0);
spotLight.Position = new Mogre.Vector3(300, 300, 0);
spotLight.SetSpotlightRange(new Degree(35), new Degree(50));
// Set up our Input
root.FrameRenderingQueued += new FrameListener.FrameRenderingQueuedHandler(Input);
//.........这里部分代码省略.........