Example #1
0
File: camera.c Project: kfowlks/MD2
void strafe_right() {
		camera_x += fsin(camera_yrot+(90*piover180)) * 0.1f;
		camera_z += fcos(camera_yrot+(90*piover180)) * 0.1f;
		walkbiasangle-= 10;
		walkbiasangle%=360;
		walkbias=fsin(walkbiasangle * piover180)*0.25f;
}
Example #2
0
/* draw_object just draws a single object at a fixed position, although
this can easily be modified to allow for more objects.
bmp = bitmap to draw to. obj = sprite for the object.
angle, cx, cy define the camera position.
*/
void draw_object (BITMAP *bmp, BITMAP *obj, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params)
{
    int width, height;
    int screen_y, screen_x;

    // The object in this case is at a fixed position of (160, 100).
    // Calculate the position relative to the camera.
    fixed obj_x = itofix(160) - cx;
    fixed obj_y = itofix(100) - cy;

    // use a rotation transformation to rotate the object by the camera
    // angle
    fixed space_x = fmul (obj_x, fcos (angle)) + fmul (obj_y, fsin (angle));
    fixed space_y = -fmul (obj_x, fsin (angle)) + fmul (obj_y, fcos (angle));

    // calculate the screen coordinates that go with these space coordinates
    // by dividing everything by space_x (the distance)
    screen_x = bmp->w/2 + fixtoi (fmul (fdiv (params.scale_x, space_x), space_y));
    screen_y = fixtoi (fdiv (fmul (params.space_z, params.scale_y), space_x)) - params.horizon;

    // the size of the object has to be scaled according to the distance
    height = fixtoi (obj->h * fdiv(params.obj_scale_y, space_x));
    width = fixtoi (obj->w * fdiv(params.obj_scale_x, space_x));

    // draw the object
    stretch_sprite (bmp, obj, screen_x - width / 2, screen_y - height, width, height);
}
Example #3
0
matrix_t * fime_ship_update(const float seconds)
{
  static float ax;
  static float ay;
  matrix_t tmp;
  float x,y,z;
  vtx_t oldpos = *(vtx_t *)mtx[3];
    

  MtxIdentity(tmp);

  x = fsin(ax += 0.015f) * 1.5;
  y = (fsin(ay += 0.008f) + 1) * -0.5;
  z = 0; //mtx[3][2] + 0.00;

  angle.z = (x - oldpos.x) * 40;
  angle.x = (y - oldpos.y) * -20;
/*   angle.z = angle.z < 0 ? -3.1 : 3.1; */

  MtxIdentity(mtx);
  MtxRotateZ(mtx, angle.z);
  MtxRotateX(mtx, angle.x);
  MtxRotateY(mtx, angle.y);

  mtx[3][0] = x;
  mtx[3][1] = y;
  mtx[3][2] = z;
  
  return &mtx;
}
Example #4
0
void _inplace_glify(GLfloat* v)
{
    hmatrix xmat;
    hvector rvec;
    real32 deg = -90.0f;
    real32 deg2 = -90.0f;

    hmatMakeRotAboutZ(&xmat, fcos(DEG_TO_RAD(deg)), fsin(DEG_TO_RAD(deg)));
    hmatMultiplyHVecByHMat(&rvec, (hvector*)v, &xmat);
    if (v[3] != 0.0f)
    {
        v[0] /= v[3];
        v[1] /= v[3];
        v[2] /= v[3];
    }
    memcpy(v, &rvec, 3*sizeof(real32));

    hmatMakeRotAboutX(&xmat, fcos(DEG_TO_RAD(deg2)), fsin(DEG_TO_RAD(deg2)));
    hmatMultiplyHVecByHMat(&rvec, (hvector*)v, &xmat);
    if (v[3] != 0.0f)
    {
        v[0] /= v[3];
        v[1] /= v[3];
        v[2] /= v[3];
    }
    memcpy(v, &rvec, 3*sizeof(real32));
}
Example #5
0
File: fsin.c Project: cpu2015g6/FPU
/*[0,pi/4)に簡約*/
uint32_t fsin(uint32_t f){

  if(fcmp(f,0) == 0)
    return fneg(fsin(f - (1 << 31)));
  if(fcmp(f,0x40c90fda) == 2)
    return fsin(fadd(f,0xc0c90fda));
  if(fcmp(f,MYPI) == 0){
    if(fcmp(f,MYPI2) == 0){
      if(fcmp(f,MYPI4) == 0)
	return kernel_sin(f);
      else
	return kernel_cos(fadd(MYPI2,fneg(f)));
    }else{
      if(fcmp(f,fadd(MYPI4,MYPI2)) == 0)
	kernel_cos(fadd(f,fneg(MYPI2)));
      else
	kernel_sin(fadd(MYPI,fneg(f)));
    }
  }else{
    f = fadd(f,fneg(MYPI));
    if(fcmp(f,MYPI2) == 0){
      if(fcmp(f,MYPI4) == 0)
	return fneg(kernel_sin(f));
      else
	return fneg(kernel_cos(fadd(MYPI2,fneg(f))));
    }else{
      if(fcmp(f,fadd(MYPI4,MYPI2)) == 0)
	fneg(kernel_cos(fadd(f,fneg(MYPI2))));
      else
	fneg(kernel_sin(fadd(MYPI,fneg(f))));
    }
  }
  
}
Example #6
0
/*-----------------------------------------------------------------------------
    Name        : btgConvertAVert
    Description : spherically unprojects a vert
    Inputs      : out - target output vector
                  x, y - 2D position
    Outputs     : out is modified
    Return      :
----------------------------------------------------------------------------*/
void btgConvertAVert(math::Vec3f* out, real64 x, real64 y)
{
    real32 xFrac, yFrac;
    real32 theta, phi;
    real32 sinTheta, cosTheta;
    real32 sinPhi, cosPhi;
    real32 pageWidth, pageHeight;
    real32 radius;

    pageWidth  = (real32)btgHead->pageWidth;
    pageHeight = (real32)btgHead->pageHeight;

    x = ((real64)pageWidth - 1.0) - x;

    xFrac = (real32)x / pageWidth;
    yFrac = (real32)y / pageHeight;

    theta = 2.0f * M_PI_F * xFrac;
    phi   = 1.0f * M_PI_F * yFrac;

	theta += math::degToRad(btgThetaOffset) + math::degToRad(90.0f);
    phi += math::degToRad(btgPhiOffset);

    sinTheta = fsin(theta);
    cosTheta = fcos(theta);
    sinPhi = fsin(phi);
    cosPhi = fcos(phi);

    radius = 1.0;
    out->x = radius * cosTheta * sinPhi;
    out->y = radius * sinTheta * sinPhi;
    out->z = radius * cosPhi;
}
Example #7
0
/*-----------------------------------------------------------------------------
    Name        : btgConvertAVert
    Description : spherically unprojects a vert
    Inputs      : out - target output vector
                  x, y - 2D position
    Outputs     : out is modified
    Return      :
----------------------------------------------------------------------------*/
void btgConvertAVert(vector* out, real32 x, real32 y)
{
    real32 xFrac, yFrac;
    real32 theta, phi;
    real32 sinTheta, cosTheta;
    real32 sinPhi, cosPhi;
    real32 pageWidth, pageHeight;
    real32 radius;

    pageWidth  = (real32)btgHead->pageWidth;
    pageHeight = (real32)btgHead->pageHeight;

    x = ((real32)pageWidth - 1.0) - x;

    xFrac = (real32)x / pageWidth;
    yFrac = (real32)y / pageHeight;

    theta = 2.0f * M_PI_F * xFrac;
    phi   = 1.0f * M_PI_F * yFrac;

    theta += DEG_TO_RAD(btgThetaOffset) + DEG_TO_RAD(90.0f);
    phi += DEG_TO_RAD(btgPhiOffset);

    sinTheta = fsin(theta);
    cosTheta = fcos(theta);
    sinPhi = fsin(phi);
    cosPhi = fcos(phi);

    radius = CAMERA_CLIP_FAR - 500.0f;
    out->x = radius * cosTheta * sinPhi;
    out->y = radius * sinTheta * sinPhi;
    out->z = radius * cosPhi;
}
Example #8
0
File: camera.c Project: kfowlks/MD2
void walk_backward() {
		camera_x += (fsin(camera_yrot)*rad_to_deg) * 0.002f;
		camera_z -= (fcos(camera_yrot)*rad_to_deg) * 0.002f;
		walkbiasangle-= 10;
		walkbiasangle%=360;
		walkbias=fsin(walkbiasangle * piover180)*0.25f;
}
Example #9
0
void 
flat_face(float ir, float or, float wd)
{

  int i;
  float w;

  /* draw each face (top & bottom ) * */
  if (poo)
    printf("Face  : %f..%f wid=%f\n", ir, or, wd);
  if (wd == 0.0)
    return;
  for (w = wd / 2; w > -wd; w -= wd) {
    if (w > 0.0)
      glNormal3f(0.0, 0.0, 1.0);
    else
      glNormal3f(0.0, 0.0, -1.0);

    if (ir == 0.0) {
      /* draw as t-fan */
      glBegin(GL_TRIANGLE_FAN);
      glVertex3f(0.0, 0.0, w);  /* center */
      glVertex3f(or, 0.0, w);
      for (i = 1; i < circle_subdiv; i++) {
        glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * or,
          fsin(2.0 * M_PI * i / circle_subdiv) * or,
          w);
      }
      glVertex3f(or, 0.0, w);
      glEnd();
    } else {
      /* draw as tmesh */
      glBegin(GL_TRIANGLE_STRIP);
      glVertex3f(or, 0.0, w);
      glVertex3f(ir, 0.0, w);
      for (i = 1; i < circle_subdiv; i++) {
        glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * or,
          fsin(2.0 * M_PI * i / circle_subdiv) * or,
          w);
        glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * ir,
          fsin(2.0 * M_PI * i / circle_subdiv) * ir,
          w);
      }
      glVertex3f(or, 0.0, w);
      glVertex3f(ir, 0.0, w);
      glEnd();

    }
  }
}
Example #10
0
void mode_7 (BITMAP *bmp, BITMAP *tile, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params)
{
    // current screen position
    int screen_x, screen_y;

    // the distance and horizontal scale of the line we are drawing
    fixed distance, horizontal_scale;

    // masks to make sure we don't read pixels outside the tile
    int mask_x = (tile->w - 1);
    int mask_y = (tile->h -1);

    // step for points in space between two pixels on a horizontal line
    fixed line_dx, line_dy;

    // current space position
    fixed space_x, space_y;

    for (screen_y = 0; screen_y < bmp->h; screen_y++)
    {
        // first calculate the distance of the line we are drawing
        distance = fdiv (fmul (params.space_z, params.scale_y),
            itofix (screen_y + params.horizon));
        // then calculate the horizontal scale, or the distance between
        // space points on this horizontal line
        horizontal_scale = fdiv (distance, params.scale_x);

        // calculate the dx and dy of points in space when we step
        // through all points on this line
        line_dx = fmul (-fsin(angle), horizontal_scale);
        line_dy = fmul (fcos(angle), horizontal_scale);

        // calculate the starting position
        space_x = cx + fmul (distance, fcos(angle)) - bmp->w/2 * line_dx;
        space_y = cy + fmul (distance, fsin(angle)) - bmp->w/2 * line_dy;

        // go through all points in this screen line
        for (screen_x = 0; screen_x < bmp->w; screen_x++)
        {
            // get a pixel from the tile and put it on the screen
            putpixel (bmp, screen_x, screen_y,
                getpixel (tile,
                    fixtoi (space_x) & mask_x,
                    fixtoi (space_y) & mask_y ));
            // advance to the next position in space
            space_x += line_dx;
            space_y += line_dy;
        }
    }
}
Example #11
0
void matrix4::perspective(float fovy, float aspect, float zNear, float zFar, bool infinite)
{
    double radians = fovy / 2 * (3.14159265358979323846) / 180;
    double cotangent = fcos(radians) / fsin(radians);
	float deltaZ = zFar - zNear;

	m[0] = (float)(cotangent / aspect);
	m[1] = 0.0f;
	m[2] = 0.0f;
	m[3] = 0.0f;

	m[4] = 0.0f;
	m[5] = (float)cotangent;
	m[6] = 0.0f;
	m[7] = 0.0f;
	
	m[8] = 0.0f;
	m[9] = 0.0f;
	m[10] = -(zFar + zNear) / deltaZ;
	m[11] = -1.0f;
	
	m[12] = 0.0f;
	m[13] = 0.0f;
	m[14] = -2 * zNear * zFar / deltaZ;
	m[15] = 0.0f;

	if (infinite)
	{
		m[10] = -1.0f;
		m[14] = -2.0f;
	}
}
Example #12
0
void main()
{
	init_sincos_library();
	printf("sine: %f\n",fsin(M_PI));
	printf("cosine: %f\n",fcos(M_PI));
	close_sincos_library();
}
Example #13
0
static void
update_IrPoints( irInfo* irs)
{
  int cnt;
  Point rpos;
  float rrot;

  float distanceToObstacle = ROB_RADIUS + IR_THRESHOLD_DIST;
  
  updateActualPosition( &rpos, &rrot, DONT_CONSIDER_DIRECTION);

  for ( cnt = 0; cnt < irs->numberOfActivatedIrs; cnt++) {
    
    float angle = rrot + irs->angle[cnt];
    
    Ir_Obstacle_Points.points[cnt].x =
      rpos.x + (fcos( angle) * distanceToObstacle);
    Ir_Obstacle_Points.points[cnt].y =
      rpos.y + (fsin( angle) * distanceToObstacle);
  }

  if ( irs->numberOfActivatedIrs > 0)
    setStartTime( IR_TIMER);
  
  Ir_Obstacle_Points.no_of_points = irs->numberOfActivatedIrs;
}
int fcos( short alpha)
{   // cos(a ) == sin (a+90)
    int i;
    i = fsin( alpha + 90);
    return i;

} // fcos
Example #15
0
static int grproc_xadvance( INSTANCE * my, int * params )
{
    int angle = params[0] ;
    LOCINT32( mod_grproc, my, COORDX ) += fixtoi( fmul( fcos( angle ), itofix( params[1] ) ) ) ;
    LOCINT32( mod_grproc, my, COORDY ) -= fixtoi( fmul( fsin( angle ), itofix( params[1] ) ) ) ;
    return 1 ;
}
Example #16
0
// create a globe with constant radius and color
void miniglobe::create_globe(float radius,const float color[3])
   {
   int i,j;

   const int alpha_steps=4*STRIPES;
   const int beta_steps=STRIPES;

   float u,v;
   float alpha,beta;
   float nx,ny,nz;

   STRIP->setcol(color[0],color[1],color[2]);

   for (j=-beta_steps; j<beta_steps; j++)
      {
      STRIP->beginstrip();

      for (i=alpha_steps; i>=0; i--)
         {
         u=(float)i/alpha_steps;
         v=(float)j/beta_steps;

         alpha=u*2*PI;
         beta=v*PI/2;

         nx=fcos(alpha)*fcos(beta);
         nz=-fsin(alpha)*fcos(beta);
         ny=fsin(beta);

         STRIP->setnrm(nx,ny,nz);
         STRIP->settex(u,0.5f-v/2);
         STRIP->addvtx(nx*radius,ny*radius,nz*radius);

         v=(float)(j+1)/beta_steps;
         beta=v*PI/2;

         nx=fcos(alpha)*fcos(beta);
         nz=-fsin(alpha)*fcos(beta);
         ny=fsin(beta);

         STRIP->setnrm(nx,ny,nz);
         STRIP->settex(u,0.5f-v/2);
         STRIP->addvtx(nx*radius,ny*radius,nz*radius);
         }
      }
   }
