Jump to content
  • Advertisement
Sign in to follow this  
Say

[c#] Device and scenes

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!