public static Mesh CreateMesh <TVert, TInd>(TVert[] vertices, TInd[] indices) where TVert : struct where TInd : struct { Mesh mesh = new Mesh(VertexDescriptor.GetDescriptor <TVert>()); mesh.Layers = new MeshPart[] { new MeshPart(0, indices.Length / 3, 0, vertices.Length, 0) }; mesh.MaterialSlotNames = new string[] { "Material0" }; mesh.CreateVertexBuffer(vertices); mesh.CreateIndexBuffer <TInd>(indices); mesh.ComputeBoundingVolumenes(); return(mesh); }
public static Mesh CreateCapsule(float height, float radius, int capStacks, int capSlices, int trunkStacks, int trunkSlices) { CapsuleBuilder capsule = new CapsuleBuilder(height, radius, capStacks, capSlices, trunkStacks, trunkSlices); Mesh mesh = new Mesh(VertexDescriptor.GetDescriptor <MeshVertex>()); mesh.Layers = new MeshPart[] { new MeshPart(capsule.Top.StartIndex, capsule.Top.PrimitiveCount, capsule.Top.StartVertex, capsule.Top.VertexCount), new MeshPart(capsule.Cylindre.StartIndex, capsule.Cylindre.PrimitiveCount, capsule.Cylindre.StartVertex, capsule.Cylindre.VertexCount), new MeshPart(capsule.Bottom.StartIndex, capsule.Bottom.PrimitiveCount, capsule.Bottom.StartVertex, capsule.Bottom.VertexCount) }; mesh.MaterialSlotNames = new string[] { "Material0" }; mesh.CreateVertexBuffer(capsule.Vertices); mesh.CreateIndexBuffer(capsule.Indices); return(mesh); }
private void InitParticles() { IsTransparent = true; _nbQuads = _particlesBuffer.Length; for (int i = 0; i < _particlesBuffer.Length; i++) { _particlesBuffer[i].Life = -1; _particlesBuffer[i].InvMass = 1f; _particlesBuffer[i].Mass = 1f; _particlesBuffer[i].Color = 0xFFFFFFFF; _particlesBuffer[i].Alpha = 0; } float size = 1; _quads = new ParticleVertex[_nbQuads * 4]; _vd = VertexDescriptor.GetDescriptor <ParticleVertex>(); short[] indices = new short[_nbQuads * 6];; for (int i = 0; i < _nbQuads; i++) { // P0----P1 // | / | // | / | // P3----P2 _quads[4 * i] = new ParticleVertex(-0.5f * size, 0.5f * size, 0, 0, 0); //P0 _quads[4 * i + 1] = new ParticleVertex(0.5f * size, 0.5f * size, 0, 1, 0); //P1 _quads[4 * i + 2] = new ParticleVertex(-0.5f * size, -0.5f * size, 0, 0, 1); //P3 _quads[4 * i + 3] = new ParticleVertex(0.5f * size, -0.5f * size, 0, 1, 1); //P2 indices[6 * i] = (short)(4 * i); indices[6 * i + 1] = (short)(4 * i + 1); indices[6 * i + 2] = (short)(4 * i + 2); indices[6 * i + 3] = (short)(4 * i + 2); indices[6 * i + 4] = (short)(4 * i + 1); indices[6 * i + 5] = (short)(4 * i + 3); } _vb = GraphicDeviceFactory.Device.CreateVertexBuffer(ResourceUsage.Dynamic, CpuAccessFlags.Write, data: _quads); _ib = GraphicDeviceFactory.Device.CreateIndexBuffer(data: indices); }
public BillBoardRender() : base() { _vd = VertexDescriptor.GetDescriptor <VertexPTx>(); _vb = GraphicDeviceFactory.Device.CreateVertexBuffer(data: Vertices); if (this.Effect != null) { _map = Effect.Map <IMap>(); //hWorldViewProj = this.effect.TryGetGlobalSematic(ShaderSemantics.WORLDVIEWPROJ); //hColor = this.effect.TryGetGlobalSematic(ShaderSemantics.COLOR); //hWorld = this.effect.TryGetGlobalSematic(ShaderSemantics.World); //hViewProj = this.effect.TryGetGlobalSematic(ShaderSemantics.VIEWPROJ); } _rastState = GraphicDeviceFactory.Device.CreateRasterizerState(new RasterizerDesc { Cull = CullMode.None }); }
public override Mesh CreateMesh() { return(new Mesh(VertexDescriptor.GetDescriptor <SkinnedVertex>())); }
public virtual Mesh CreateMesh() { return(new Mesh(VertexDescriptor.GetDescriptor <MeshVertex>())); }
public ShapeRender() { _vd = VertexDescriptor.GetDescriptor <MeshVertex>(); _color = new Vector4(1, 1, 1, 1); Distance = 0.5f; }
public object OnCreateResource(ResourceOperationContext context) { return(new Mesh(VertexDescriptor.GetDescriptor(_vertexType))); }