예제 #1
0
/*
 * variation on vtagget. In this case, the tag_num is returned
 */
GAnnotations *
get_tag_num(GapIO *io,                                                 /* in */
	    int gel,                                                   /* in */
	    int num_t,                                                 /* in */
	    char **type,                                               /* in */
	    int *tag_num)                                             /* out */
{
    static GAnnotations a;
    static int anno;
    int arg;
    char str[5];

    if (!gel)
	anno = a.next;
    else
	if (-1 == io_read_annotation(io, gel, &anno))
	    return (GAnnotations *)-1;

    while (anno) {
	tag_read(io, anno, a);
	for (arg = 0; arg < num_t; arg++) {
	    if (idToIndex(type[arg]) == idToIndex(type2str(a.type,str))) {
		*tag_num = anno;
		return &a;
	    }
	}
	anno = a.next;
    }

    return (GAnnotations *)NULL;
}
예제 #2
0
void drawCubesTheHardWay ()
{
  /*
    Without vertex texture support, we have to read the position/rotation
    data back from the hardware every frame and render each cube individually.
  */

  float p0 = positionData [ 0 ] ;
  float p1 = positionData [ 1 ] ;
  float p2 = positionData [ 2 ] ;

  position -> fetchTexture ( positionData ) ;
  rotation -> fetchTexture ( rotationData ) ;

  //if ( positionData [ 0 ] == p0 &&
  //     positionData [ 1 ] == p1 &&
  //     positionData [ 2 ] == p2 )
  //{
  //  fprintf ( stderr, "WARNING: If nothing seems to be working, you may\n"
  //                    "have an old version of the nVidia driver.\n"
  //                    "Version 76.76 is known to be bad.\n" ) ;
  //}

  cubeShader -> use () ;  /* Math = Cube shader */

  glPushClientAttrib   ( GL_CLIENT_VERTEX_ARRAY_BIT ) ;

  glDisableClientState  ( GL_TEXTURE_COORD_ARRAY ) ;

  glEnableClientState  ( GL_COLOR_ARRAY ) ;
  glBindBufferARB      ( GL_ARRAY_BUFFER_ARB, vbo_co ) ;
  glColorPointer       ( 4, GL_FLOAT, 0, vbo_co ? NULL : colours ) ;

  glEnableClientState  ( GL_VERTEX_ARRAY ) ;
  glBindBufferARB      ( GL_ARRAY_BUFFER_ARB, vbo_vx ) ;
  glVertexPointer      ( 3, GL_FLOAT, 0, vbo_vx ? NULL : vertices ) ;

  for ( int y = 0 ; y < TEX_SIZE ; y++ )
    for ( int x = 0 ; x < TEX_SIZE ; x++ )
    {
      float *pos = & positionData [ idToIndex ( x, y ) * 3 ] ;
      float *rot = & rotationData [ idToIndex ( x, y ) * 3 ] ;

      glPushMatrix () ;
      glTranslatef ( pos [ 0 ], pos [ 1 ], pos [ 2 ] ) ;
      glRotatef ( rot [ 0 ] * 180.0f / 3.14159f, 0, 1, 0 ) ;
      glRotatef ( rot [ 1 ] * 180.0f / 3.14159f, 1, 0, 0 ) ;
      glRotatef ( rot [ 2 ] * 180.0f / 3.14159f, 0, 0, 1 ) ;
      glMultiDrawArraysEXT ( GL_TRIANGLE_STRIP, (GLint*)starts,
                                                (GLint*)lengths,
                                                STRIPS_PER_CUBE ) ;
      glPopMatrix () ;
    }

  glBindBufferARB      ( GL_ARRAY_BUFFER_ARB, 0 ) ;
  glPopClientAttrib () ;
}
예제 #3
0
void CCDelegatedRendererLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData)
{
    if (m_renderPassesInDrawOrder.isEmpty())
        return;

    CCRenderPass::Id targetRenderPassId = appendQuadsData.renderPassId;

    // If the index of the renderPassId is 0, then it is a renderPass generated for a layer
    // in this compositor, not the delegated renderer. Then we want to merge our root renderPass with
    // the target renderPass. Otherwise, it is some renderPass which we added from the delegated
    // renderer.
    bool shouldMergeRootRenderPassWithTarget = !targetRenderPassId.index;
    if (shouldMergeRootRenderPassWithTarget) {
        // Verify that the renderPass we are appending to is created our renderTarget.
        ASSERT(targetRenderPassId.layerId == renderTarget()->id());

        CCRenderPass* rootDelegatedRenderPass = m_renderPassesInDrawOrder.last();
        appendRenderPassQuads(quadSink, appendQuadsData, rootDelegatedRenderPass);
    } else {
        // Verify that the renderPass we are appending to was created by us.
        ASSERT(targetRenderPassId.layerId == id());

        int renderPassIndex = idToIndex(targetRenderPassId.index);
        CCRenderPass* delegatedRenderPass = m_renderPassesInDrawOrder[renderPassIndex];
        appendRenderPassQuads(quadSink, appendQuadsData, delegatedRenderPass);
    }
}
예제 #4
0
inline float idToFloat ( int x, int y )
{
  /*
    Convert a coordinate pair within the texture to a float
    by putting one coordinate into the integer part and the
    other into the fraction so we can retrieve Y using floor()
    and X using fract() to recover them later on inside the shader.
  */
  return ((float) idToIndex ( x, y )) / (float)TEX_SIZE ;
}
예제 #5
0
void DetectingStage::calTalkTime(int personId){
	int index = idToIndex(personId);
	if (!isStartTalking_[personId]){
		startTimeTalk_[personId] = getElapsedSeconds() + 1;
		isStartTalking_[personId] = true;
	}
	else if (startTimeTalk_[personId] < getElapsedSeconds()){
		timeTalk_++;
		isStartTalking_[personId] = false;
	}
	
}
예제 #6
0
void initMotionTextures ()
{
  if ( debugOpt == DRAW_WITHOUT_SHADERS ) return ;

  position    = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
  rotation    = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
  old         = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;

  if ( debugOpt == DRAW_WITHOUT_PHYSICS )
  {
    velocity    = NULL ;
    rotvelocity = NULL ;
    force       = NULL ;
    new_force   = NULL ;
    massSizeX   = NULL ;
    collisions  = NULL ;
  }
  else
  {
    velocity    = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
    rotvelocity = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
    force       = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
    new_force   = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
    massSizeX   = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
    collisions  = new FrameBufferObject ( TEX_SIZE, TEX_SIZE, 3, FBO_FLOAT ) ;
  }

  positionData    = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
  rotationData    = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;

  float *velocityData    ;
  float *rotvelocityData ;
  float *forceData       ;
  float *massSizeXData   ;

  if ( debugOpt == DRAW_WITHOUT_PHYSICS )
  {
    velocityData    = NULL ;
    rotvelocityData = NULL ;
    forceData       = NULL ;
    massSizeXData   = NULL ;
    collisionData   = NULL ;
  }
  else
  {
    velocityData    = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
    rotvelocityData = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
    forceData       = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
    massSizeXData   = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
    collisionData   = new float [ TEX_SIZE * TEX_SIZE * 3 ] ;
  }

  /* Give the objects some initial position, rotation, mass, force, etc */

  for ( int y = 0 ; y < TEX_SIZE ; y++ )
    for ( int x = 0 ; x < TEX_SIZE ; x++ )
    {
      /*
        Start the cubes on a nice, regular 5m grid, 10m above the ground
        centered around the origin
      */

      positionData    [ idToIndex(x,y) * 3 + 0 ] = 5.0f * (float) (x - TEX_SIZE/2) ;
      positionData    [ idToIndex(x,y) * 3 + 1 ] = 0.0f ; // 10.0f ;
      positionData    [ idToIndex(x,y) * 3 + 2 ] = 5.0f * (float) (y - TEX_SIZE/2) ;

      /* Zero their rotations */
      rotationData    [ idToIndex(x,y) * 3 + 0 ] = 0.0f ;
      rotationData    [ idToIndex(x,y) * 3 + 1 ] = 0.0f ;
      rotationData    [ idToIndex(x,y) * 3 + 2 ] = 0.0f ;

      if ( debugOpt != DRAW_WITHOUT_PHYSICS )
      {
        /* Random (but predominantly upwards) velocities. */
if(irand(2)==0)
{
        velocityData    [ idToIndex(x,y) * 3 + 0 ] = frand ( 1.0f ) ;
        velocityData    [ idToIndex(x,y) * 3 + 1 ] = 0.0f ;
        velocityData    [ idToIndex(x,y) * 3 + 2 ] = frand ( 1.0f ) ;
}
else
{
        velocityData    [ idToIndex(x,y) * 3 + 0 ] = 0.0f ; //frand (  10.0f ) - 5.0f;
        velocityData    [ idToIndex(x,y) * 3 + 1 ] = 0.0f ; //frand ( 100.0f ) ;
        velocityData    [ idToIndex(x,y) * 3 + 2 ] = 0.0f ; //frand (  10.0f ) - 5.0f;
}

        /* Random rotational velocities */
        rotvelocityData [ idToIndex(x,y) * 3 + 0 ] = 0.0f ; //frand ( 3.0f ) ;
        rotvelocityData [ idToIndex(x,y) * 3 + 1 ] = 0.0f ; //frand ( 3.0f ) ;
        rotvelocityData [ idToIndex(x,y) * 3 + 2 ] = 0.0f ; //frand ( 3.0f ) ;

        /* Zero forces */
        forceData       [ idToIndex(x,y) * 3 + 0 ] = 0.0f ;
        forceData       [ idToIndex(x,y) * 3 + 1 ] = 0.0f ;
        forceData       [ idToIndex(x,y) * 3 + 2 ] = 0.0f ;

        /* One kg each */
        massSizeXData   [ idToIndex(x,y) * 3 + 0 ] = 0.05f ; /* Mass */
        massSizeXData   [ idToIndex(x,y) * 3 + 1 ] = 1.0f ;  /* Radius */
        massSizeXData   [ idToIndex(x,y) * 3 + 2 ] = 0.0f ;  /* Unused */

        /* Zero out collision data */
        collisionData [ idToIndex(x,y) * 3 + 0 ] = 0.0f ;
        collisionData [ idToIndex(x,y) * 3 + 1 ] = 0.0f ;
        collisionData [ idToIndex(x,y) * 3 + 2 ] = 0.0f ;
      }
    }

  if ( debugOpt != DRAW_WITHOUT_PHYSICS )
  {
    /*
      Object zero is the 'null' object for collision detection
      so put it far away and stop it from moving around.
    */

    positionData  [ 0 ] = 1000000000.0f ;
    positionData  [ 1 ] = 1000000000.0f ;
    positionData  [ 2 ] = 1000000000.0f ;
    velocityData  [ 0 ] = 0.0f ;
    velocityData  [ 1 ] = 0.0f ;
    velocityData  [ 2 ] = 0.0f ;
    massSizeXData [ 0 ] = 10000000.0f ;  /* Mass   */
    massSizeXData [ 1 ] = 0.00000001f ;  /* Radius */
    massSizeXData [ 2 ] = 0.0f ;         /* Unused */
    collisionData [ 0 ] = 0.0f ;
    collisionData [ 1 ] = 0.0f ;
    collisionData [ 2 ] = 0.0f ;
  }

  /* Initialise the textures */

  position    -> fillTexture ( positionData ) ;
  rotation    -> fillTexture ( rotationData ) ;
  old         -> fillTexture ( positionData ) ;  // Doesn't really need it...

  if ( debugOpt != DRAW_WITHOUT_PHYSICS )
  {
    velocity    -> fillTexture ( velocityData ) ;
    rotvelocity -> fillTexture ( rotvelocityData ) ;
    force       -> fillTexture ( forceData ) ;
    new_force   -> fillTexture ( forceData ) ;
    massSizeX   -> fillTexture ( massSizeXData ) ;
    collisions  -> fillTexture ( collisionData ) ;
  }
}