/// <summary> /// Called at first-time load, loads required resources. /// </summary> /// <param name="sender">The sending object</param> /// <param name="e">The empty event args object</param> static void Window_Load(object sender, EventArgs e) { SysConsole.Output(OutputType.INIT, "Loading texture engine..."); Texture.InitTextureSystem(); SysConsole.Output(OutputType.INIT, "Loading shader engine..."); Shader.InitShaderSystem(); SysConsole.Output(OutputType.INIT, "Loading text engine..."); GLFont.Init(); SysConsole.Output(OutputType.INIT, "Loading font-set engine..."); FontSet.Init(); SysConsole.Output(OutputType.INIT, "Loading 3D model engine..."); Model.Init(); SysConsole.Output(OutputType.INIT, "Loading rendering helper engine..."); Renderer.Init(); SysConsole.Output(OutputType.INIT, "Adjusting OpenGL settings..."); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Texture2D); GL.Viewport(0, 0, Window.Width, Window.Height); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Front); SysConsole.Output(OutputType.INIT, "Loading material->texture map..."); MaterialTexture.Init(); SysConsole.Output(OutputType.INIT, "Loading keyboard handling engine..."); KeyHandler.Init(); SysConsole.Output(OutputType.INIT, "Loading interactive console engine..."); UIConsole.InitConsole(); SysConsole.Output(OutputType.INIT, "Loading world..."); InitWorld(); SysConsole.Output(OutputType.INIT, "Displaying window..."); }
public void PasteMaterialOnCenter(Texture2D material, Vector2Int pos) { MaterialTexture.Paste( texture, blueprintMask, material, pos - new Vector2Int(material.width / 2, material.height / 2)); }
void Start() { origBlueprint = MaterialTexture.Copy(Resources.Load <Texture2D>("Blueprints/body_blueprint")); mask = MaterialShape.GenerateMask( Resources.Load <Texture2D>("Blueprints/body_blueprint_mask") ); wood = Resources.Load <Texture2D>("Materials/BaseTexture/wood"); nyan = Resources.Load <Texture2D>("Materials/BaseTexture/nyan"); UpdateSprite(); }
public MaterialTexture Clone() { MaterialTexture nmt = new MaterialTexture(); for (int i = 0; i < m_textures.Count; ++i) { nmt.Add(m_textures[i]); } return(nmt); }
public void SetPart(PartType type, Texture2D blueprint, Texture2D blueprintMask) { this.type = type; this.texture = MaterialTexture.Copy(blueprint); this.blueprintMask = MaterialShape.GenerateMask(blueprintMask); GetComponent <Image>().sprite = Sprite.Create( texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); GetComponent <RectTransform>().sizeDelta = new Vector2(texture.width, texture.height); }
public static MaterialItem CreateFromTemplate( string name, Vector2Int size, Vector2[] shape, Texture2D baseTexture, Vector2Int baseStart) { bool[,] shapeMask = MaterialShape.PolygonFillMask(size.y, size.x, shape, true); Texture2D texture = MaterialTexture.CreateTextureFromMask(shapeMask, baseTexture, baseStart); return(new MaterialItem(name, Sprite.Create( texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)))); }
public void UpdateSprite() { bool[,] shapeMask = MaterialShape.PolygonFillMask(512, 256, MaterialShape.square, true); Texture2D shape = MaterialTexture.CreateTextureFromMask( shapeMask, nyan, new Vector2Int(x, y)); blueprint = MaterialTexture.Copy(origBlueprint); MaterialTexture.Paste(blueprint, mask, shape, Vector2Int.zero); GetComponent <Image>().sprite = Sprite.Create( blueprint, new Rect(0, 0, blueprint.width, blueprint.height), new Vector2(0.5f, 0.5f)); }
private DisposableList <MaterialTexture> CreateResizedTextures(int newWidth, int newHeight) { DisposableList <MaterialTexture> resized = new DisposableList <MaterialTexture>(); for (int i = 0; i < m_textures.Count; ++i) { MaterialTexture newMT = new MaterialTexture(); for (int k = 0; k < m_textures[i].Count; ++k) { int targetWidth = Mathf.Min(newWidth, m_textures[i][k].Width); int targetHeight = Mathf.Min(newHeight, m_textures[i][k].Height); WorkingTexture resizedTexture = m_textures[i][k].Resize(Allocator.Persistent, targetWidth, targetHeight); newMT.Add(resizedTexture); resizedTexture.Dispose(); } resized.Add(newMT); } return(resized); }
public static void Stuff(object target, FormatBase feed, string logPrefix = null, bool muteLogging = false) { foreach (PropertyInfo prop in target.GetType().GetProperties()) { if (prop.CanWrite) { MethodInfo setter = prop.GetSetMethod(); if (setter == null || !setter.IsPublic) { continue; } Type type = prop.PropertyType; object set = null; if (type.Equals(typeof(Int16))) { set = feed.readInt16(); } else if (type.Equals(typeof(Int32))) { set = feed.readInt32(); } else if (type.Equals(typeof(Int64))) { set = feed.readInt64(); } else if (type.Equals(typeof(UInt16))) { set = feed.readUInt16(); } else if (type.Equals(typeof(byte))) { set = feed.readUInt8(); } else if (type.Equals(typeof(UInt32))) { set = feed.readUInt32(); } else if (type.Equals(typeof(UInt64))) { set = feed.readUInt64(); } else if (type.Equals(typeof(float))) { set = feed.readFloat(); } else if (type.Equals(typeof(double))) { set = feed.readDouble(); } else if (type.Equals(typeof(string))) { set = feed.readString(); } else if (type.Equals(typeof(Position))) { set = Position.Read(feed); } else if (type.Equals(typeof(C4Plane))) { set = C4Plane.Read(feed); } else if (type.Equals(typeof(Colour4))) { set = Colour4.Read(feed); } else if (type.Equals(typeof(Rotation))) { set = Rotation.Read(feed); } else if (type.Equals(typeof(MaterialTexture))) { set = MaterialTexture.Read(feed); } // This is some hacky-ass code, but it allows MCNK chunk to use // the stuffer without code bloat. Probably could be done better. if (set == null) { if (type.Equals(typeof(UInt32[]))) { int size = ((UInt32[])prop.GetValue(target, null)).Length; UInt32[] arr = new UInt32[size]; for (int i = 0; i < size; i++) { arr[i] = feed.readUInt32(); } set = arr; } } if (set != null) { prop.SetValue(target, set, null); #if !DEBUG if (!muteLogging) #endif Log.Write("{0}{1} -> {2}", logPrefix == null ? string.Empty : logPrefix, prop.Name, set); } else { Log.Write("WARNING: Stuffer was not prepared to handle {0}!", type.Name); } } } }
private static MaterialTexture CreateMaterialTextureFromAiTextureSlot(Ai.TextureSlot aiTextureSlot, Ai.Material aiMaterial, Material material, TextureSet textureSet, string texturesDirectoryPath) { MaterialTextureType type; MaterialFlags flags; // skyth y u no use dictionary switch (aiTextureSlot.TextureType) { case Ai.TextureType.Diffuse: case Ai.TextureType.Ambient: type = MaterialTextureType.Color; flags = MaterialFlags.Color; break; case Ai.TextureType.Specular: type = MaterialTextureType.Specular; flags = MaterialFlags.Specular; break; case Ai.TextureType.Normals: type = MaterialTextureType.Normal; flags = MaterialFlags.Normal; break; case Ai.TextureType.Opacity: type = MaterialTextureType.Transparency; flags = MaterialFlags.Transparency; break; case Ai.TextureType.Reflection: type = MaterialTextureType.Reflection; flags = MaterialFlags.Environment; break; default: return(null); } int materialTextureIndex = -1; for (int i = 0; i < material.MaterialTextures.Length; i++) { if (material.MaterialTextures[i].Type != MaterialTextureType.None) { continue; } materialTextureIndex = i; break; } if (materialTextureIndex == -1) { return(null); } var texture = CreateTextureFromFilePath(aiTextureSlot.FilePath, type == MaterialTextureType.Normal ? TextureFormat.ATI2 : TextureFormat.Unknown, texturesDirectoryPath, textureSet); if (texture == null) { return(null); } var materialTexture = new MaterialTexture(); materialTexture.RepeatU = aiTextureSlot.WrapModeU == Ai.TextureWrapMode.Wrap; materialTexture.RepeatV = aiTextureSlot.WrapModeV == Ai.TextureWrapMode.Wrap; materialTexture.MirrorU = aiTextureSlot.WrapModeU == Ai.TextureWrapMode.Mirror; materialTexture.MirrorV = aiTextureSlot.WrapModeV == Ai.TextureWrapMode.Mirror; materialTexture.ClampToEdge = aiTextureSlot.WrapModeU == Ai.TextureWrapMode.Clamp && aiTextureSlot.WrapModeV == Ai.TextureWrapMode.Clamp; if (texture.ArraySize == 6 || aiTextureSlot.Mapping == Ai.TextureMapping.Box) { materialTexture.TextureCoordinateTranslationType = MaterialTextureCoordinateTranslationType.Cube; if (type == MaterialTextureType.Reflection) { type = MaterialTextureType.EnvironmentCube; } } else if (aiTextureSlot.Mapping == Ai.TextureMapping.Sphere) { materialTexture.TextureCoordinateTranslationType = MaterialTextureCoordinateTranslationType.Sphere; if (type == MaterialTextureType.Reflection) { type = MaterialTextureType.EnvironmentSphere; } } materialTexture.Blend = type == MaterialTextureType.Specular ? 1u : 7; materialTexture.Filter = 2; materialTexture.MipMap = 2; materialTexture.Type = type; materialTexture.TextureId = texture.Id; material.Flags |= flags; material.MaterialTextures[materialTextureIndex] = materialTexture; return(materialTexture); }
private static void _client_Started() { var world = new World(); var commandRecorder = new EntityCommandRecorder(); var scene = new Scene("Client", world, commandRecorder); var factory = _client.GraphicsDevice.ResourceFactory; var materialInputLayouts = new MaterialInputLayouts(); var textureLayout = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("SurfaceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment), new ResourceLayoutElementDescription("SurfaceSampler", ResourceKind.Sampler, ShaderStages.Fragment), new ResourceLayoutElementDescription("TextureColour", ResourceKind.UniformBuffer, ShaderStages.Fragment))); materialInputLayouts.ResourceLayouts["Texture"] = textureLayout; materialInputLayouts.ResourceLayouts["WorldTransform"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("WorldBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex))); materialInputLayouts.ResourceLayouts["SceneInputs"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("ProjectionBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("ViewBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("SceneLighting", ResourceKind.UniformBuffer, ShaderStages.Fragment))); materialInputLayouts.ResourceLayouts["CameraInputs"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("CameraInfo", ResourceKind.UniformBuffer, ShaderStages.Vertex))); materialInputLayouts.VertexLayouts["Model"] = new VertexLayoutDescription( new VertexElementDescription("Position", VertexElementSemantic.Position, VertexElementFormat.Float3), new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2), new VertexElementDescription("Normal", VertexElementSemantic.Normal, VertexElementFormat.Float3)); materialInputLayouts.VertexLayouts["Lighting"] = new VertexLayoutDescription( new VertexElementDescription("Light", VertexElementSemantic.Color, VertexElementFormat.Float1)); var mesh3dMaterial = new Material(_client.GraphicsDevice, _client.MainSceneFramebuffer, _client.Resources.LoadText("Shaders\\Mesh.vs"), _client.Resources.LoadText("Shaders\\Mesh.fg"), new string[] { "Model" }, new string[] { "SceneInputs", "WorldTransform", "Texture" }, materialInputLayouts); var lightMeshMaterial = new Material(_client.GraphicsDevice, _client.MainSceneFramebuffer, _client.Resources.LoadText("Shaders\\LightMesh.vs"), _client.Resources.LoadText("Shaders\\LightMesh.fg"), new string[] { "Model", "Lighting" }, new string[] { "SceneInputs", "WorldTransform", "Texture", "CameraInputs" }, materialInputLayouts); var voxelTexturesResource = _client.Resources.LoadImage("Textures\\spritesheet_tiles.png"); var voxelTexture = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.White); var redVoxelTexture = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.Red); var semiTransVoxelColour = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, new RgbaFloat(1.0f, 1.0f, 1.0f, 0.8f)); Action <Entity> setVoxelRender = (Entity e) => { e.Set(new LightVertexResources()); e.Set(lightMeshMaterial); e.Set(voxelTexture); }; var networkedEntities = new NetworkedEntities(world); var clientSystem = new ClientSystem(world, _messageTargetMap, _clientMessagingChannel); clientSystem.AddListener(new TransformMessageApplier(networkedEntities)); clientSystem.AddListener(new ClientEntityAssignmentApplier(networkedEntities)); clientSystem.AddListener(new VoxelSpaceMessageApplier(networkedEntities)); clientSystem.AddListener(new VoxelGridMessageApplier(setVoxelRender, networkedEntities)); clientSystem.AddListener(new VoxelGridChangeMessageApplier(networkedEntities)); clientSystem.AddListener(new EntityRemover(networkedEntities)); clientSystem.AddListener(new ComponentSyncMessageApplier <EntityMetaData>(networkedEntities)); scene.AddSystem(clientSystem); var parallelRunner = new DefaultParallelRunner(8); var px = Image.Load("Assets\\Textures\\cloudtop_rt.png"); var nx = Image.Load("Assets\\Textures\\cloudtop_lf.png"); var py = Image.Load("Assets\\Textures\\cloudtop_up.png"); var ny = Image.Load("Assets\\Textures\\cloudtop_dn.png"); var pz = Image.Load("Assets\\Textures\\cloudtop_bk.png"); var nz = Image.Load("Assets\\Textures\\cloudtop_ft.png"); scene.AddSystem(new SkyboxRenderer(_client.GraphicsDevice, _client.MainSceneFramebuffer, px, nx, py, ny, pz, nz)); scene.AddSystem(new MeshGeometryRenderer(_client.GraphicsDevice, materialInputLayouts, world)); scene.AddSystem(new LightMeshGeometryRenderer(_client.GraphicsDevice, materialInputLayouts, world)); var voxelTypes = LoadVoxelTypes(); var editors = new List <IEditor>() { new SelectedEntitySystem(world), new EntityInspector(world), new EntityList(world), new SystemList(scene), new VoxelEditor(_clientMessagingChannel, world, voxelTypes.Select((t, i) => (t.Name, new Voxel() { Exists = true, BlockType = (ushort)i })).ToArray()), new VoxelSpaceLoader(_clientMessagingChannel, world) }; _editorMenu.AddEditorSet("Client", editors); scene.AddSystem(_editorMenu); scene.AddSystems(editors); scene.AddSystem(new SunLightPropogationSystem(world, new VoxelTypes(voxelTypes))); scene.AddSystem(new VoxelGridMesher(commandRecorder, world, new VoxelTypes(voxelTypes), _client.GraphicsDevice, parallelRunner)); scene.AddSystem(new MeshGeometryCleaner(world)); scene.AddSystem(new LightVertexCleaner(world)); scene.AddSystem(new TransformLerper(networkedEntities, world)); scene.AddSystem(new FlagClearingSystem <NeighbourMemberChanged>(world)); scene.AddSystem(new InputForceApplierInputSystem(_clientMessagingChannel, world)); scene.AddSystem(new SimpleCameraMoverInputSystem(_clientMessagingChannel, world)); world.SubscribeEntityDisposed((in Entity e) => { if (e.Has <VoxelGrid>()) { var voxelGrid = e.Get <VoxelGrid>(); voxelGrid.VoxelSpace.Remove(voxelGrid.MemberIndex); } });
public void Parse(GameBitBuffer buffer) { Field0 = buffer.ReadInt(32); Field1 = buffer.ReadInt(32); Field2 = buffer.ReadInt(32); Field3 = new MaterialTexture(); Field3.Parse(buffer); Field4 = buffer.ReadInt(32); Field5 = buffer.ReadInt(32); Field6 = buffer.ReadFloat32(); Field7 = new LightStateParams(); Field7.Parse(buffer); Field8 = new LightStateParams(); Field8.Parse(buffer); }
public void Parse(GameBitBuffer buffer) { Field0 = buffer.ReadInt(32); Field1 = new MaterialTexture(); Field1.Parse(buffer); }
protected override void Initialize() { var factory = GraphicsDevice.ResourceFactory; var materialInputLayouts = new MaterialInputLayouts(); var textureLayout = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("SurfaceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment), new ResourceLayoutElementDescription("SurfaceSampler", ResourceKind.Sampler, ShaderStages.Fragment), new ResourceLayoutElementDescription("TextureColour", ResourceKind.UniformBuffer, ShaderStages.Fragment))); materialInputLayouts.ResourceLayouts["Texture"] = textureLayout; materialInputLayouts.ResourceLayouts["WorldTransform"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("WorldBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex))); materialInputLayouts.ResourceLayouts["SceneInputs"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("ProjectionBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("ViewBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("SceneLighting", ResourceKind.UniformBuffer, ShaderStages.Fragment))); materialInputLayouts.ResourceLayouts["CameraInputs"] = factory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("CameraInfo", ResourceKind.UniformBuffer, ShaderStages.Vertex))); materialInputLayouts.VertexLayouts["Model"] = new VertexLayoutDescription( new VertexElementDescription("Position", VertexElementSemantic.Position, VertexElementFormat.Float3), new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2), new VertexElementDescription("Normal", VertexElementSemantic.Normal, VertexElementFormat.Float3)); materialInputLayouts.VertexLayouts["Lighting"] = new VertexLayoutDescription( new VertexElementDescription("Light", VertexElementSemantic.Color, VertexElementFormat.Float1)); var mesh3dMaterial = new Material(GraphicsDevice, MainSceneFramebuffer, Resources.LoadText("Shaders\\Mesh.vs"), Resources.LoadText("Shaders\\Mesh.fg"), new string[] { "Model" }, new string[] { "SceneInputs", "WorldTransform", "Texture" }, materialInputLayouts); var lightMeshMaterial = new Material(GraphicsDevice, MainSceneFramebuffer, Resources.LoadText("Shaders\\LightMesh.vs"), Resources.LoadText("Shaders\\LightMesh.fg"), new string[] { "Model", "Lighting" }, new string[] { "SceneInputs", "WorldTransform", "Texture", "CameraInputs" }, materialInputLayouts); var voxelTexturesResource = Resources.LoadImage("Textures\\spritesheet_tiles.png"); var voxelTexture = new MaterialTexture(GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.White); var redVoxelTexture = new MaterialTexture(GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.Red); var semiTransVoxelColour = new MaterialTexture(GraphicsDevice, textureLayout, voxelTexturesResource, new RgbaFloat(1.0f, 1.0f, 1.0f, 0.8f)); Action <Entity> setVoxelRender = (Entity e) => { e.Set(lightMeshMaterial); e.Set(voxelTexture); }; var parallelRunner = new DefaultParallelRunner(4); var player = Scene.World.CreateEntity(); var playerTransform = new Transform(); playerTransform.Position = new Vector3(0, 40, 0); player.Set(playerTransform); player.Set(new Camera()); var worldVoxelSpace = Scene.World.CreateEntity(); worldVoxelSpace.Set(new Transform()); worldVoxelSpace.Set(new VoxelSpace(32, 1, worldVoxelSpace)); var px = Image.Load("Assets\\Textures\\cloudtop_rt.png"); var nx = Image.Load("Assets\\Textures\\cloudtop_lf.png"); var py = Image.Load("Assets\\Textures\\cloudtop_up.png"); var ny = Image.Load("Assets\\Textures\\cloudtop_dn.png"); var pz = Image.Load("Assets\\Textures\\cloudtop_bk.png"); var nz = Image.Load("Assets\\Textures\\cloudtop_ft.png"); Scene.RendererSystems.Add(new SkyboxRenderer(GraphicsDevice, MainSceneFramebuffer, px, nx, py, ny, pz, nz)); Scene.RendererSystems.Add(new MeshGeometryRenderer(GraphicsDevice, materialInputLayouts, Scene.World)); Scene.RendererSystems.Add(new LightMeshGeometryRenderer(GraphicsDevice, materialInputLayouts, Scene.World)); var physicsSystem = new PhysicsSystem(); var voxelTypes = LoadVoxelTypes(); var tools = new List <ITool>() { new RemoveVoxelEditingTool((e) => { e.Set(lightMeshMaterial); e.Set(redVoxelTexture); }, Scene.World, physicsSystem, player) }; tools.AddRange(voxelTypes.Select((type, i) => new BasicVoxelAddingTool(type.Name, (ushort)i, (e) => { e.Set(lightMeshMaterial); e.Set(semiTransVoxelColour); }, Scene.World, physicsSystem, player))); Scene.LogicSystems.Add(new EditorMenu(Scene, new List <IEditor>() { new EditorConsole(Scene), new Toolbar(tools.ToArray()), new SelectedEntitySystem(Scene.World), new PhysicsEntitySelector(Scene.World, physicsSystem, playerTransform), new EntityInspector(Scene.World), new EntityList(Scene.World), new SystemList(Scene), new VoxelSpaceLoader(Scene.World, playerTransform, setVoxelRender) })); Scene.LogicSystems.Add(new SimpleCameraMover(player, physicsSystem, Scene.World)); Scene.LogicSystems.Add(new WorldSpaceLoader(setVoxelRender, Scene.World, playerTransform, worldVoxelSpace, 10, 3, 32)); Scene.LogicSystems.Add(new ChunkGeneratorSystem(Scene, parallelRunner, new ChunkGenerator())); Scene.LogicSystems.Add(new VoxelSpaceExpanderSystem(setVoxelRender, Scene.World)); Scene.LogicSystems.Add(new InputForceApplier(physicsSystem, Scene.World)); Scene.LogicSystems.Add(new PhysicsBlockFinder(Scene.World, parallelRunner)); Scene.LogicSystems.Add(new ParallelSystem <double>(parallelRunner, new SequentialSystem <double>( new VoxelSpaceChangePropogator(Scene.World), new VoxelStaticBodyGenerator(physicsSystem, Scene.World), new VoxelSpaceDynamicBodyGenerator(physicsSystem, Scene.World), physicsSystem, new DynamicBodyPositionSync(Scene.World)), new SunLightPropogationSystem(new VoxelTypes(voxelTypes), Scene))); Scene.LogicSystems.Add(new VoxelGridMesher(Scene, new VoxelTypes(voxelTypes), GraphicsDevice, parallelRunner)); Scene.LogicSystems.Add(new CharacterInputSystem(physicsSystem, Scene.World)); Scene.LogicSystems.Add(new MeshGeometryCleaner(Scene.World)); Scene.LogicSystems.Add(new LightVertexCleaner(Scene.World)); Scene.LogicSystems.Add(new FlagClearingSystem <NeighbourMemberChanged>(Scene.World)); //var cylinder = Scene.World.CreateEntity(); //AddCylinder(cylinder, mesh3dMaterial, voxelTexture); }
private static void AddCylinder(Entity entity, GraphicsDevice device, Material material, MaterialTexture materialTexture) { entity.Set(new Transform()); entity.Set(material); entity.Set(materialTexture); var cylinder = PrimitiveMeshGenerator.GenerateCapsule(1, 0.3f); var mesh = new RenderableMeshGeometry() { Vertices = new ResizableBuffer <VertexPositionTextureNormal>(device, VertexPositionTextureNormal.SizeInBytes, BufferUsage.VertexBuffer, cylinder .Select(v => new VertexPositionTextureNormal(v.Vertex, new Vector2(20, 20), v.Normal)) .ToArray()), Indices = new ResizableBuffer <ushort>(device, sizeof(ushort), BufferUsage.IndexBuffer, cylinder.Select((v, i) => (ushort)i).ToArray()), TransparentIndices = new ResizableBuffer <ushort>(device, sizeof(ushort), BufferUsage.IndexBuffer), BoundingRadius = 0 }; entity.Set(mesh); }