コード例 #1
0
ファイル: Camera.c プロジェクト: joanasleet/isoengineOld
void updateCam( Camera *cam ) {

    State *state = cam->state;

    /* update target orientation */
    applyTorque( state );
    quatSlerp( state->orientation, state->targetOrien, state->orientation, cam->smoothing );
    quatNorm( state->orientation );

    /* rotation matrix */
    GLfloat rotaMatrix[16];
    quatToMat(rotaMatrix, state->orientation);

    /* update orientation vectors */
    mat4multVec3(rotaMatrix, baseUpVec, state->up );
    mat4multVec3(rotaMatrix, baseRightVec, state->right );
    mat4multVec3(rotaMatrix, baseForwardVec, state->forward );

    // calc & update velocity
    float newVel[] = {
        state->velocity[0] + lerpStep(state->velocity[0], state->targetVelocity[0], cam->smoothing ),
        state->velocity[1] + lerpStep(state->velocity[1], state->targetVelocity[1], cam->smoothing ),
        state->velocity[2] + lerpStep(state->velocity[2], state->targetVelocity[2], cam->smoothing )
    };
    cpyBuf( state->velocity, newVel, 3 );
    calcPosition( state->position, state, 1.0f);
    watch( "Camera Position ( %.1f, %.1f, %.1f )\n", state->position[0], state->position[1], state->position[2] );

    // calc & store perspective
    cam->fov[0] += lerpStep( cam->fov[0], cam->fov[1], cam->smoothing );
    mat4perspinf( cam->perspective, cam->nearClip, cam->fov[0], cam->aspectRatio );
}
コード例 #2
0
ファイル: nls.c プロジェクト: TijmenW/FreeDOS
/* GetData function used by both the MUX-callback function and
	the direct-access interface.
	subfct == NLS_DOS_38 is a value > 0xff in order to not clash
	with subfunctions valid to be passed as DOS-65-XX. */
STATIC int nlsGetData(struct nlsPackage FAR * nls, int subfct,
                      UBYTE FAR * buf, unsigned bufsize)
{
  VOID FAR *poi;

  log(("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n",
       subfct, bufsize, nls->cp, nls->cntry));

  /* Theoretically tables 1 and, if NLS_REORDER_POINTERS is enabled,
     2 and 4 could be hard-coded, because their
     data is located at predictable (calculatable) locations.
     However, 1 and subfct NLS_DOS_38 are to handle the same
     data and the "locateSubfct()" call has to be implemented anyway,
     in order to handle all subfunctions.
     Also, NLS is often NOT used in any case, so this code is more
     size than speed optimized. */
  if ((poi = locateSubfct(nls, subfct)) != NULL)
  {
    log(("NLS: nlsGetData(): subfunction found\n"));
    switch (subfct)
    {
      case 1:                  /* Extended Country Information */
        return cpyBuf(buf, bufsize, poi,
                      ((struct nlsExtCntryInfo FAR *)poi)->size + 3);
      case NLS_DOS_38:         /* Normal Country Information */
        return cpyBuf(buf, bufsize, &(((struct nlsExtCntryInfo FAR *)poi)->dateFmt), 24);       /* standard cinfo has no more 34 _used_ bytes */
        /* don't copy 34, copy only 0x18 instead, 
           see comment at DosGetCountryInformation                      TE */
      default:
        /* All other subfunctions just return the found nlsPoinerInf
           structure */
        return cpyBuf(buf, bufsize, poi, sizeof(struct nlsPointer));
    }
  }

  /* The requested subfunction could not been located within the
     NLS pkg --> error. Because the data corresponds to the subfunction
     number passed to the API, the failure is the same as that a wrong
     API function has been called. */
  log(("NLS: nlsGetData(): Subfunction not found\n"));
  return DE_INVLDFUNC;
}