[c#] Device and scenes

Started by
6 comments, last by Say 18 years, 9 months ago
I have created a form with 2 panels. I would to show the same scene in the first panel and in the second, but in the second i want set the camera to watch on onother point of that scene. How could i do? I use the following code.

using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Direct3D = Microsoft.DirectX.Direct3D;
public class Meshes : Form
{
    Device device = null;              // Rendering device
    Mesh mesh = null;                  // Mesh object in system memory
    Direct3D.Material[] meshMaterials; // Materials for the mesh
    Texture[] meshTextures;            // Textures for the mesh
    PresentParameters presentParams = new PresentParameters();
    .
    .
    .
}

public void OnResetDevice(object sender, EventArgs e)
{
    ExtendedMaterial[] materials = null;
    
    // Set the directory up to load the right data, because the
    // default build location is Bin\debug or Bin\release.
    Directory.SetCurrentDirectory(Application.StartupPath +  @"\..\..\");
    
    Device dev = (Device)sender;
    
    // Turn on the z-buffer.
    dev.RenderState.ZBufferEnable = true;
    
    // Turn on ambient lighting.
    dev.RenderState.Ambient = System.Drawing.Color.White;
    .
    .
    .
}

public void OnResetDevice(object sender, EventArgs e)
{
    .
    .
    .
    // Load the mesh from the specified file.
    mesh = Mesh.FromFile("tiger.x",
                         MeshFlags.SystemMemory,
                         device,
                         out materials);
    if (meshTextures == null)
    {
        // Extract the material properties and texture names.
        meshTextures  = new Texture[materials.Length];
        meshMaterials = new Direct3D.Material[materials.Length];
        for( int i=0; i<materials.Length; i++ )
        {
            meshMaterials = materials.Material3D;
            
            // Set the ambient color for the material. Direct3D
            // does not do this by default.
            meshMaterials.Ambient = meshMaterials.Diffuse;
            
            // Create the texture.
            meshTextures = TextureLoader.FromFile(dev,
                                       materials.TextureFilename);
        }
    }
}

private void Render()
{
    .
    .
    .
    for( int i=0; i<meshMaterials.Length; i++ )
    {
        // Set the material and texture for this subset.
        device.Material = meshMaterials;
        device.SetTexture(0, meshTextures);
        
        // Draw the mesh subset.
        mesh.DrawSubset(i);
    }
    
    // End the scene.
    device.EndScene();
    device.Present();
}



At the place of "device" in the following code
   mesh = Mesh.FromFile("tiger.x",
                         MeshFlags.SystemMemory,
                         device,
                         out materials);


i've set panel1. Now what i have to do to realize what i want? [Edited by - Say on July 22, 2005 3:49:34 AM]
Advertisement
up
It sounds to me like you want to use 2 different swap chains, one for each panel. You do NOT want to use 2 different devices because resources allocated for one device cannot be shared with another device (and lots of other reasons).
How can use 2 different swap chains?
please is very important for me :(
ok someone?
Google on directx swap chains: 2nd hit.

Cheers
big tnx renow

This topic is closed to new replies.

Advertisement