Skip to content

Commit

Permalink
Use of Memory Stream instead of File
Browse files Browse the repository at this point in the history
  • Loading branch information
Selinux24 committed Jul 31, 2015
1 parent e7c059e commit b383f40
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 201 deletions.
12 changes: 7 additions & 5 deletions 6 Terrain/TestScene3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public override void Initialize()

#region Models

string resources = @"Resources\Resources.zip";

Stopwatch sw = Stopwatch.StartNew();

string loadingText = null;
Expand All @@ -92,7 +94,7 @@ public override void Initialize()
sw.Restart();
this.cursor3D = this.AddModel(new ModelDescription()
{
ContentPath = @"Resources\Resources.zip",
ContentPath = resources,
ModelFileName = "cursor.dae",
});
sw.Stop();
Expand All @@ -105,7 +107,7 @@ public override void Initialize()
sw.Restart();
this.terrain = this.AddTerrain(new TerrainDescription()
{
ContentPath = @"Resources\Resources.zip",
ContentPath = resources,
ModelFileName = "two_levels.dae",
UseQuadtree = true,
UsePathFinding = true,
Expand Down Expand Up @@ -149,7 +151,7 @@ public override void Initialize()
sw.Restart();
this.helicopter = this.AddModel(new ModelDescription()
{
ContentPath = @"Resources\Resources.zip",
ContentPath = resources,
ModelFileName = "helicopter.dae",
DropShadow = true,
TextureIndex = 2,
Expand Down Expand Up @@ -186,7 +188,7 @@ public override void Initialize()
sw.Restart();
this.tank = this.AddModel(new ModelDescription()
{
ContentPath = @"Resources\Resources.zip",
ContentPath = resources,
ModelFileName = "tank.dae",
DropShadow = true,
});
Expand All @@ -208,7 +210,7 @@ public override void Initialize()
sw.Restart();
this.obelisk = this.AddInstancingModel(new ModelInstancedDescription()
{
ContentPath = @"Resources\Resources.zip",
ContentPath = resources,
ModelFileName = "obelisk.dae",
DropShadow = true,
Instances = 4,
Expand Down
53 changes: 3 additions & 50 deletions Engine/Common/ModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using SharpDX;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using SharpDX;
using ShaderResourceView = SharpDX.Direct3D11.ShaderResourceView;

namespace Engine.Common
{
using Engine.Content;
using Engine.Helpers;

/// <summary>
/// Model basic implementation
Expand Down Expand Up @@ -278,53 +277,7 @@ protected virtual void InitializeTextures(ModelContent modelContent)
{
ImageContent info = modelContent.Images[images];

ShaderResourceView view = null;

if (info.Stream != null)
{
byte[] buffer = info.Stream.GetBuffer();

view = this.Game.Graphics.Device.LoadTexture(buffer);
}
else
{
if (info.IsArray)
{
if (info.Paths != null && info.Paths.Length > 0)
{
view = this.Game.Graphics.Device.LoadTextureArray(info.Paths);
}
else if (info.Streams != null && info.Streams.Length > 0)
{
view = this.Game.Graphics.Device.LoadTextureArray(info.Streams);
}
}
else if (info.IsCubic)
{
int faceSize = info.CubicFaceSize;

if (info.Path != null)
{
view = this.Game.Graphics.Device.LoadTextureCube(info.Path, faceSize);
}
else if (info.Stream != null)
{
view = this.Game.Graphics.Device.LoadTextureCube(info.Stream, faceSize);
}
}
else
{
if (info.Path != null)
{
view = this.Game.Graphics.Device.LoadTexture(info.Path);
}
else if (info.Stream != null)
{
view = this.Game.Graphics.Device.LoadTexture(info.Stream);
}
}
}

ShaderResourceView view = info.CreateResource(this.Game.Graphics.Device);
if (view != null)
{
this.Textures.Add(images, view);
Expand Down
110 changes: 0 additions & 110 deletions Engine/Content/Compression.cs

This file was deleted.

0 comments on commit b383f40

Please sign in to comment.