0

Database view at run time

Anonymous 10 years ago 0
This discussion was imported from CodePlex

mateovidro wrote at 2012-04-13 22:48:

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


objo wrote at 2012-04-14 00:23:

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.


mateovidro wrote at 2012-04-14 14:20:

Thanks Objo i'm really grateful
for your help


mateovidro wrote at 2012-12-07 00:59:

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