Skip to content

Instantly share code, notes, and snippets.

@horsman
Last active February 28, 2016 22:45
Show Gist options
  • Save horsman/a871370145e50e455292 to your computer and use it in GitHub Desktop.
Save horsman/a871370145e50e455292 to your computer and use it in GitHub Desktop.
# Exported from Wings 3D 1.4.1
mtllib dollarsign.mtl
o text1
#40 vertices, 14 faces
v -5.2569805e-2 6.3388977e-5 0.0000000e+0
v 5.0945820e-2 6.3388977e-5 0.0000000e+0
v 5.0945820e-2 0.17779776 0.0000000e+0
v 0.35172707 0.30865714 0.0000000e+0
v 0.46793801 0.61334464 0.0000000e+0
v 0.44010598 0.76764151 0.0000000e+0
v 0.36051613 0.89068839 0.0000000e+0
v 0.22672707 0.97857901 0.0000000e+0
v 5.0945820e-2 1.03033683 0.0000000e+0
v 5.0945820e-2 1.53717276 0.0000000e+0
v 0.18619973 1.46441886 0.0000000e+0
v 0.25114113 1.30572745 0.0000000e+0
v 0.43278176 1.33307120 0.0000000e+0
v 0.29410988 1.59576651 0.0000000e+0
v 5.0945820e-2 1.68561026 0.0000000e+0
v 5.0945820e-2 1.88634545 0.0000000e+0
v -5.2569805e-2 1.88634545 0.0000000e+0
v -5.2569805e-2 1.68561026 0.0000000e+0
v -0.31624168 1.58990714 0.0000000e+0
v -0.44905418 1.28619620 0.0000000e+0
v -0.40364402 1.09771964 0.0000000e+0
v -0.27424949 0.96783683 0.0000000e+0
v -5.2569805e-2 0.88385245 0.0000000e+0
v -5.2569805e-2 0.32428214 0.0000000e+0
v -0.23030418 0.42877433 0.0000000e+0
v -0.30256980 0.63678214 0.0000000e+0
v -0.47932762 0.60357901 0.0000000e+0
v -0.40950340 0.37213370 0.0000000e+0
v -0.26692527 0.23492667 0.0000000e+0
v -5.2569805e-2 0.17584464 0.0000000e+0
v 5.0945820e-2 0.32428214 0.0000000e+0
v 5.0945820e-2 0.85943839 0.0000000e+0
v 0.23991066 0.75543448 0.0000000e+0
v 0.28727395 0.60162589 0.0000000e+0
v 0.22037941 0.41314933 0.0000000e+0
v -5.2569805e-2 1.53912589 0.0000000e+0
v -5.2569805e-2 1.05279776 0.0000000e+0
v -0.22297996 1.14947745 0.0000000e+0
v -0.27327293 1.29986808 0.0000000e+0
v -0.21419090 1.45709464 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 0.0000000e+0
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
vn 0.0000000e+0 0.0000000e+0 1.00000000
g text1_default2
usemtl default2
s 1
f 1//1 30//30 29//29 28//28 27//27 26//26 25//25 24//24 23//23 22//22 21//21 20//20 19//19 18//18 17//17 16//16 15//15 14//14 13//13 12//12 11//11 10//10 9//9 8//8 7//7 6//6 5//5 4//4 3//3 2//2
f 2//2 3//3 30//30 1//1
f 3//3 31//31 24//24 30//30
f 4//4 5//5 6//6 7//7 8//8 9//9 32//32 33//33 34//34 35//35 31//31 3//3
f 10//10 15//15 18//18 36//36
f 10//10 36//36 37//37 9//9
f 11//11 12//12 13//13 14//14 15//15 10//10
f 16//16 17//17 18//18 15//15
f 19//19 20//20 21//21 22//22 23//23 37//37 38//38 39//39 40//40 36//36 18//18
f 24//24 31//31 32//32 23//23
f 25//25 26//26 27//27 28//28 29//29 30//30 24//24
f 31//31 35//35 34//34 33//33 32//32
f 36//36 40//40 39//39 38//38 37//37
f 37//37 23//23 32//32 9//9
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class ObjToLines {
public static TextReader streamFromTextAsset(TextAsset text){
return new StringReader(text.text);
}
public static Mesh CreateMeshFromLines(TextReader stream){
// Storage
List<Vector3> vertices = new List<Vector3>();
List<int> lines = new List<int>(); // Every 2 is one line,
// it is not a line strip,
// indexes into vertices
// Read the file
string line;
while((line = stream.ReadLine()) != null){
string[] words = line.Split(new string[]{ " ", "\t"}, System.StringSplitOptions.None);
if(words[0].Trim() == "v"){
vertices.Add(
new Vector3(
float.Parse(words[1].Trim()),
float.Parse(words[2].Trim()),
float.Parse(words[3].Trim())
)
);
}
else if(words[0].Trim() == "f"){
List<int> thisFace = new List<int>();
for(int i = 1; i < words.Length; i++){
thisFace.Add(int.Parse(words[i].Split("/"[0])[0])-1);
}
for(int i = 1; i < thisFace.Count; i++){
lines.Add(thisFace[i-1]);
lines.Add(thisFace[i]);
}
lines.Add (thisFace[thisFace.Count-1]);
lines.Add (thisFace[0]);
}
}
// Build the mesh
Mesh mesh = new Mesh();
mesh.vertices = vertices.ToArray();
mesh.normals = new Vector3[vertices.Count];
mesh.uv = new Vector2[vertices.Count];
mesh.SetIndices(lines.ToArray (), MeshTopology.Lines, 0);
return mesh;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment