public TextureCollection LoadFromLoadList(Objects.Graphics.Misc.TextureLoadList list) { if (!_systemReady) { throw new EngineException("System not ready for creation", true); } TextureCollection collection = new TextureCollection(); foreach (var kvp in list.Entries) { switch (kvp.Value[1].ToString()) { case "Atlas": var atlas = new TextureAtlas(kvp.Key, kvp.Value[0].ToString(), kvp.Value[2]); _textures[atlas.Name] = atlas; collection.Add(atlas.Name, atlas); break; case "Texture": var texture = new TextureObject(kvp.Key, kvp.Value[0].ToString()); _textures[texture.Name] = texture; collection.Add(texture.Name, texture); break; case "Target": var target = CreateTargetObject(kvp.Key, (int)((int[])kvp.Value[2])[0], (int)((int[])kvp.Value[2])[1]); _textures[target.Name] = target; collection.Add(target.Name, target); break; } } LoadTextures(); return(collection); }
public static TextureCollection createTextureMapArr(List<string> para_fullPathLocations) { List<Texture2D> tmpTexList = new List<Texture2D>(); List<int> indexMap = new List<int>(); Dictionary<string,int> seenTextures = new Dictionary<string,int>(); for(int i=0; i<para_fullPathLocations.Count; i++) { string tmpFPath = para_fullPathLocations[i]; if(seenTextures.ContainsKey(tmpFPath)) { indexMap.Add(seenTextures[tmpFPath]); } else { Texture2D nwTex = getTexture(para_fullPathLocations[i]); tmpTexList.Add(nwTex); seenTextures.Add(tmpFPath,tmpTexList.Count-1); indexMap.Add(tmpTexList.Count-1); } } Texture2D[] retTexArr = tmpTexList.ToArray(); int[] retIndexMap = indexMap.ToArray(); TextureCollection tCol = new TextureCollection(retTexArr,retIndexMap); return tCol; }
public override BlockController Controller() { BlockCube controller = new BlockCube(); controller.blockName = blockName; controller.isSolid = blockIsSolid; controller.solidTowardsSameType = solidTowardsSameType; TextureCollection[] textureCoordinates = new TextureCollection[6]; for (int i = 0; i < 6; i++) { try { textureCoordinates[i] = Block.index.textureIndex.GetTextureCollection(textures[i]); } catch { if (Application.isPlaying) { Debug.LogError("Couldn't find texture for " + textures[i]); } } } controller.textures = textureCoordinates; return(controller); }
public void UnloadTexture(TextureCollection collection) { foreach (var kvp in collection.Values) { _content.Unload(kvp.Texture); } }
private void textureTreeView_AfterSelect(object sender, TreeViewEventArgs e) { NodeType type = (NodeType)e.Node.Tag; TextureCollection textureManager = textureCollection; textureImageList.Images.Clear(); switch (type) { case NodeType.Directory: if (currentGroupName != e.Node.Name) { currentGroupName = e.Node.Name; lastSelectedTexture = null; } break; case NodeType.Texture: TextureItem?texture = textureManager.GetTextureItemById(e.Node.Name); if (texture.HasValue) { currentGroupName = texture.Value.Group; } break; } textureListView.VirtualListSize = textureManager.GetTexturesByGroup(currentGroupName).Count; }
public override BlockController Controller() { BlockCube controller = new BlockCube(); controller.blockName = blockName; controller.isSolid = blockIsSolid; controller.solidTowardsSameType = solidTowardsSameType; TextureCollection[] textureCoordinates = new TextureCollection[6]; for (int i = 0; i < 6; i++) { try { textureCoordinates[i] = Block.index.textureIndex.GetTextureCollection(textures[i]); } catch { if (Application.isPlaying) Debug.LogError("Couldn't find texture for " + textures[i]); } } controller.textures = textureCoordinates; return controller; }
private static void LoadDff() { using (new Timing("Loading DFFs into scene")) using (new MemoryCounter()) { var itemDefinitions = new DefinitionCollection(); var modelCollection = new ModelCollection(); var textureCollection = new TextureCollection(true); foreach (var obj in Selection.objects) { var objPath = AssetDatabase.GetAssetPath(obj); if (objPath.EndsWith(".dff", StringComparison.OrdinalIgnoreCase)) { var dff = new DffFile(objPath); modelCollection.Add(dff); itemDefinitions.Add(new ItemDefinition(dff.FileNameWithoutExtension)); } else if (objPath.EndsWith(".txd", StringComparison.OrdinalIgnoreCase)) { textureCollection.Add(new TxdFile(objPath)); } } using (new Loader(itemDefinitions, modelCollection, textureCollection)) foreach (var definition in itemDefinitions) { definition.GetObject(true); } } }
private Document() { Map = new Map(); Selection = new SelectionManager(this); History = new HistoryManager(this); HelperManager = new HelperManager(this); TextureCollection = new TextureCollection(new List <TexturePackage>()); }
internal ObjectSerializationAdaptor() { Metadata.Type = "Object"; Geometries = new GeometryCollection(); Materials = new MaterialCollection(); Images = new ImageCollection(); Textures = new TextureCollection(); }
public TextureIndex() { List<Texture2D> atlasTextures = new List<Texture2D>(); // Load all files in Textures folder atlasTextures.AddRange(Resources.LoadAll<Texture2D>(Config.Directories.TextureFolder)); //Load and generate all the connected textures List<Texture2D> connectedTextures = new List<Texture2D>(); connectedTextures.AddRange(Resources.LoadAll<Texture2D>(Config.Directories.ConnectedTextureFolder)); if (connectedTextures.Count!=0) atlasTextures.AddRange(ConnectedTextures.GenerateConnectedTextures(connectedTextures)); // Create new atlas atlas = new Texture2D(8192, 8192); atlas.filterMode = FilterMode.Point; // Generate atlas Rect[] rects = atlas.PackTextures(atlasTextures.ToArray(), 0, 8192, false); // Add each atlas entry into texture dictionary for (int i = 0; i < atlasTextures.Count; i++) { if (!atlasTextures[i]) continue; string[] fileName = atlasTextures[i].name.ToString().Split('-'); Rect texture = rects[i]; string textureName = fileName[0]; int connectedTextureType = -1; //Get the properties associated with this texture for (int n = 1; n < fileName.Length; n++) { switch (fileName[n][0]) { case 'c': int.TryParse(fileName[n].Substring(1), out connectedTextureType); break; default: break; } } //Create a texture collection with this name if it doesn't exist already TextureCollection collection; if (!textures.TryGetValue(textureName, out collection)) { collection = new TextureCollection(textureName); textures.Add(textureName, collection); } collection.AddTexture(texture, connectedTextureType); } }
private void ReleaseTextures() { // Release the textures object. if (TextureCollection != null) { TextureCollection.Shutdown(); TextureCollection = null; } }
public override bool OnSetUp(Hashtable config, World world) { if (!base.OnSetUp(config, world)) { return(false); } texture = world.textureProvider.GetTextureCollection(_GetPropertyFromConfig(config, "texture", "")); return(true); }
public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, TextureCollection texture, Block block) { float halfBlock = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding; float colliderOffest = 0.05f * Config.Env.BlockSize; float blockHeight = halfBlock * 2 * (block.data2 / 255f); float offsetX = (halfBlock * 2 * ((byte)(block.data3 & 0x0F) / 32f)) - (halfBlock/2); float offsetZ = (halfBlock * 2 * ((byte)((block.data3 & 0xF0) >> 4) / 32f)) - (halfBlock/2); //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z Vector3 vPos = pos; Vector3 vPosCollider = pos; vPos += new Vector3(offsetX, 0, offsetZ); float blockLight = ( (block.data1/255f) * Config.Env.BlockLightStrength) + (0.8f*Config.Env.AOStrength); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock)); meshData.AddQuadTriangles(); BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture); meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock)); meshData.AddQuadTriangles(); BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture); meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock)); meshData.AddQuadTriangles(); BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture); meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock)); meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock)); meshData.AddQuadTriangles(); BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture); meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight); meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true); meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true); meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true); meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true); meshData.AddQuadTriangles(collisionMesh:true); }
internal ObjectSerializationAdaptor() { Metadata.Type = "Object"; Elements = new ElementCollection(); Geometries = new GeometryCollection(); BufferGeometries = new BufferGeometryCollection(); Materials = new MaterialCollection(); Fonts = new FontDataCollection(); Images = new ImageCollection(); Textures = new TextureCollection(); }
public ITexture GetTexture(string name) { if (!TextureHelper.Exists(name)) { var ti = TextureCollection.GetItem(name); if (ti != null) { TextureProvider.LoadTextureItem(ti); } } return(TextureHelper.Get(name)); }
private void TextureBrowserDialog_Load(object sender, EventArgs e) { GeneralUtility.SetSpacing(textureListView, (short)(textureDimensions + 16), (short)(textureDimensions + 24)); // instantiate list view textureListView.LargeImageList = textureImageList; textureImageList.ImageSize = new Size(textureDimensions, textureDimensions); textureImageList.ColorDepth = ColorDepth.Depth24Bit; // configure tree list treeImageList.ImageSize = new Size(treeIconDimensions, treeIconDimensions); treeImageList.ColorDepth = ColorDepth.Depth24Bit; textureTreeView.ImageList = treeImageList; treeImageList.Images.Add(Resources.folder_icon); treeImageList.Images.Add(Resources.texture_icon); TextureCollection textureManager = textureCollection; textureManager.OnTextureCreated = OnTextureCreated; textureManager.OnTextureDeleted = OnTextureDeleted; textureManager.OnTextureRenamed = OnTextureRenamed; textureListView.DrawItem += OnDrawListViewItem; foreach (string groupName in textureManager.TextureGroupNames) { TreeNode groupNode = new TreeNode { Name = groupName, Text = groupName, Tag = NodeType.Directory, ImageIndex = 0, SelectedImageIndex = 0 }; textureTreeView.Nodes.Add(groupNode); List <TextureItem> textures = textureManager.GetTexturesByGroup(groupName); textures?.ForEach((t) => { TreeNode node = new TreeNode { Name = t.Id, Text = t.Name, Tag = NodeType.Texture, ImageIndex = 1, SelectedImageIndex = 1 }; groupNode.Nodes.Add(node); }); } }
public Loader(DefinitionCollection itemDefinitions, ModelCollection modelCollection, TextureCollection textureCollection) { if (Current != null) { throw new Exception("Another loader already in progress, make sure only one loader run at a time"); } Current = this; IdeCollection = itemDefinitions; ModelCollection = modelCollection; TxdCollection = textureCollection; }
public override BlockController Controller() { BlockCube controller = new BlockCube { BlockName = BlockName, IsSolid = IsSolid, SolidTowardsSameType = SolidTowardsSameType }; TextureCollection[] textureCoordinates = new TextureCollection[6]; if (!IsConnectedTextures) { for (int i = 0; i < 6; i++) { try { textureCoordinates[i] = Block.Index.TextureIndex.GetTextureCollection(Textures.GetTextureFromIndex(i).name); } catch { if (Application.isPlaying) { Debug.LogError("Couldn't find texture for " + Textures.GetTextureFromIndex(i)); } } } } else { for (int i = 0; i < ConnectedTextures.Length; i++) { try { textureCoordinates[i] = Block.Index.TextureIndex.GetTextureCollection(ConnectedTextures[i].name); } catch { if (Application.isPlaying) { Debug.LogError("¯\\_(ツ)_/¯"); } } } } controller.Textures = textureCoordinates; return(controller); }
/// <summary> /// Gets the cursor texture. /// </summary> /// <param name="skin">The name of the skin.</param> /// <returns>A <see cref="Texture"/> representing the cursor texture.</returns> protected virtual Texture GetCursorTexture(string skin) { TextureCollection subSkins = this.skin.SubSkins; string name = this.skin.Name + "."; var retValue = subSkins[name + skin]; if (retValue != null) { return(retValue); } switch (skin) { case "ResizeTop": retValue = subSkins[name + "ResizeBottom"]; break; case "ResizeBottom": retValue = subSkins[name + "ResizeTop"]; break; case "ResizeLeft": retValue = subSkins[name + "ResizeRight"]; break; case "ResizeRight": retValue = subSkins[name + "ResizeLeft"]; break; case "ResizeBottomLeft": retValue = subSkins[name + "ResizeTopRight"]; break; case "ResizeTopRight": retValue = subSkins[name + "ResizeBottomLeft"]; break; case "ResizeBottomRight": retValue = subSkins[name + "ResizeTopLeft"]; break; case "ResizeTopLeft": retValue = subSkins[name + "ResizeBottomRight"]; break; } return(retValue ?? subSkins[this.Skin.Name]); }
public override BlockController Controller() { BlockCube controller = new BlockCube(); controller.blockName = blockName; controller.isSolid = blockIsSolid; TextureCollection[] textureCoordinates = new TextureCollection[6]; for (int i = 0; i < 6; i++) { textureCoordinates[i] = Block.index.textureIndex.GetTextureCollection(textures[i]); } controller.textures = textureCoordinates; return controller; }
public AssetManager(Game game) : base(game) { _textures = new TextureCollection(); _fonts = new FontCollection(); _effects = new EffectCollection(); _skeletons = new SkeletonCollection(); _content = new ElegyEngine.Content.ExclusiveContentManager(game.Services); _textureLoad = false; _effectLoad = false; _fontLoad = false; _skeletonLoad = false; _frameCaptured = false; }
private void textureListView_MouseDoubleClick(object sender, MouseEventArgs e) { ListView senderList = (ListView)sender; ListViewItem clickedItem = senderList.HitTest(e.Location).Item; if (clickedItem != null) { TextureCollection textureManager = textureCollection; TextureItem? textureItem = textureManager.GetTextureItemById(clickedItem.Name); if (textureItem.HasValue) { textureCollection.SelectedTexture = textureItem.Value; OnTextureSelected?.Invoke(textureItem.Value); } } }
public TextureBrowserDialog(TextureCollection collection) { InitializeComponent(); textureCollection = collection; textureImageList = new ImageList(); treeImageList = new ImageList(); textureTreeView.HandleCreated += (sender, eventArgs) => { ((Control)sender).DoubleBuffered(true); }; // textureListView.HideSelection = false; textureListView.HandleCreated += (sender, eventArgs) => { ((Control)sender).DoubleBuffered(true); }; }
public override BlockController Controller() { BlockCube controller = new BlockCube(); controller.blockName = blockName; controller.isSolid = blockIsSolid; controller.solidTowardsSameType = solidTowardsSameType; TextureCollection[] textureCoordinates = new TextureCollection[6]; for (int i = 0; i < 6; i++) { textureCoordinates[i] = Block.index.textureIndex.GetTextureCollection(textures[i]); } controller.textures = textureCoordinates; return(controller); }
private void textureListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { TextureCollection textureManager = textureCollection; ListViewItem item = new ListViewItem(); TextureItem textureItem = textureManager.GetTexturesByGroup(currentGroupName)[e.ItemIndex]; string itemId = $"{textureItem.Id}"; if (!textureImageList.Images.ContainsKey(itemId)) { textureImageList.Images.Add(itemId, textureItem.Image); } item.Name = itemId; item.Text = textureItem.Name; item.ForeColor = Color.White; item.ImageKey = itemId; item.ImageIndex = textureImageList.Images.IndexOfKey(itemId); e.Item = item; }
public override bool SetUp(Hashtable config, World world) { if (!base.SetUp(config, world)) { return(false); } solid = _GetPropertyFromConfig(config, "solid", false); texture = world.textureProvider.GetTextureCollection(_GetPropertyFromConfig(config, "texture", "")); Vector3 meshOffset; meshOffset.x = float.Parse(_GetPropertyFromConfig(config, "meshXOffset", "0")); meshOffset.y = float.Parse(_GetPropertyFromConfig(config, "meshYOffset", "0")); meshOffset.z = float.Parse(_GetPropertyFromConfig(config, "meshZOffset", "0")); SetUpMesh(world.config.meshFolder + "/" + _GetPropertyFromConfig(config, "meshFileLocation", ""), meshOffset, out m_triangles, out m_vertices); return(true); }
/// <summary> /// Things that need to be done when the GUI is loaded /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditorForm_Load(object sender, EventArgs e) { Hide(); Opacity = 100; creationButtonsPanel.UpdatePrimitiveToolbar("box"); UpdateSolidManipulationToolbar(SolidManipulationMode.Solid); SetSolidManipulationMode("solid"); // show splash form SplashForm splash = new SplashForm(); splash.OnSplashDone += Show; splash.OnSplashIsShown = () => { TextureCollection.OnTextureLoadingProgress += splash.SetProgressBar; TextureCollection.LoadTextureCollection(); }; splash.ShowDialog(); }
/// <summary> /// Initializes the editor /// </summary> private void InitializeEditor() { // events Move += editorViewport.OnEditorMoves; Activated += editorViewport.OnEditorGotFocus; Deactivate += editorViewport.OnEditorLostFocus; Disposed += EditorForm_Dispose; editorViewport.OnViewportFocus += OnViewportFocus; textureSelector.ApplyButton.Click += OnApplySelectedTexture; textureSelector.ReplaceButton.Click += OnReplaceSelectedTexture; creationButtonsPanel.OnCreationButtonPressed = HandleGeometryBarItems; solidProperties.OnPropertiesChanged = OnSolidPropertiesChanged; textureProperties.OnPropertiesChanged = OnTexturePropertiesChanged; textureProperties.OnJustify = OnTexturePropertiesJustifyClicked; // initialization EditorSettings = new EditorSettings(); RubberBand = new RubberBand(); Selection = new MapObjectGroup(); CopyBoard = new MapObjectGroup(); CurrentTool = new SolidManipulationTool(); defaultMapSaver = new RuneMapExporter(); defaultMapLoader = new RuneMapImporter(); TextureCollection = new TextureCollection(EditorSettings.TextureFolder); if (!DesignMode) { EditorSettings.Load(); SetupSolidFactory(); solidProperties.UpdateProperties(Selection); editorViewport.SetController(this); textureSelector.TextureCollection = TextureCollection; CurrentTool.Initialize(this); Rotate = GeneralUtility.CreateCursor(Resources.rotate, 16, 16); NewDocument(); } }
private void ApplySelectedTexture(TextureItem texture) { if (Selection.Empty) { return; } CustomOperation operation = new CustomOperation(); operation.OnMapObjectGroup = (group) => group.MapObjectList.ForEach((subMapObject) => subMapObject.PerformOperation(operation)); operation.OnSolid = (solid) => { solid.Faces.ForEach(face => { Texture2D texture2D = TextureCollection.LoadTexture2D(texture.Id); bool sameTexture = face.Texture?.Identifier == texture.Id; if (CurrentSolidManipulationMode == SolidManipulationMode.Solid) { if (!sameTexture) { face.Texture = texture2D; } } else if (CurrentSolidManipulationMode == SolidManipulationMode.Face) { if (face.Selected && !sameTexture) { face.Texture = texture2D; } } }); }; Selection.PerformOperation(operation); SceneDocument.IsDirty = true; RenderViewports(); }
static void ValidateTexture(string collectionName, TextureData dat, TextureCollection textureCollection, int tileDimension, out string eMessage) { // todo: normal textures var texture = dat.GetTexture(); if (texture == null) { eMessage = $"There's a null texture in {collectionName} collection '{textureCollection.Name}'"; return; } if (texture.width < tileDimension || texture.height < tileDimension) { eMessage = $"The texture {texture.name} in {collectionName} collection '{textureCollection.Name}' is too small"; return; } if (!Mathf.IsPowerOfTwo(texture.width) || !Mathf.IsPowerOfTwo(texture.height)) { eMessage = $"The texture {texture.name} in {collectionName} collection '{textureCollection.Name}' is not power of two!"; return; } if (texture.width % tileDimension != 0 || texture.width % tileDimension != 0) { eMessage = $"The texture {texture.name} in {collectionName} collection '{textureCollection.Name}' is not multiple of the tileDimension {tileDimension}!"; return; } if (dat.Type == ETexType.Invalid) { eMessage = $"The texture {texture.name} in {collectionName} collection '{textureCollection.Name}' has invalid TexType (wrong dimensions)!"; return; } EnsureTextureReadableAndUncompressed(out eMessage, texture); }
private void LoadUsedTexturesToGpu() { CustomOperation loadTextureOperation = new CustomOperation(); loadTextureOperation.OnMapObjectGroup = group => { group.MapObjectList.ForEach(g => g.PerformOperation(loadTextureOperation)); }; loadTextureOperation.OnSolid = solid => { solid.Faces.ForEach(f => { f.Texture = TextureCollection.LoadTexture2D(f.Texture.Identifier); solid.AlignTextureAxisToWorldForFace(f); solid.CalculateTextureCoordinatesForFace(f, true); }); }; foreach (MapObject mapObject in SceneDocument) { mapObject.PerformOperation(loadTextureOperation); } }
public static void BuildTexture(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, TextureCollection[] textureCollections) { Rect texture = new Rect(); switch (direction) { case Direction.up: texture = textureCollections[0].GetTexture(chunk, pos, direction); break; case Direction.down: texture = textureCollections[1].GetTexture(chunk, pos, direction); break; case Direction.north: texture = textureCollections[2].GetTexture(chunk, pos, direction); break; case Direction.east: texture = textureCollections[3].GetTexture(chunk, pos, direction); break; case Direction.south: texture = textureCollections[4].GetTexture(chunk, pos, direction); break; case Direction.west: texture = textureCollections[5].GetTexture(chunk, pos, direction); break; default: break; } Vector2[] UVs = new Vector2[4]; UVs[0] = new Vector2(texture.x + texture.width, texture.y); UVs[1] = new Vector2(texture.x + texture.width, texture.y + texture.height); UVs[2] = new Vector2(texture.x, texture.y + texture.height); UVs[3] = new Vector2(texture.x, texture.y); meshData.uv.AddRange(UVs); }
public static void BuildTexture(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, TextureCollection textureCollection) { Rect texture = textureCollection.GetTexture(chunk, pos, direction); Vector2[] UVs = new Vector2[4]; UVs[0] = new Vector2(texture.x + texture.width, texture.y); UVs[1] = new Vector2(texture.x + texture.width, texture.y + texture.height); UVs[2] = new Vector2(texture.x, texture.y + texture.height); UVs[3] = new Vector2(texture.x, texture.y); meshData.uv.AddRange(UVs); }
protected abstract void SaveToStream(Stream stream, DataStructures.MapObjects.Map map, DataStructures.GameData.GameData gameData, TextureCollection textureCollection);
protected virtual void SaveToFile(string filename, DataStructures.MapObjects.Map map, DataStructures.GameData.GameData gameData, TextureCollection textureCollection) { using (var strm = new FileStream(filename, FileMode.Create, FileAccess.Write)) { SaveToStream(strm, map, gameData, textureCollection); } }
public static void SaveMapToFile(string filename, DataStructures.MapObjects.Map map, DataStructures.GameData.GameData gameData, TextureCollection textureCollection = null) { var provider = RegisteredProviders.FirstOrDefault(p => p.IsValidForFileName(filename)); if (provider != null) { provider.SaveToFile(filename, map, gameData, textureCollection); return; } throw new ProviderNotFoundException("No map provider was found for this file format."); }
static void MakeFenceTexture(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, TextureCollection[] textureCollections, Vector3 MeshSize, Direction[] Dir) { Rect texture = new Rect(); //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z foreach (Direction localDir in Dir) { Vector3 vPos = new Vector3(); if (localDir == Direction.north) { vPos = new Vector3(pos.x, pos.y, pos.z + MeshSize.z); } else if (localDir == Direction.east) { vPos = new Vector3(pos.x + MeshSize.x, pos.y, pos.z); } else if (localDir == Direction.west) { vPos = new Vector3(pos.x - MeshSize.x, pos.y, pos.z); } else if (localDir == Direction.south) { vPos = new Vector3(pos.x, pos.y, pos.z - MeshSize.z); } else if (localDir == Direction.up) { vPos = new Vector3(pos.x, pos.y + MeshSize.y, pos.z); } else if (localDir == Direction.down) { vPos = new Vector3(pos.x, pos.y - MeshSize.y, pos.z); } switch (direction) { case Direction.up: texture = textureCollections[0].GetTexture(chunk, vPos, direction); break; case Direction.down: texture = textureCollections[1].GetTexture(chunk, vPos, direction); break; case Direction.north: texture = textureCollections[2].GetTexture(chunk, vPos, direction); break; case Direction.east: texture = textureCollections[3].GetTexture(chunk, vPos, direction); break; case Direction.south: texture = textureCollections[4].GetTexture(chunk, vPos, direction); break; case Direction.west: texture = textureCollections[5].GetTexture(chunk, vPos, direction); break; default: break; } Vector2[] UVs = new Vector2[4]; UVs[0] = new Vector2(texture.x + texture.width, texture.y); UVs[1] = new Vector2(texture.x + texture.width, texture.y + texture.height); UVs[2] = new Vector2(texture.x, texture.y + texture.height); UVs[3] = new Vector2(texture.x, texture.y); meshData.uv.AddRange(UVs); } }
public static void BuildTextures(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, TextureCollection[] textureCollections, Vector3 MeshSize, Direction[] Dir) { MakeTexture(chunk, pos, meshData, direction, textureCollections); if (Dir.Length > 0) MakeFenceTexture(chunk, pos, meshData, direction, textureCollections,MeshSize, Dir); }
private void ReleaseTextures() { // Release the textures object. TextureCollection?.Shutdown(); TextureCollection = null; }
public TextureCollection LoadFromLoadList(Objects.Graphics.Misc.TextureLoadList list) { if (!_systemReady) throw new EngineException("System not ready for creation", true); TextureCollection collection = new TextureCollection(); foreach (var kvp in list.Entries) { switch(kvp.Value[1].ToString()) { case"Atlas": var atlas = new TextureAtlas(kvp.Key, kvp.Value[0].ToString(),kvp.Value[2]); _textures[atlas.Name] = atlas; collection.Add(atlas.Name, atlas); break; case"Texture": var texture = new TextureObject(kvp.Key, kvp.Value[0].ToString()); _textures[texture.Name] = texture; collection.Add(texture.Name, texture); break; case "Target": var target = CreateTargetObject(kvp.Key, (int)((int[])kvp.Value[2])[0], (int)((int[])kvp.Value[2])[1]); _textures[target.Name] = target; collection.Add(target.Name, target); break; } } LoadTextures(); return collection; }
//*************************************************************************** // Class Constructors // private Graphics3D() { this._materials = new MaterialCollection(); this._textures = new TextureCollection(); this._meshes = new MeshObjectCollection(); this._vertBuffers = new VertexBufferCollection(); this._presentParams = new PresentParameters(); this._presentParams.Windowed = true; this._presentParams.SwapEffect = SwapEffect.Discard; this._presentParams.AutoDepthStencilFormat = DepthFormat.D16; this._presentParams.EnableAutoDepthStencil = true; this._fov = ((float)System.Math.PI / 4.0f); this._clipNear = 1.0f; this._clipFar = 50.0f; this._aspect = 1.333f; this._minVS = new Version(0, 0); this._minPS = new Version(0, 0); this._camera = new Direct3DCamera(); }