本文整理汇总了C#中SceneManager.CreateManualObject方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateManualObject方法的具体用法?C# SceneManager.CreateManualObject怎么用?C# SceneManager.CreateManualObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SceneManager
的用法示例。
在下文中一共展示了SceneManager.CreateManualObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRectangle
public static ManualObject CreateRectangle(SceneManager sceneMgr, Vector3 pos, Vector3 size, string material = ColoredMaterials.BLUE)
{
Vector3[,] points = new Vector3[2,4];
for (int y = 0; y < 2; y++)
{
points[y, 0] = pos + y * Vector3.UNIT_Y * size.y;
points[y, 1] = pos + new Vector3(1, y, 0) * size;
points[y, 2] = pos + new Vector3(1, y, 1) * size;
points[y, 3] = pos + new Vector3(0, y, 1) * size;
}
ManualObject manOb = sceneMgr.CreateManualObject();
manOb.Begin(material, RenderOperation.OperationTypes.OT_LINE_LIST);
for (int y = 0; y < 2; y++)
{
for (int i = 0; i < 4; i++)
{
manOb.Position(points[y, i]);
manOb.Position(points[y, (i + 1)%4]);
}
}
for (int i = 0; i < 4; i++)
{
manOb.Position(points[0, i]);
manOb.Position(points[1, i]);
}
manOb.End();
return manOb;
}
示例2: CreateLine
public static ManualObject CreateLine(SceneManager sceneMgr, Vector3 p1, Vector3 p2, string material = ColoredMaterials.BLUE)
{
ManualObject manOb = sceneMgr.CreateManualObject();
manOb.Begin(material, RenderOperation.OperationTypes.OT_LINE_LIST);
manOb.Position(p1);
manOb.Position(p2);
manOb.End();
return manOb;
}
示例3: CreateGrid
// create grid
public static void CreateGrid(SceneManager mgr, String name, int numcols, int numrows, float unitsize)
{
ManualObject grid = mgr.CreateManualObject(name);
grid.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);
float width = (float)numcols * unitsize;
float depth = (float)numrows * unitsize;
Vector3 center = new Vector3(-width / 2.0f, 0, -depth / 2.0f);
for (int i = 0; i < numrows; ++i)
{
Vector3 s, e;
s.x = 0.0f;
s.z = i * unitsize;
s.y = 0.0f;
e.x = width;
e.z = i * unitsize;
e.y = 0.0f;
grid.Position(s + center);
grid.Position(e + center);
}
grid.Position(new Vector3(0.0f, 0.0f, numrows * unitsize) + center);
grid.Position(new Vector3(width, 0.0f, numrows * unitsize) + center);
for (int i = 0; i < numcols; ++i)
{
Vector3 s, e;
s.x = i * unitsize;
s.z = depth;
s.y = 0.0f;
e.x = i * unitsize;
e.z = 0.0f;
e.y = 0.0f;
grid.Position(s + center);
grid.Position(e + center);
}
grid.Position(new Vector3(numcols * unitsize, 0.0f, 0.0f) + center);
grid.Position(new Vector3(numcols * unitsize, 0.0f, depth) + center);
grid.End();
mgr.RootSceneNode.AttachObject(grid);
}
示例4: CreateNode
public ManualObject CreateNode(string name, SceneManager sceneMgr, bool useScreenPos)
{
ManualObject manualObj = sceneMgr.CreateManualObject(name);
RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
if (useScreenPos)
manualObj.Begin("CgTutorials/C2E1v_green_Material", operation);
else
manualObj.Begin("CgTutorials/C2E1v_green_Material_2", operation);
manualObj.Position(-0.5f, 0.0f, 0.0f);
manualObj.Position(0.5f, 0.0f, 0.0f);
manualObj.Position(0.0f, 0.5f, 0.0f);
manualObj.End();
return manualObj;
}
示例5: MakeBox
// creates a simple box with specified material
public static MovableObject MakeBox(SceneManager mgr, String materialName, Vector3 dims, Vector2 coord)
{
ManualObject mo = mgr.CreateManualObject();
mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
float w = dims.x * 0.5f;
float h = dims.y * 0.5f;
float d = dims.z * 0.5f;
Vector3[] norm = {
new Vector3( 1.0f, 0.0f, 0.0f),
new Vector3( 0.0f, 1.0f, 0.0f),
new Vector3( 0.0f, 0.0f, 1.0f),
new Vector3(-1.0f, 0.0f, 0.0f),
new Vector3( 0.0f,-1.0f, 0.0f),
new Vector3( 0.0f, 0.0f,-1.0f)
};
Vector3[] geom = { // 6 faces x 4 vertexes
new Vector3(+w,-h,+d), new Vector3(+w,-h,-d), new Vector3(+w,+h,-d), new Vector3(+w,+h,+d),
new Vector3(+w,+h,+d), new Vector3(+w,+h,-d), new Vector3(-w,+h,-d), new Vector3(-w,+h,+d),
new Vector3(+w,+h,+d), new Vector3(-w,+h,+d), new Vector3(-w,-h,+d), new Vector3(+w,-h,+d),
new Vector3(-w,-h,+d), new Vector3(-w,+h,+d), new Vector3(-w,+h,-d), new Vector3(-w,-h,-d),
new Vector3(-w,-h,+d), new Vector3(-w,-h,-d), new Vector3(+w,-h,-d), new Vector3(+w,-h,+d),
new Vector3(-w,-h,-d), new Vector3(-w,+h,-d), new Vector3(+w,+h,-d), new Vector3(+w,-h,-d)
};
// texcoords
Vector2[] uvs = { new Vector2(0, 0), new Vector2(0, coord.y), coord, new Vector2(coord.x, 0) };
for(int i=0; i<6; i++){ // 6 faces
uint k = (uint)(i * 4);
for(int j=0; j<4; j++){ // 4 verts
mo.Position(geom[k+j]);
mo.Normal(norm[i]);
mo.TextureCoord(uvs[j]);
}
mo.Quad(k,k+1,k+2,k+3);
}
mo.End();
return mo;
}
示例6: CreateNode
public ManualObject CreateNode(string name, SceneManager sceneMgr)
{
ManualObject manualObj = sceneMgr.CreateManualObject(name);
RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
MaterialPtr material = MaterialManager.Singleton.Create("Test/Tutorial00",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
material.GetTechnique(0).GetPass(0).VertexColourTracking =
(int)TrackVertexColourEnum.TVC_AMBIENT;
manualObj.Begin("Test/Tutorial00", operation);
manualObj.Position(-5.0f, 0.0f, 0.0f);
manualObj.Position(5.0f, 0.0f, 0.0f);
manualObj.Position(0.0f, 5.0f, 0.0f);
manualObj.End();
return manualObj;
}
示例7: BuildPlane
public void BuildPlane(string materialName,ref SceneManager mSceneMgr)
{
float z = planeWidth / 2;
float y = planeHeight / 2;
float x = -40f;
ManualObject cube = mSceneMgr.CreateManualObject(planeName);
cube.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_FAN);
cube.Position(x, -y, -z);
cube.TextureCoord(1, 1);
cube.Position(x, y, -z);
cube.TextureCoord(1, 0);
cube.Position(x, y, z);
cube.TextureCoord(0, 0);
cube.Position(x, -y, z);
cube.TextureCoord(0, 1);
//
// cube.Triangle(0, 2, 1);
// cube.Triangle(0, 2, 3);
cube.End();
}
示例8: MakeHud
// create a 2D hud element: pos = [-1;1] & size = (pixels)
public static MovableObject MakeHud(SceneManager mgr, Viewport vp, String materialName, Vector2 pos, Vector2 size)
{
// Create a manual object for 2D
ManualObject manual = mgr.CreateManualObject();
// Use identity view/projection matrices
manual.UseIdentityProjection = true;
manual.UseIdentityView = true;
// convert from pixels to screen coords
float s = size.x / vp.ActualWidth;
float t = size.y / vp.ActualHeight;
manual.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);
manual.Position(pos.x - s, pos.y - t, 0.0f); manual.TextureCoord(0, 1);
manual.Position(pos.x + s, pos.y - t, 0.0f); manual.TextureCoord(1, 1);
manual.Position(pos.x + s, pos.y + t, 0.0f); manual.TextureCoord(1, 0);
manual.Position(pos.x - s, pos.y + t, 0.0f); manual.TextureCoord(0, 0);
manual.Index(0);
manual.Index(1);
manual.Index(2);
manual.Index(3);
manual.Index(0);
manual.End();
// Use infinite AAB to always stay visible
AxisAlignedBox aabInf = new AxisAlignedBox();
aabInf.SetInfinite();
manual.BoundingBox = aabInf;
// Render just before overlays
manual.RenderQueueGroup = (byte)(RenderQueueGroupID.RENDER_QUEUE_OVERLAY-1);
manual.CastShadows = false;
// Attach to scene
mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual);
return manual;
}
示例9: MakeDummy
// creates a wireframe octahedron as a dummy model
public static MovableObject MakeDummy(SceneManager mgr, String name, String materialName, float size)
{
ManualObject dummy = mgr.CreateManualObject(name);
dummy.Begin(materialName, RenderOperation.OperationTypes.OT_LINE_LIST);
// octahedron wire shape
Vector3[] points = {
new Vector3(0,size,0), new Vector3(0,0,size),
new Vector3(0,size,0), new Vector3(0,0,-size),
new Vector3(0,size,0), new Vector3(-size,0,0),
new Vector3(0,size,0), new Vector3(size,0,0),
new Vector3(0,-size,0), new Vector3(0,0,size),
new Vector3(0,-size,0), new Vector3(0,0,-size),
new Vector3(0,-size,0), new Vector3(-size,0,0),
new Vector3(0,-size,0), new Vector3(size,0,0),
new Vector3(-size,0,0), new Vector3(0,0,size),
new Vector3(0,0,size), new Vector3(size,0,0),
new Vector3(size,0,0), new Vector3(0,0,-size),
new Vector3(0,0,-size), new Vector3(-size,0,0),
};
foreach (Vector3 v in points)
{
dummy.Position(v);
}
dummy.End();
return dummy;
}
示例10: Initialise
public void Initialise(SceneManager aSceneManager, float aFillAlpha)
{
if (isInitialised) {
// Initialization multiple call guard
return;
}
if (aSceneManager == null) {
return;
}
m_sceneManager = aSceneManager;
fillAlpha = aFillAlpha;
m_manualObject = null;
linesIndex = 0;
trianglesIndex = 0;
m_manualObject = m_sceneManager.CreateManualObject("debugDrawer_object");
m_manualObject.CastShadows = false;
m_sceneManager.RootSceneNode.CreateChildSceneNode("debugDrawer_object").AttachObject(m_manualObject);
m_manualObject.Dynamic = (true);
icoSphere.Create(this.DEFAULT_ICOSPHERE_RECURSION_LEVEL);
m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_LINE_LIST);
m_manualObject.Position(Vector3.ZERO);
m_manualObject.Colour(ColourValue.ZERO);
m_manualObject.Index(0);
m_manualObject.End();
m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
m_manualObject.Position(Vector3.ZERO);
m_manualObject.Colour(ColourValue.ZERO);
m_manualObject.Index(0);
m_manualObject.End();
trianglesIndex = 0;
linesIndex = trianglesIndex;
isInitialised = true;
// Initialization multiple call guard
}
示例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: CreateNode
public ManualObject CreateNode(string name, SceneManager sceneMgr, bool isClosed, int useMaterial, Vector4 color)
{
if (lines3d == null)
{
lines3d = sceneMgr.CreateManualObject(name);
for (int i = 0; i < pointsList.Count - 1; i++)
{
CreateLine(lines3d, pointsList[i], pointsList[i + 1], useMaterial, color);
}
if (isClosed && pointsList.Count > 1)
{
CreateLine(lines3d, pointsList[pointsList.Count - 1], pointsList[0], useMaterial, color);
}
}
return lines3d;
}
示例13: CreateNode
public ManualObject CreateNode(string name, SceneManager sceneMgr, bool isClosed)
{
if (lineNode == null)
{
lineNode = sceneMgr.CreateManualObject(name);
MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
material.GetTechnique(0).GetPass(0).VertexColourTracking =
(int)TrackVertexColourEnum.TVC_AMBIENT;
int nSeg = 5; // Number of segments on the cap or join pieces
BufferParameters param = new BufferParameters(nSeg, BufferParameters.BufferEndCapStyle.CapRound, BufferParameters.BufferJoinStyle.JoinRound, 2);
IGeometry coordBuffer = line1.Buffer(0.5, param);
Tesselate(coordBuffer.Coordinates);
}
return lineNode;
}
示例14: CreateTestTetrahedron
public static SceneNode CreateTestTetrahedron(SceneManager sm, string name, float scale, Mogre.Vector3 position, String materialName)
{
var mo = sm.CreateManualObject(name);
mo.CastShadows = true;
var node = sm.RootSceneNode.CreateChildSceneNode();
Mogre.Vector3[] c = new Mogre.Vector3[4]; // corners
// calculate corners of tetrahedron (with point of origin in middle of volume)
Single mbot = scale * 0.2f; // distance middle to bottom
Single mtop = scale * 0.62f; // distance middle to top
Single mf = scale * 0.289f; // distance middle to front
Single mb = scale * 0.577f; // distance middle to back
Single mlr = scale * 0.5f; // distance middle to left right
// width / hight / depth
c[0] = new Mogre.Vector3(-mlr, -mbot, mf); // left bottom front
c[1] = new Mogre.Vector3(mlr, -mbot, mf); // right bottom front
c[2] = new Mogre.Vector3(0, -mbot, -mb); // (middle) bottom back
c[3] = new Mogre.Vector3(0, mtop, 0); // (middle) top (middle)
// add position offset for all corners (move tetrahedron)
for (Int16 i = 0; i <= 3; i++)
c[i] += position;
// create bottom
mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
var normal = (c[1] - c[0]).CrossProduct(c[1] - c[2]).NormalisedCopy;
var normalA = normal;
var normalB = normal;
var normalC = normal;
//this is an attempt to try to make it seem softer.
normalA.x += 2f;
normalA.y += 0.5f;
normalB.y -= 2f;
normalB.x -= 0.5f;
mo.Position(c[0]);
mo.Normal(normalA);
mo.TextureCoord(0, 0);
mo.Position(c[1]);
mo.Normal(normalB);
mo.TextureCoord(0, 1);
mo.Position(c[2]);
mo.Normal(normalC);
mo.TextureCoord(1, 1);
mo.Triangle(0, 1, 2);
mo.Triangle(0, 2, 1);
mo.End();
float lineLen = scale / 3;
// create right back side
mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
normal = (c[1] - c[2]).CrossProduct(c[1] - c[3]).NormalisedCopy;
normalA = normal;
normalB = normal;
normalC = normal;
normalA.x += 2f;
normalA.y += 0.5f;
normalB.y -= 2f;
normalB.x -= 0.5f;
mo.Position(c[1]);
mo.Normal(normalA);
mo.Position(c[2]);
mo.Normal(normalB);
mo.Position(c[3]);
mo.Normal(normalC);
mo.Triangle(0, 1, 2);
mo.Triangle(0, 2, 1);
mo.End();
// create left back side
normal = (c[0] - c[2]).CrossProduct(c[2] - c[3]);
mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
mo.Position(c[3]);
mo.Normal(normal);
mo.Position(c[2]);
mo.Normal(normal);
mo.Position(c[0]);
mo.Normal(normal);
mo.Triangle(0, 1, 2);
mo.Triangle(0, 2, 1);
mo.End();
// create front side
normal = (c[1] - c[3]).CrossProduct(c[0] - c[3]);
mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
//.........这里部分代码省略.........
示例15: CreateBoidMesh
/*
static public void CreateBoidMesh(string name, string color)
{
Vector3[] colors = baseColors;
if (color.Equals("green"))
{
colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f);
}
else if (color.Equals("red"))
{
colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f);
}
// Return now if already exists
if (MeshManager.Singleton.ResourceExists(name))
return;
MeshBuilderHelper mbh = new MeshBuilderHelper(name, "Flocking", false, 0, (uint)pts.Length);
UInt32 offPos = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION).Offset;
UInt32 offDiff = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_DIFFUSE).Offset;
mbh.CreateVertexBuffer(HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
for (int count = 0; count < pts.Length; count++)
{
mbh.SetVertFloat((uint)count, offPos, pts[count].x, pts[count].y, pts[count].z); //position
mbh.SetVertFloat((uint)count, offDiff, colors[count].x, colors[count].y, colors[count].z); //color
}
mbh.CreateIndexBuffer((uint)(indices.Length / 3), HardwareIndexBuffer.IndexType.IT_16BIT, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
for (uint index = 0; index < indices.Length / 3; index++)
{
mbh.SetIndex16bit(index, (UInt16)(indices[index * 3]),
(UInt16)(indices[index * 3 + 1]),
(UInt16)(indices[index * 3 + 2]));
}
MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourTest", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;
MeshPtr m = mbh.Load("Test/ColourTest");
m._setBounds(new AxisAlignedBox(-1.0f, -1.0f, -1.0f,
1.0f, 1.0f, 1.0f), false);
m._setBoundingSphereRadius((float)System.Math.Sqrt(1.0f * 1.0f + 1.0f * 1.0f));
}
*/
public static ManualObject CreateBoidObject(string name, SceneManager sceneMgr, string color)
{
Vector3[] colors = baseColors;
if (color.Equals("green"))
{
colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f);
}
else if (color.Equals("red"))
{
colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f);
}
// Return now if already exists
if (MeshManager.Singleton.ResourceExists(name))
return null;
ManualObject boidObj = sceneMgr.CreateManualObject(name);
RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/Boid", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;
boidObj.Begin("Test/Boid", operation);
for (int count = 0; count < pts.Length; count++)
{
boidObj.Position(pts[count]); //position
boidObj.Colour(colors[count].x, colors[count].y, colors[count].z); //color
}
for (uint index = 0; index < indices.Length / 3; index++)
{
boidObj.Index((ushort)(indices[index * 3]));
boidObj.Index((ushort)(indices[index * 3 + 1]));
boidObj.Index((ushort)(indices[index * 3 + 2]));
}
boidObj.End();
return boidObj;
}