posts - 34,  comments - 14,  trackbacks - 0

在研究一些3D引擎的时候,常常看到一个术语:Scene Graph, 从字面上看了半天没看出个究竟,
看了看相关内部代码,同样糊涂……于是到国外的几个游戏编程论坛查了查,呵呵……收获不好啊!
    下面是我收集的一些资料关键:

  1) What is a Scene Graph?
   Abstractly put, a Scene Graph is an organized hierarchy of nodes in a data structure with special relationships that
  simplify a problem. Put more concretely for our project: A Scene Graph is an m-ary tree, a tree with any node possessing
    any number of children, in which any particular node will inherit and amalgamate the transformations and render states,
    or other such states of the parent.


    2) Inheritance and Polymorphism (OOP) 。// 呵呵,C++
      As the complexities of game programming increase, it is immediately important in the beginning of a project's lifetime
    to start organizing your core engine. The more time that is spent understanding the purpose of your project, defining the
    features and limitations, and planning the long-term scale, the faster projects will fall together in a well-polished final
    product. Object-oriented programming can greatly help in this organization.

      The real powers in OOP lie in two key areas: Inheritance and Polymorphism. Inheritance allows for an object to extend the
    functionality of a base class, if necessary. Polymorphism allows you to call derived class methods which have been marked as
    virtual through a base class pointer.

      These two concepts are used heavily in the scene management framework that will be described later in this article. For
    further information on Object-Oriented Programming check out Bjarne Stroustrup's book (Stroustrup97).


    3) Object Ownership
      Determining ownership of objects is an important part of constructing a game engine for two reasons. First and most
    important, objects are used and reused all over the lifetime of the game. It is important to know when it is safe to
    change or delete an object. Second, to avoid memory leaks, objects must be deleted. Since a game will deal with many        

    objects, it is wise to design a good solution to deal with object lifetime so that object management does not get out
    of control.

      A good resolution is to allow parent objects to take ownership of their directly descendent child objects. This method
    allows the ability to divide the responsibility of objects being deleted. Later we will be adding child objects similar to
    this:

    void LoadModel(char* pFile, char* pName)
    {
      FFObject* pObj = new FFMeshObject(pFile, pName);
      m_pSceneRoot->AttachChild(pObj);
    }

      Here, pObj is a dynamically allocated object that is handed to the scene root, and m_pSceneRoot takes full
    responsibility of pObj. Whenever m_pSceneRoot determines that it no longer needs pObj, it must free the resources.

 


  好了,文盲的我“憋”到这里也实在不知道怎么“憋”不下去了…… It's time to rest!

posted on 2006-07-25 11:34 Konami wiki 阅读(609) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。