From: Anthony Bavuso (a.t.bavuso++at++larc.nasa.gov)
Date: 01/05/2000 14:32:14
Greetings,
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();
}
This archive was generated by hypermail 2b29 : Wed Jan 05 2000 - 14:31:28 PST