Dr. Markus Lappe (lappe++at++midnite.neurobiologie.ruhr-uni-bochum.de)
Thu, 15 Dec 94 17:21:57 +0100
Thus, I decided to use a draw function callback that only draws the
objects and does not perform a screen clear.
To remove the objects drawn in the previous frame I created a second
channel that is supposedly rendered first. The draw function callback
of this channel is supposed to draw the the same objects as seen from
the previous viewpoint, but with the color of the objects set to
black, the background color. To achieve the color change, I issued a
cpack(0xFFFFFFFF) in the draw function callback of the channel
supposed to draw white objects from the new viewpoint and a
cpack(0xFF000000) in the draw function callback of the channel
supposed to draw black objects from the old viewpoint.
However, instead of the movement of the objects I get a superimposed
view of the trajectory, i.e. the clearing of the old view does not
seem to work.
The program I use is a small variation of the simple.c example.
It is short enought to be included with this mail.
I also include a sample data file "one_object.obj" that I use.
I am using an Indigo 2 XZ running IRIX 5.2.
Does anybody have an idea what I am doing wrong?
Thanks,
Markus
-------------------swing.c--------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <gl/device.h>
#include <Performer/pf.h>
#include "pfsgi.h"
void DrawFunc(pfChannel *chan, void *data);
void DrawFunc2(pfChannel *chan, void *data);
int
main (int argc, char *argv[])
{
float t = 0.0f;
pfScene *scene;
pfPipe *p;
pfChannel *chan,*chan2;
pfNode *root;
int draw_oldview;
/* Initialize Performer */
pfInit();
/* Use default multiprocessing mode based on number of
* processors.
*/
pfMultiprocess(PFMP_DEFAULT);
/* Configure multiprocessing mode and start parallel
* processes.
*/
pfConfig();
/* Configure and open pipe */
p = pfGetPipe(0);
pfInitPipe(p, NULL);
/* Append to PFPATH files in /usr/src/Performer/data */
pfFilePath(".:/usr/src/Performer/data");
/* Create a pfScene. */
scene = pfNewScene();
/* Create and configure a pfChannel. */
chan = pfNewChan(p);
pfChanScene(chan, scene);
pfChanNearFar(chan, 0.01f, 30.0f);
pfChanFOV(chan, 45.0f, 0.0f);
pfChanDrawFunc(chan, DrawFunc);
/* Create and configure a second pfChannel. */
chan2 = pfNewChan(p);
pfAttachChan(chan,chan2);
pfChanShare(chan,
PFCHAN_SWAPBUFFERS |
PFCHAN_FOV |
PFCHAN_NEARFAR |
PFCHAN_SCENE |
PFCHAN_EARTHSKY);
pfChanDrawFunc(chan2, DrawFunc2);
/* Read a single file, of any known type. */
if ((root = LoadFile(argv[1], NULL)) == NULL)
{
pfExit();
exit(-1);
}
/* Attach loaded file to a pfScene. */
pfAddChild(scene, root);
draw_oldview = 0;
pfInitClock (0.0f);
/* Simulate */
while (t<5)
{
float s, c;
pfCoord view;
float phi;
/* Go to sleep until next frame time. */
pfSync();
/* Compute new view position. */
t = pfGetTime();
/* Compute new viewpoint. */
/* Swing. */
phi = 4.0 * sin(sqrt(9.81 / 3.5) * t);
pfSinCos(phi, &s, &c);
pfSetVec3(view.xyz, 0.0f, 0.0f + 3.5f * s, - 3.5f + 3.5f *
c);
/* Compute new gaze direction. */
pfSetVec3(view.hpr, 0.0f, 0.0f, 0.0f);
pfChanView(chan2, view.xyz, view.hpr);
/* Initiate cull/draw for this frame. */
if(draw_oldview==1) pfFrame();
draw_oldview = 1;
pfChanView(chan, view.xyz, view.hpr);
}
/* Terminate parallel processes and exit. */
pfExit();
return 0;
}
void
DrawFunc(pfChannel *chan, void *data)
{
cpack(0xFF000000);
pfDraw();
}
void
DrawFunc2(pfChannel *chan, void *data)
{
cpack(0xFFFFFFFF);
pfDraw();
}
-------------------one_object.obj-------------
v -0.099391 0.800000 -0.166105
v -0.097226 0.800000 -0.167355
v -0.095061 0.800000 -0.166105
v -0.095061 0.800000 -0.163605
v -0.097226 0.800000 -0.162355
v -0.099391 0.800000 -0.163605
f 1 2 3 4 5 6
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:44 PDT