XNA Game Development Forums
2012/05/18 06:34:47 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Scene graph  (Read 1812 times)
EclipsE
Full Member
***
Offline Offline

Posts: 111


View Profile
« on: 2007/03/13 10:15:48 »

I don't understand why did you make your scene graph complicated and so long, here's mine solution and it works ok:

Code:
#region NSceneNode class
    /// <summary>
    /// It's a simple node
    /// </summary>
    public class NSceneNode
    {
        #region Variables
        #region Object
        private NObject theObject;
        public NObject Object { get { return theObject; } }
        #endregion
        #endregion

        #region Constructor( objectToAdd )
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="objectToAdd">The object to add</param>
        public NSceneNode(NObject objectToAdd)
        {
            theObject = objectToAdd;
        }
        #endregion
    }
    #endregion

    #region NScene class
    /// <summary>
    /// The scene that contains all the nodes
    /// </summary>
    public class NScene
    {
        #region Collection of nodes
        private Collection<NSceneNode> sceneNodeCollection = new Collection<NSceneNode>();
        #endregion

        #region Render( device )
        /// <summary>
        /// Renders all the objects
        /// </summary>
        /// <param name="device">The device</param>
        public void Render(GraphicsDevice device)
        {
            //Go through each object in the scene
            foreach (NSceneNode obj in sceneNodeCollection)
            {
                if (obj.Object is NIRenderable)  //If it's a renderable object, render it
                {
                    ((NIRenderable)obj.Object).Render(device);
                }
                if (obj.Object is NIModel)
                {
                    ((NIModel)obj.Object).RenderModel(device);
                }

            }
        }
        #endregion

        #region AddObject( objectToAdd )
        /// <summary>
        /// Adds a object to the scene
        /// </summary>
        /// <param name="objectToAdd">The object to add</param>
        public void AddObject(NObject objectToAdd)
        {
            NSceneNode newNode = new NSceneNode(objectToAdd);

            sceneNodeCollection.Add(newNode);
        }
        #endregion

        #region ClearScene()
        public void ClearScene()
        {
            sceneNodeCollection.Clear();
        }
        #endregion

        #region LoadGraphicContent( device, loader )
        /// <summary>
        /// Loads all the content
        /// </summary>
        /// <param name="device">The device</param>
        /// <param name="loader">The content loader</param>
        public void LoadGraphicContent(GraphicsDevice device, NContentManager loader)
        {
            //Go through each object in the scene
            foreach (NSceneNode node in sceneNodeCollection)
            {
                if (node.Object is NILoadable)  //If it's a renderable object, render it
                {
                    ((NILoadable)node.Object).LoadGraphicContent(device, loader);
                }
            }
        }
        #endregion
    }
    #endregion

Also, I think you should use regions often in your code to make it easier to read. And about the Octree, I really think you should remove it and find a better way for culling... What if a object moves its position and goes into another node?? Really complicated...
Logged
EclipsE
Full Member
***
Offline Offline

Posts: 111


View Profile
« Reply #1 on: 2007/03/13 11:56:17 »

And now I made my own post processor, but have a problem: When I have only one pp shader it's ok, but if I have two of them, the second one is using the texture of the original texture, and not the modified one by the first shader. How can I get the modified texture by the first shader???
Logged
bcronje
Newbie
*
Offline Offline

Posts: 5


View Profile
« Reply #2 on: 2007/03/13 14:33:30 »

Eclipse,

It might be just me but I think you need to work on the tone of your posts. Sounds a bit demanding...
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #3 on: 2007/03/13 18:24:26 »

The architecture of the engine (as has been discussed in many other posts) is not created to be a final tool for people to use in making their games, but to explain the concepts behind creating these systems. The entire point is to allow people to go out and create their own engine implementations with their own ideas.
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Hazy Mind Scene Editor Hazy Mind Scene Editor mikeschuld 5 4604 Last post 2006/11/10 23:34:51
by AndroiD
Saving scene Hazy Mind Scene Editor Requests « 1 2 » Hunefalk 27 11610 Last post 2011/04/30 10:06:26
by gunther6616
Tutorial 2 :: Scene Graph and Object Framework Tutorial Discussion « 1 2 » mikeschuld 18 10042 Last post 2008/07/31 22:50:22
by mikeschuld
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.11 seconds with 18 queries.