Re: pfFCS help

New Message Reply Date view Thread view Subject view Author view

From: Yair Kurzion (yair++at++polygon.engr.sgi.com)
Date: 01/05/2000 15:06:42


Hello There !

I see some problems in the code below:

o It does not modify the bounding sphere of the pfFCS node. A regular pfDCS
  node re-computes its bounding sphere every time you change its matrix.
  This bounding sphere is used for culling this pfDCS. In a pfFCS node, the
  matrix is modified without notifying the pfFCS node so it does not re-compute
  its bounding sphere.
  A wrong bounding sphere leads to incorrect culling - either you draw the
  object when it is outside the viewing frustum, or you don't draw it when it
  is inside the frustum.

  There are two possible solutions for this:

  - If your object moves in some confined space, you can set the bounding
    sphere of your pfFCS staticly to that space.

  - You can set your pfFCS bounding sphere in the APP process every frame.
    In this case, it makes more sense to use a pfDCS node. Have a separate
    process compute the matrix and store it in a pfFlux, and have your APP
    process read this pfFlux and store the matrix in a pfDCS. This way the
    bounding sphere will be correct and culling will not fail.

o I don't see a call to pfFlux::setFrame in your code. Since you fork your
  private process, you should notify pfFlux of the current frame number in
  that process. It is usually a good idea to use the APP frame number at the
  start of each frame as the current frame number of your private process.

o In your code, calling matrix->make* overrides the matrix contents with the
  new transformation matrix. So, calling it multiple times (as in
  dynamicModel::setCoord) has no effect. You probably want to use
  pfMatrix::pre* or pfMatrix::post* in order to accumulate transforms.

-yair

> I am trying to use a pfFCS for a dynamicModel class that I am developing
> (code fragments are attached below). The dynamicModel class is used for any
> model or geometry in my scene that moves dynamically. I used a pfDCS node
> before but I was having trouble with mulit-threaded synchronization so I am
> trying to use the pfFCS which as I understand handles the synchronization
> for me through a frame indexed multi-buffer.
>
> I have included a stub main routine to demonstrate the usage of the
> dynamicModel class. The model is instantiated, initialized, and then the
> models root node is added to the scene graph. When the model is initialized
> a pthread is created to update the models position using the pfFCS node
> through the setCoord() method.
>
> There are two dynamicModel methods of interest here;
> dynamicModel::initCoordSystem() and dynamicModel::setCoord(). The
> initCoordSystem() method allocates and initializes the pfFCS* member. The
> setCoord() method is used to set the position of the geometry through the
> pfFCS node.
>
> I have compiled and run the full set of code of which I only provide the
> relevant fragments. When I run the program, I see the dynamicModels moving
> through the scene but as I move closer to the model using the fly mouse
> interface the models disappear.
>
> Could someone tell me what I am doing wrong here? Am I making some obvious
> mistake regarding the use of the pfFCS?
>
> Thanks in advance.
>
> void main()
> {
>
> //scene graph pointer
> pfScene* scene;
>
> //Performer initialization
> ...
>
> //allocate and initialize the dynamicModel
> dynamicModel* airplane = new dynamicModel();
> airplane->init();
>
> scene->addChild( airplane->getNode() );
>
> //Performer rendering loop
> ...
>
>
> }
>
>
> class dynamicModel : public thread
> {
> protected:
> pfNode* getRoot() { return m_objectRoot; }
> void init();
> pfNode* initCoordSystem(pfCoord objectCoord,
> pfNode* objectGeometry);
> void setCoord(pfVec3 Position, pfVec3 Orientation);
>
> private:
> pfFCS* m_objectFCS;
> pfNode* m_objectRoot;
> };
>
> ////////////////////////////////////////////////////////////////////////////
> ///////////////////
> void dynamicModel ::init()
> {
> //load geometry
> m_objectGeometry = loadGeometry(m_DatabaseFilename, m_ModelPath,
> m_TexturePath);
>
> //apply coordinate transformations to geometry and set to root
> m_objectRoot = initCoordSystem(m_objectCoord, m_objectGeometry);
> }
>
> ////////////////////////////////////////////////////////////////////////////
> //////////////////
> pfNode* dynamicModel::initCoordSystem(pfCoord objectCoord,
> pfNode* objectGeometry)
> {
> pfFlux* flux_matrix;
>
> //allocate the flux matrix
> flux_matrix = new pfFlux(sizeof(pfMatrix), PFFLUX_DEFAULT_NUM_BUFFERS);
>
> //allocate the FCS
> m_objectFCS = new pfFCS(flux_matrix);
>
> //add the geometry as a child to the FCS
> m_objectFCS->addChild(objectGeometry);
>
> return m_objectFCS;
> }
>
> ////////////////////////////////////////////////////////////////////////////
> //////////////////
> void dynamicModel::setCoord(pfVec3 Position, pfVec3 Orientation)
> {
> pfFlux* flux;
> pfMatrix* matrix;
>
> flux = m_objectFCS->getFlux();
> matrix = (pfMatrix*)flux->getWritableData();
>
> matrix->makeRot(Orientation[0], 0,0,1);
> matrix->makeRot(Orientation[1], 0,1,0);
> matrix->makeRot(Orientation[2], 1,0,0);
> matrix->makeTrans(Position[0], Position[1], Position[2]);
>
> flux->writeComplete();
> }
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>

-- 
\_________  \_____  \__    \__  \_____         Yair Kurzion
\_________  \_____   \__   \__  \_____         yair++at++sgi.com
       \__     \__   \____\__      \__   http://reality.sgi.com/yair
       \__          \__  \__                Work: (650) 933-6502
       \__          \__   \__               Home: (408) 226-9771
       \__          \__    \__             


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Jan 05 2000 - 15:06:49 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.