Example #17
0
int main(int argc, char **argv) {
    int done, i;
    float theta, dt;
    float colors[3*10] = {
        0.0f, 0.5f, 1.0f,
        0.0f, 1.0f, 0.0f,
        1.0f, 0.0f, 0.0f,
        0.0f, 0.0f, 1.0f,
        0.5f, 0.5f, 0.0f,
        0.5f, 0.0f, 0.5f,
        0.5f, 0.5f, 0.5f,
        0.73f, 0.8f, 0.25f,
        0.25f, 0.8f, 0.73f,
        1.0f, 1.0f, 0.0f
    };

    // Init PVR
    pvr_init_defaults();

    // Setup the context
    plx_cxt_init();
    plx_cxt_texture(NULL);
    plx_cxt_culling(PLX_CULL_NONE);

    // Until the user hits start...
    dt = 2*M_PI/160.0f;
    for (done = 0, theta = 0.0f; !done; ) {
        // Check for start
        MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
        if (st->buttons & CONT_START)
            done = 1;
        MAPLE_FOREACH_END()

        // Setup the frame
        pvr_wait_ready();
        pvr_scene_begin();
        pvr_list_begin(PVR_LIST_OP_POLY);

        // Submit the context
        plx_cxt_send(PVR_LIST_OP_POLY);

        // Draw a sinus bar at our current position and several positions
        // back. Each bar will get its own Z value (descending).
        for (i=0; i<10; i++) {
            drawbar(240.0f + fsin(theta - dt*i*6) * 120.0f, 100.0f - i,
                    colors[i*3+0], colors[i*3+1], colors[i*3+2]);
        }

        pvr_scene_finish();

        // Move our counters
        theta += dt;
        while (theta >= 2*M_PI)
            theta -= 2*M_PI;
    }

    return 0;
}
Example #18
0
// readjust the settings, call this when slide dimension is changed
void PictureFlowState::reposition() {
  angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted

  offsetX = slideWidth / 2 * (PFREAL_ONE - fcos(angle));
  offsetY = slideWidth / 2 * fsin(angle);
  offsetX += slideWidth * PFREAL_ONE;
  offsetY += slideWidth * PFREAL_ONE / 4;
  spacing = 40;
}
Example #19
0
    ComputeSHShader()
    {
        std::ifstream fsin("../examples/shaders/computesh.comp", std::ios::in);
        const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());
        Program = ProgramShaderLoading::LoadProgram(
                      GL_COMPUTE_SHADER, fs.c_str());

        AssignSamplerNames(Program, "DATA", "probe");
        GLuint SHblock = glGetProgramResourceIndex(Program, GL_SHADER_STORAGE_BLOCK, "SH");
        glShaderStorageBlockBinding(Program, SHblock, 0);
    }
