Esempio n. 1
0
        public void Load(ref List<IRenderable> renderables)
        {
            ObjLoaderFactory objLoaderFactory = new ObjLoaderFactory();
              IObjLoader objLoader = objLoaderFactory.Create();
              LoadResult loadresult = objLoader.Load(new FileStream("testbed.obj", FileMode.Open));
              List<GL33Renderable> rs = GLRenderableFactory.GetInstance().CreateRenderableFromObj<GL33Renderable>(loadresult);
              if(renderables == null)
            renderables = new List<IRenderable>();
              renderables.AddRange(rs);

              foreach(IRenderable renderable in renderables)
              {
            //Add shaders
            GL33Shader shader = new GL33Shader();
            shader.LoadVertexShader("test.vert");
            shader.LoadFragmentShader ("test.frag");
            if(shader.LinkProgram ())
              renderable.SetShader (shader);

            renderable.SetUpRenderable();
            renderable.SetProjectionMatrix(Matrix4.CreateOrthographic(1024f, 768f, 0.1f, 100.0f));
            if(renderable.Name.Contains("Goal"))
              entities.Add(EntityFactory.GetInstance().CreateStaticEntity<Goal>((GL33Renderable)renderable, new List<MemoryStream>(), new MemoryStream(), true));
            else if(renderable.Name.Contains("Level"))
              entities.Add(EntityFactory.GetInstance().CreateStaticEntity<Map>((GL33Renderable)renderable, new List<MemoryStream>(), new MemoryStream(), false));
            else if(renderable.Name.Contains("Player"))
              entities.Add(EntityFactory.GetInstance().CreateDynamicEntity<Player>((GL33Renderable)renderable, new List<MemoryStream>(), new MemoryStream(), false, 1.0f, 0.5f, 0.5f));
              }
        }
Esempio n. 2
0
 public static LoadResult Load(string path)
 {
     var objLoaderFactory = new ObjLoaderFactory();
     var objLoader = objLoaderFactory.Create();
     var fileStream = new FileStream(path,FileMode.Open);
     var result = objLoader.Load(fileStream);
     return result;
 }
		public static LoadResult LoadObjSolid(string fileName)
		{
			var objLoaderFactory = new ObjLoaderFactory ();
			var objLoader = objLoaderFactory.Create ();
			var fileStream = new FileStream (fileName, FileMode.OpenOrCreate);
			LoadResult solid = objLoader.Load (fileStream);
			fileStream.Close();
			return solid;
		}
Esempio n. 4
0
        static void Main(string[] args)
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            var objLoaderFactory = new ObjLoaderFactory();
            var objLoader = objLoaderFactory.Create(new MaterialStreamProvider());

            var fileStream = new FileStream(args[0], FileMode.Open, FileAccess.Read);

            var result = objLoader.Load(fileStream);

            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);

            PrintResult(result);
        }
Esempio n. 5
0
		private LoadResult LoadObjSolid(
			string fileName,
			float scale)
		{
			var objLoaderFactory = new ObjLoaderFactory ();
			var objLoader = objLoaderFactory.Create ();
			var fileStream = new FileStream (fileName, FileMode.OpenOrCreate);
			LoadResult solid = objLoader.Load (fileStream);
			fileStream.Close();

			OpenGLUtilities.UnitizeObject (ref solid);
			OpenGLUtilities.ScaleObject (ref solid, scale);

			return solid;
		}