Good job, I am new to the development
and started with WPF in
C #, I can create a small application
and export .obj files
1. When loading a file. obj
will change the texture Helixviewport3d
blue. Where I can change to white
2. When I load the
obj. of Viewport3D. What is the best
way to save the file, some text and some
trace of the line? (Access, SQL, compact, etc)
3. Where do I get an example
to make this data link (code) ?
Thanks for the help
Apr 13, 2012 at 10:23 PM
1. The ObjReader class has a property DefaultColor where you can set the color of elements that don't have materials assigned.
The ObjExporter should export the materials defined in your Model3D. I think it supports all kinds of materials, for complex materials (e.g. gradients) it will export an image file.
2. Currently the ObjExporter only supports writing to files (the .obj itself could be written to a stream, but it also needs to write material files...) If you just need to persist your model - try serializing the Xaml of the Viewport3D (see the XamlExporter
3. Sorry, I have not planned examples with databases in this library.
Thanks Objo i'm really grateful
for your help
I already Viewport3D serialize
XAML at runtime. I try to show my models
in a simple application,
I just want to save and
load models with some additional text.
This is my code :(btn events)
load with this code:
private void button1_Click(object sender, RoutedEventArgs e)
Viewport3D viewport = this.view1.Viewport;
object obj = viewport;
FileStream fs = new FileStream(@"C:\test.txt", FileMode.Create, FileAccess.Write);
string savedview = XamlWriter.Save(obj);
byte byts = System.Text.ASCIIEncoding.ASCII.GetBytes(savedview);
Any suggestions to compress the data,add
some text (textbox.text), or other. ().
private void button2_Click(object sender, RoutedEventArgs e)
FileStream fs = new FileStream(@"C:\Users\MateoLab\Documents\test.txt", FileMode.Open, FileAccess.Read);
Viewport3D vp = XamlReader.Load(fs) as Viewport3D;
//Move the child visuals to a temporary collection.
List<Visual3D> items = new List<Visual3D>();
foreach (Visual3D visual in vp.Children)
//"Detach" the visuals from the original parent.
//Now, put it in the destination viewport.
foreach (var item in items)