Example #20
0
void sphere(float s, float t, float *x, float *y, float *z, float *nx, float *ny, float *nz)
{
	float r;
	float RGV;
	

	*y = sin((t-0.5)*PI) * (maxy-miny)/2.0 + (maxy+miny)/2 + 0.5;
	r = cos((t-0.5)*PI);
	*x = r * sin(s*2*PI) * (maxx-minx)/2.0 + (maxx+minx)/2 + 0.5;
	*z = r * cos(s*2*PI) * (maxz-minz)/2.0 + (maxz+minz)/2 + 0.5;

	*nx = fsin(3.0 * 2.0 * PI * s) * 127.0 + 127.0;
	*ny = fsin(3.0 * 2.0 * PI * t) * 127.0 + 127.0;

	RGV = (*nx/255.0) * (*nx/255.0) + (*ny/255.0) * (*ny/255.0);
	if (RGV < 0.25)
	  *nz = 255.0 - (*nx/255.0) * (*nx/255.0) - (*ny/255.0) * (*ny/255.0);
	else
	  *nz = 0;	  
}
Example #21
0
 static date_type local_dst_end_day(year_type year)
 {
   if (year >= year_type(2007)) {
     //first sunday in november
     fkday fsin(Sunday, gregorian::Nov);
     return fsin.get_date(year);      
   } else {
     //last sunday in october
     lkday lsio(Sunday, gregorian::Oct);
     return lsio.get_date(year);
   }
 }
