I found there is a function which read 3D data(let's say a character) from obj file, and draw it . the source code:
List<Vertex3f> verts=new List<Vertex3f>();
List<Vertex3f> norms=new List<Vertex3f>();
Groups=new List<ToothGroup>();
//ArrayList ALf=new ArrayList();//faces always part of a group
List<Face> faces=new List<Face>();
MemoryStream stream=new MemoryStream(buffer);
using(StreamReader sr = new StreamReader(stream)){
String line;
Vertex3f vertex;
string[] items;
string[] subitems;
Face face;
ToothGroup group=null;
while((line = sr.ReadLine()) != null) {
if(line.StartsWith("#")//comment
|| line.StartsWith("mtllib")//material library. We build our own.
|| line.StartsWith("usemtl")//use material
|| line.StartsWith("o")) {//object. There's only one object
continue;
}
if(line.StartsWith("v ")) {//vertex
items=line.Split(new char[] { ' ' });
vertex=new Vertex3f();//float[3];
if(flipHorizontally) {
vertex.X=-Convert.ToSingle(items[1],CultureInfo.InvariantCulture);
}
else {
vertex.X=Convert.ToSingle(items[1],CultureInfo.InvariantCulture);
}
vertex.Y=Convert.ToSingle(items[2],CultureInfo.InvariantCulture);
vertex.Z=Convert.ToSingle(items[3],CultureInfo.InvariantCulture);
verts.Add(vertex);
continue;
}
And why it need to read the data manually in directX? As far as I know, in XDA programming, we just need to call a function a load the resource.
Is this because it is in DirectX, there is no function to read resource? If yes, then how to prepare the 3D resource ? in XDA we just need to use other software draw the 3D picture and then export. but what should I do in DirectX?
How to read the 3D chart data with directX?
-
- Posts: 1
- Joined: Sun Mar 21, 2010 4:42 pm
- jordansparks
- Site Admin
- Posts: 5770
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Re: How to read the 3D chart data with directX?
"other software" is kind of vague. Kind of critical, too. Depending on what software was used to draw, only certain export formats will be available. Also, we want to have various faces grouped together so that we have access to change their color. We chose to use materials for that because it was the fastest way to finish development. We can always improve performance later by moving to shaders, but we simply don't have time to mess with it right now.in XDA we just need to use other software draw the 3D picture and then export
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com