Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code highlighting to README. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
ObjLoader [![Build status](https://ci.appveyor.com/api/projects/status/5dbqtlt7gxninwyn?svg=true)](https://ci.appveyor.com/project/ChrisJansson/objloader)[![NuGet version](https://badge.fury.io/nu/CjClutter.ObjLoader.svg)](https://badge.fury.io/nu/CjClutter.ObjLoader)
========

Objloader is a simple Wavefront .obj and .mtl loader
Objloader is a simple Wavefront .obj and .mtl loader.

Installation
------------
Build the project and reference the .dll or reference the project directly as usual.

Loading a model
---------------
Either create the loader with the standard material stream provider, this will open the file read-only from the working directory.

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

Either create the loader with the standard material stream provider, this will open the file read-only from the working directory.
```cs
var objLoaderFactory = new ObjLoaderFactory();
var objLoader = objLoaderFactory.Create();
```

Or provide your own:

//With the signature Func<string, Stream>
var objLoaderFactory = new ObjLoaderFactory();
var objLoader = objLoaderFactory.Create(materialFileName => File.Open(materialFileName);
```cs
//With the signature Func<string, Stream>
var objLoaderFactory = new ObjLoaderFactory();
var objLoader = objLoaderFactory.Create(materialFileName => File.Open(materialFileName);
```

Then it is just a matter of invoking the loader with a stream containing the model.

var fileStream = new FileStream("model.obj");
var result = objLoader.Load(fileStream);
```cs
var fileStream = new FileStream("model.obj");
var result = objLoader.Load(fileStream);
```

The result object contains the loaded model in this form:

public class LoadResult
{
public IList<Vertex> Vertices { get; set; }
public IList<Texture> Textures { get; set; }
public IList<Normal> Normals { get; set; }
public IList<Group> Groups { get; set; }
public IList<Material> Materials { get; set; }
}
```cs
public class LoadResult
{
public IList<Vertex> Vertices { get; set; }
public IList<Texture> Textures { get; set; }
public IList<Normal> Normals { get; set; }
public IList<Group> Groups { get; set; }
public IList<Material> Materials { get; set; }
}
```