Example #22
0
void alienrocket::update(){
     if(fired){
        // rocket moves towards destination:
        if((fixtoi(x) > 0) && (fixtoi(x) < 800) && (fixtoi(y) < 600) && (fixtoi(y) > 0)){
              x += speed * fcos (angle);
              y += speed * fsin (angle); 
        }else{ fired = false; }
        //angle = (angle + angle_stepsize) & 0xFFFFFF; 
        //if we hit the player
        if (abs (x - targetX) + abs (y - targetY) < itofix(50)){ hit = true; fired = false; } 
    } 
}
Example #23
0
int main(void) {
	GHandle		gh;
	uint16_t 	i;
	
	gfxInit();
	
	{
		GWindowInit wi;

		gwinClearInit(&wi);
		wi.show = TRUE;
		wi.x = wi.y = 0;
		wi.width = gdispGetWidth();
		wi.height = gdispGetHeight();
		gh = gwinGraphCreate(&g, &wi);
	}

	gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
	gwinGraphSetStyle(gh, &GraphStyle1);
	gwinGraphDrawAxis(gh);
	
	for(i = 0; i < gwinGetWidth(gh); i++)
		gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*fsin(2*i/5));	//sin(2*0.2*M_PI*i/180));

	gwinGraphStartSet(gh);
	GraphStyle1.point.color = uGreen;
	gwinGraphSetStyle(gh, &GraphStyle1);
	
	for(i = 0; i < gwinGetWidth(gh)*5; i++)
		gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*fsin(2*i/5));	//sin(2*0.2*M_PI*i/180));

	gwinGraphStartSet(gh);
	gwinGraphSetStyle(gh, &GraphStyle2);

	gwinGraphDrawPoints(gh, data, sizeof(data)/sizeof(data[0]));

	while(TRUE) {
		gfxSleepMilliseconds(100);
	}
}
Example #24
0
    Tonemap()
    {
        std::ifstream vsin("../examples/shaders/screenquad.vert", std::ios::in);
        const std::string &vs = std::string((std::istreambuf_iterator<char>(vsin)), std::istreambuf_iterator<char>());

        std::ifstream fsin("../examples/shaders/tonemap.frag", std::ios::in);
        const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());
        Program = ProgramShaderLoading::LoadProgram(
                      GL_VERTEX_SHADER, vs.c_str(),
                      GL_FRAGMENT_SHADER, fs.c_str());

        AssignSamplerNames(Program, "tex");
    }
