MPKChannel - MPKChannel functional interface.| MPKChannel* | mpkChannelNew(void ); |
| void | mpkChannelDelete(MPKChannel* channel); |
| void | mpkChannelSetName(MPKChannel* c, char* name); |
| const char* | mpkChannelGetName(MPKChannel* c); |
| void | mpkChannelSetUserData(MPKChannel* channel, void* userData); |
| void* | mpkChannelGetUserData(MPKChannel* c); |
| void | mpkChannelSetViewport(MPKChannel* c, float vp[4]); |
| void | mpkChannelGetViewport(MPKChannel* c, float vp[4]); |
| void | mpkChannelSetNearFar(MPKChannel* c, float n, float f); |
| void | mpkChannelGetNearFar(MPKChannel* c, float* n, float* f); |
| MPKConfig* | mpkChannelGetConfig(MPKChannel* c); |
| MPKPipe* | mpkChannelGetPipe(MPKChannel* c); |
| MPKWindow* | mpkChannelGetWindow(MPKChannel* c); |
| MPKChannel* | mpkChannelGetProxy(MPKChannel* c); |
| void | mpkChannelSetProjection(MPKChannel* c, const float* origin, float distance, const float* fov, const float* hpr); |
| int | mpkChannelGetProjection(MPKChannel* c, float* origin, float* d, float* fov, float* hpr); |
| void | mpkChannelSetWall(MPKChannel* c, const float bl[3], const float br[3], const float tl[3]); |
| int | mpkChannelGetWall(MPKChannel* c, float* bl, float* br, float* tl); |
| void | mpkChannelSetOrthoWall(MPKChannel* c, const float bl[3], const float br[3], const float tl[3]); |
| int | mpkChannelGetOrthoWall(MPKChannel* c, float* bl, float* br, float* tl); |
| void | mpkChannelSetAttribute(MPKChannel* channel, int attr, int value); |
| void | mpkChannelUnsetAttribute(MPKChannel* channel, int attr); |
| void | mpkChannelResetAttribute(MPKChannel* channel, int attr); |
| int | mpkChannelTestAttribute(MPKChannel* channel, int attr); |
| int | mpkChannelGetAttribute(MPKChannel* channel, int attr, int* value); |
| void | mpkChannelSetDrawCB(MPKChannel* c, int which, MPKChannelDrawCB cb); |
| MPKChannelDrawCB | mpkChannelGetDrawCB(MPKChannel* c, int which); |
| void | mpkChannelSetCullCB(MPKChannel* c, int which, MPKChannelCullCB cb); |
| MPKChannelCullCB | mpkChannelGetCullCB(MPKChannel* c, int which); |
| void | mpkChannelApplyBuffer(MPKChannel* c); |
| void | mpkChannelApplyViewport(MPKChannel* c); |
| void | mpkChannelApplyNearFar(MPKChannel* c, float n, float f); |
| void | mpkChannelApplyFrustum(MPKChannel* c); |
| void | mpkChannelApplyHeadTransform(MPKChannel* c); |
| void | mpkChannelApplyViewTransform(MPKChannel* c); |
| void | mpkChannelApplyOrtho(MPKChannel* c, int orthomode, const float zoom[2]); |
| void | mpkChannelGetOrtho(MPKChannel* c, int orthomode, const float zoom[2], float ortho[6], float xform[16]); |
| void | mpkChannelGetFrustum(MPKChannel* c, int eye, float frust[6], float xform[16]); |
| int | mpkChannelGetEye(MPKChannel* c); |
| void | mpkChannelGetPixelViewport(MPKChannel* c, int* pvp); |
| void | mpkChannelUpdatePixelViewport(MPKChannel* c); |
| int | mpkChannelGetRange(MPKChannel* c, float* range); |
| void | mpkChannelPushGLState(MPKChannel* c, int state); |
| void | mpkChannelPopGLState(MPKChannel* c); |
| void | mpkChannelAssembleFrame(MPKChannel* c, MPKFrame* frame); |
| void | mpkChannelDrawImage(MPKChannel* channel, MPKImage* image, float region[4]); |
| void | mpkChannelDeclareROI(MPKChannel* c, float region[4]); |
| void | mpkChannelReadFrame(MPKChannel* c, MPKFrame* frame, float region[4]); |
| pfChannel* | mpkChannelGetPfChannel(MPKChannel* c); |
| void* | mpkChannelNextData(MPKChannel* channel); |
| int | mpkChannelCheckData(MPKChannel* channel); |
| void | mpkChannelPassData(MPKChannel* channel, void* data); |
| void | mpkChannelFlushData(MPKChannel* channel); |
| void | mpkChannelPutData(MPKChannel* channel, void* data); |
MPKWindow. The corresponding projection rectangle can be specified in real-world coordinates via mpkChannelSetWall or mpkChannelSetProjection. The application can then be written independently from the current stereo pass, from the viewer's head-position and from the decomposition specified by the current MPKCompound.
main( int argc, char *argv[] )
{
...
mpkConfigSetChannelInitCB( config, initChannel );
...
mpkConfigInit( config );
while ( !exit ) {
...
mpkConfigSetHeadPosition( config, head.position );
mpkConfigFrame( config, framedata );
}
}
void initChannel( MPKChannel *c )
{
mpkChannelSetDrawCB(c, MPK_CHANNEL_DRAWCB_INIT, loadChannel);
mpkChannelSetDrawCB(c, MPK_CHANNEL_DRAWCB_CLEAR, clearChannel);
mpkChannelSetDrawCB(c, MPK_CHANNEL_DRAWCB_UPDATE, updateChannel);
mpkChannelSetNearFar( c, 0.001, 100.0 );
}
void loadChannel( MPKChannel *c, void *framedata )
{
myLoadTextures( framedata );
}
void clearChannel( MPKChannel *c, void *framedata )
{
mpkChannelApplyBuffer(c);
mpkChannelApplyViewport(c);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
void updateChannel( MPKChannel *c, void *framedata )
{
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
mpkChannelApplyFrustum(c);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
mpkChannelApplyHeadTransform(c);
myDrawData( framedata );
}
|
name. This is done by copy and not by reference.channel structure. Transport is done by reference and not by copy.vp.vp.n and f.origin, in the attitude characterized by the hpr angles, and projecting orthogonally onto a wall situated at distance. The horizontal and vertical fields of view of this projector are specified by the argument fov.
projection {
origin [ 0., 0., 0. ]
distance 3.
fov [ 54., 47. ]
hpr [ 0., 0., 0. ] # CENTRE WALL
# hpr [ 50., 0., 0. ] # LEFT WALL
# hpr [ -50., 0., 0. ] # RIGHT WALL
}
|
# 80cm x 60cm screen located 1m in front of the viewer
wall {
bottom_left [ -.4, -.3, -1. ]
bottom_right [ .4, -.3, -1. ]
top_left [ -.4, .3, -1. ]
}
|
MPKGlobal man page for a description of all MPKChannel attributes and their default or possible values.attr to value.attr or, if attr is MPK_CATTR_ALL, unsets all attributes for the passed MPKChannel.attr to its corresponding default value or, if attr is MPK_CATTR_ALL, it resets all attributes for the passed MPKChannel to their default value.attr is set for the passed MPKChannel, 0 otherwise.attr and returns 1 if the attribute is set for the passed MPKChannel, 0 otherwise.which to the passed function, of type:which arewhich.which to the passed function, of type :which arewhich.GL_DRAW_BUFFER and GL_READ_BUFFER for the passed MPKChannel with respect to the current stereo mode and eye pass.
#define IRND(a) ((int)((a)+.5)) // compute first pixel position of the channel channel.pvp[0] = IRND(channel.vp[0] * window.pvp[2]); channel.pvp[1] = IRND(channel.vp[1] * window.pvp[3]); // compute last pixel position of the channel channel.pvp[2] = IRND((channel.vp[0]+channel.vp[2]) * window.pvp[2]); channel.pvp[3] = IRND((channel.vp[1]+channel.vp[3]) * window.pvp[3]); // compute channel's dimension channel.pvp[2] -= channel.pvp[0]; channel.pvp[3] -= channel.pvp[1]; |
vp(1): [0. 0. 0.3333 1. ] pvp(1): [0 0 427 1024]
vp(2): [0.3333 0. 0.3333 1. ] pvp(2): [427 0 426 1024]
|
MPKGlobal variable MPK_DATTR_FULLSTEREO_OFFSET will be added to channel.pvp[1]n and f distances used for the following frustum or ortho operations. This function can be used to dynamically adjust the near and far distance from the channel update callbacks.orthomode is MPK_ORTHO_STILL, then mpkChannelApplyOrtho simply uses the half-width and half-height dimensions of the channel layout to produce the distances used in glOrtho(3G).orthomode is MPK_ORTHO_TRACKED, then mpkChannelApplyOrtho uses the current view direction (e.g. from mpkConfigSetHeadOrientation) in order to produce consistent viewing across all the config's channels.zoom, if not NULL, specifies two-dimensional scaling on the X and Y Screen coordinates.
mpkChannelGetOrtho(c, orthomode, zoom, ortho, xform);
glOrtho( ortho[0], ortho[1], ortho[2], ortho[3], ortho[4], ortho[5] );
glMultMatrixf( xform );
|
mpkChannelApplyOrtho(c, orthomode, zoom);
mpkChannelApplyHeadTransform(c);
|
mpkChannelGetFrustum(c, mpkChannelGetEye(), frust, xform);
glFrustum(frust[0], frust[1], frust[2], frust[3], frust[4], frust[5]);
glMultMatrixf( xform );
|
mpkChannelApplyFrustum(c);
mpkChannelApplyHeadTransform(c);
|
MPK_EYE_CYCLOP in mono mode, MPK_EYE_LEFT or MPK_EYE_RIGHT if the channel is rendered in stereo mode.pvp.MPKGlobal variable MPK_DATTR_FULLSTEREO_OFFSET will be added to the vertical pixel viewport coordinate.range values of the passed MPKChannel if this is relevant, returning 0 otherwise. The range of a MPKChannel is inherited at rendering time from the currently overriding MPKCompound. This information should then be used to render only a portion of the database, e.g. :
mpkChannelGetRange(c,range) )
DrawDatabase( range[0], range[1] );
|
MPKCompound is specified relatively to its hierarchy, whereas the MPKChannel inherits absolute values.
MPK_PIXEL_OPERATION sets up the projection matrix to
perform drawing of input frames
|
if frame format has depth bit set
enable depth test
draw all depth images using mpkChannelDrawImage()
disable depth test
if frame format has color bit set
draw all color images using mpkChannelDrawImage()
if frame format has stencil bit set
draw all stencil images using mpkChannelDrawImage()
|
image into the region of channel.region is interpreted as ( x, y, width, height ), and the area it describes has to be clipped to [0, 0] - [1, 1].frame.frame can be obtained by using the function mpkCompoundGetOutputFrame(). region specifies the 2D fractional viewport to be read into frame with respect to the channel c viewport.frame if they are not big enough for reading the region.channel is involved in the configuration. Please see the MPKCompound documentation for further explanations on culling.data can be done via frame data referenciation and dereferenciation callbacks, to be specified prior to mpkConfigInit() via MPKConfigSetFrameDataRefCB() and MPKConfigSetFrameDataUnrefCB().
while( data = mpkChannelNextData( channel ))
{
switch( visiblity( frustum, data ))
{
case FULL_VISIBLE: // draw whole tree
mpkChannelPassData( channel, data );
break;
case PARTIAL_VISIBLE: // re-test each subtree
foreach child of data
mpkChannelPutData( channel, child );
break;
case NOT_VISIBLE: // discard
break;
}
}
|
data can be done via frame data referenciation and dereferenciation callbacks, to be specified prior to mpkConfigInit() via MPKConfigSetFrameDataRefCB() and MPKConfigSetFrameDataUnrefCB().| # channel FIELDS description | |
| name | "channel-name" |
| viewport | [ xf, yf, wf, hf ] |
| # channel WALL or PROJECTION description | |
| wall | { channel-wall description } |
| projection | { channel-projection description } |
| # channel ORTHO-WALL description | |
| ortho-wall | { channel-ortho-wall description } |
| bottom_left | [ x, y, z ] |
| bottom_right | [ x, y, z ] |
| top_left | [ x, y, z ] |
| origin | [ x, y, z ] |
| distance | value |
| fov | [ horizontal, vertical ] |
| hpr | [ head, pitch, roll ] |
| bottom_left | [ x, y, z ] |
| bottom_right | [ x, y, z ] |
| top_left | [ x, y, z ] |
viewport parameters are relative to the parent window size, and therefore their values should be in the range 0.0 to 1.0MPKCompound, MPKGlobal, MPKWindow