Database view at run time

Apr 13, 2012 at 9:48 PM

Hi all,

  Good job, I am new to the development and started with WPF in C #, I can create a small application and export .obj files but:

  1. When loading a file. obj will change the texture Helixviewport3d blue. Where I can change to white by default?

  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

  Novice

Apr 13, 2012 at 11: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 class).

3. Sorry, I have not planned examples with databases in this library.

Apr 14, 2012 at 1:20 PM

Thanks Objo i'm really grateful
for your help

Dec 7, 2012 at 12:59 AM

Hi, objo

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)

 

 

and 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);

    fs.Write(byts,0 ,byts.Length);

    fs.Close();
   
}
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)
    {
        items.Add(visual);
    }

    //"Detach" the visuals from the original parent.
    vp.Children.Clear();

    //Now, put it in the destination viewport.
    foreach (var item in items)
    {
        view1.Children.Add(item);
    }
    
    }
Any suggestions to compress the data,add some text (textbox.text), or other. ().
thanks