Example #25
0
        IBLShader()
        {
            std::ifstream vsin("../examples/shaders/screenquad.vert", std::ios::in);
            const std::string &vs = std::string((std::istreambuf_iterator<char>(vsin)), std::istreambuf_iterator<char>());

            std::ifstream fsin("../examples/shaders/ibl.frag", std::ios::in);
            const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());
            Program = ProgramShaderLoading::LoadProgram(
                          GL_VERTEX_SHADER, vs.c_str(),
                          GL_FRAGMENT_SHADER, fs.c_str());

            AssignSamplerNames(Program, "VIEWDATA", "IBLDATA", "ntex", "ctex", "dtex", "probe", "dfg");
        }
Example #26
0
        ImportanceSamplingForSpecularCubemap()
        {
            std::ifstream vsin("../examples/shaders/screenquad.vert", std::ios::in);
            const std::string &vs = std::string((std::istreambuf_iterator<char>(vsin)), std::istreambuf_iterator<char>());

            std::ifstream fsin("../examples/shaders/importance_sampling_specular.frag", std::ios::in);
            const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());
            Program = ProgramShaderLoading::LoadProgram(
                          GL_VERTEX_SHADER, vs.c_str(),
                          GL_FRAGMENT_SHADER, fs.c_str());

            AssignSamplerNames(Program, "Matrix", "tex", "samples");
        }
