Ejemplo n.º 1
0
/* -------------------------------------------------------------------------- */
void proj_init(proj_info *in_pj)
{
  double xs, xw;

  is_init = 0;

  memcpy((void *) &pj, (void *) in_pj, sizeof(proj_info));

  cntri0 = (float) (pj.c_dim_i + 1) * 0.50;
  cntrj0 = (float) (pj.c_dim_j + 1) * 0.50;

  if (pj.exp_flag)
  {
    xs = pj.xsouth + pj.exp_off_i;
    xw = pj.xwest + pj.exp_off_j;
    cntri = (cntri0 - xs) * pj.ratio + 0.50;
    cntrj = (cntrj0 = xw) * pj.ratio + 0.50;
  }
  else
  {
    cntri = (cntri0 - pj.xsouth) * pj.ratio + 0.50;
    cntrj = (cntrj0 - pj.xwest) * pj.ratio + 0.50;
  }

  set_proj();

  is_init = 1;

  return;
}
Ejemplo n.º 2
0
Camera::Camera(int view_mat_location, int proj_mat_location) {
	this->view_mat_location = view_mat_location;
	this->proj_mat_location = proj_mat_location;
	cam_pos = vec3 (0.0f, 0.0f, 5.0f);
	near = 0.1f; // clipping plane
	far = 100.0f; // clipping plane
	fovy = 67.0f; // 67 degrees
	// aspect ratio
	aspect = (float)g_gl_width / (float)g_gl_height;
	proj_mat = perspective (fovy, aspect, near, far);
	cam_speed = 5.0f; // 1 unit per second
	cam_heading_speed = 100.0f; // 30 degrees per second
	cam_heading = 0.0f; // y-rotation in degrees
	T = translate (
		identity_mat4 (), vec3 (-cam_pos.v[0], -cam_pos.v[1], -cam_pos.v[2])
	);
	create_versor (quaternion, -cam_heading, 0.0f, 1.0f, 0.0f);
	// convert the quaternion to a rotation matrix (just an array of 16 floats)
	quat_to_mat4 (R.m, quaternion);
	// combine the inverse rotation and transformation to make a view matrix
	view_mat = R * T;

	fwd = FORWARD;
	rgt = RIGHT;
	up = UP;

	set_view();
	set_proj();

	reset_control();
}
Ejemplo n.º 3
0
void parse(char * text, programmer ** p)
{
	cJSON * jList = cJSON_Parse(text);
	if (!jList) {
		printf("Error before: [%s]\n", cJSON_GetErrorPtr());
		return 1;
	}

    int count = cJSON_GetArraySize(jList);
   for (int i = 0; i < count; i++) {
        cJSON * jItem = cJSON_GetArrayItem(jList, i);
        char * name = cJSON_GetObjectItem(jItem, "name")->valuestring;
        char * surname = cJSON_GetObjectItem(jItem, "surname")->valuestring;
        char * birthdate = cJSON_GetObjectItem(jItem, "birthdate")->valuestring;
        cJSON * jGroup = cJSON_GetObjectItem(jItem, "working");
        char * companyName = cJSON_GetObjectItem(jGroup, "company")->valuestring;
        char * position = cJSON_GetObjectItem(jGroup, "position")->valuestring;
        int  hired = cJSON_GetObjectItem(jItem, "hired")->valueint;
        double rating = cJSON_GetObjectItem(jItem, "rating")->valuedouble;
        char * language = cJSON_GetObjectItem(jItem, "language")->valuestring;
        set_progr(p[i],name,surname,birthdate,companyName,position,language,hired,rating);
        cJSON * jProjects = cJSON_GetObjectItem(jItem, "projects");
        int cnt = cJSON_GetArraySize(jProjects);
        for (int j = 0; j < cnt; j++){
           cJSON * pItem = cJSON_GetArrayItem(jProjects, j);
           char * pname = cJSON_GetObjectItem(pItem, "name")->valuestring;
           char * start = cJSON_GetObjectItem(pItem, "started")->valuestring;
           char * release = cJSON_GetObjectItem(pItem, "release")->valuestring;
           int hours = cJSON_GetObjectItem(pItem, "spendHours")->valueint;
           int percent = cJSON_GetObjectItem(pItem, "percent")->valueint;
           set_proj(p[i],pname,start,release,hours,percent,j);

        }
    }
    cJSON_Delete(jList);

}