Example #27
0
    Skybox()
    {
        std::ifstream vsin("../examples/shaders/skybox.vert", std::ios::in);
        const std::string &vs = std::string((std::istreambuf_iterator<char>(vsin)), std::istreambuf_iterator<char>());

        std::ifstream fsin("../examples/shaders/skybox.frag", std::ios::in);
        const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());
        Program = ProgramShaderLoading::LoadProgram(
                      GL_VERTEX_SHADER, vs.c_str(),
                      GL_FRAGMENT_SHADER, fs.c_str());

        AssignSamplerNames(Program, "Matrixes", "skytexture");
    }
Example #28
0
// T and Q defines the light source as polar coordinates where
// T is the elevation angle ranging from 0 to Pi/2 (90 degrees) and
// Q is the rotation angle ranging from 0 to Pi*2 (360 degrees).
// h is an intensity value specifying how much bumping should be done. 0 <= h <= 1
void
set_bump_direction (float T, float Q, float h)
{
  unsigned char Q2 = (unsigned char) ((Q / (2 * 3.1415927))* 255);
  unsigned char h2 = (unsigned char) (h * 255);

  unsigned char k1 = 255 - h2;
  unsigned char k2 = (unsigned char) (h2 * fsin(T));
  unsigned char k3 = (unsigned char) (h2 * fcos(T));

  /* The bump direction is encoded as an offset colour.  */
  glKosOffsetColor4ub (k2, k3, Q2, k1);
}
Example #29
0
    ObjectShader()
    {
        std::ifstream vsin("../examples/shaders/object.vert", std::ios::in);
        const std::string &vs = std::string((std::istreambuf_iterator<char>(vsin)), std::istreambuf_iterator<char>());

        std::ifstream fsin("../examples/shaders/object_gbuffer.frag", std::ios::in);
        const std::string &fs = std::string((std::istreambuf_iterator<char>(fsin)), std::istreambuf_iterator<char>());

        Program = ProgramShaderLoading::LoadProgram(
                      GL_VERTEX_SHADER, vs.c_str(),
                      GL_FRAGMENT_SHADER, fs.c_str());

        AssignSamplerNames(Program, "ViewMatrices", "ObjectData", "tex");
    }
Example #30
0
// readjust the settings, call this when slide dimension is changed
void PictureFlowState::reposition()
{
 // angle = 70 * IANGLE_MAX / 360;  // approx. 70 degrees tilted
  angle = rawAngle  * IANGLE_MAX / 360;
  offsetX = slideWidth/2 * (PFREAL_ONE-fcos(angle));
  offsetY = slideWidth/2 * fsin(angle);
  offsetX += slideWidth * PFREAL_ONE;
  offsetY += slideWidth * PFREAL_ONE / 3;
  if(rawAngle < 45)
    offsetX += offsetX/4;
  if(angle>0)
		spacing = slideWidth * 0.35;
  else
		spacing = slideWidth*spacingRatio + slideWidth*(spacingRatio?0.10:0.2);
}