예제 #1
0
파일: camera.cpp 프로젝트: nbingham1/Blaze
void camerahdl::view(framehdl &frame, float ratio, float front, float back)
{
	frame.projection = frustum(-ratio, ratio, -1.0f, 1.0f, front, back);

	frame.modelview = identity<float, 4, 4>();
	if (link != NULL)
		frame.modelview *= rotate_xyz(-link->orientation);
	frame.modelview *= rotate_xyz(-orientation);

	frame.modelview *= translate(-(vec3f)position);
}
예제 #2
0
파일: player.cpp 프로젝트: nbingham1/Blaze
void playerhdl::down(preference *pref, vec3f value)
{
	playerhdl *player = (playerhdl*)pref->data;
	if (player != NULL && player->camera != NULL)
	{
		if (player->camera->link != NULL)
			player->camera->link->impulse(-player->speed*rotate_zyx(rotate_xyz(vec3d(0.0, 1.0, 0.0), player->camera->orientation), player->camera->link->orientation), vec3d(0.0, 0.0, 0.0));
		else
			player->camera->impulse(-player->speed*rotate_xyz(vec3d(0.0, 1.0, 0.0), player->camera->orientation), vec3d(0.0, 0.0, 0.0));
	}
}
예제 #3
0
static void draw_gl(Evas_Object *obj)
{
	static int i=0;
	appdata_s *ad = evas_object_data_get(obj, "ad");
	float model[16], view[16];
	float aspect;

	if (!ad)
		return;

	init_matrix(model);
	init_matrix(view);

	aspect = (float) ad->glview_w / (float) ad->glview_h;

	view_set_perspective(view, 60.0f, aspect, 1.0f, 20.0f);

	translate_xyz(model, 0.0f, 0.0f, -2.5f);
	rotate_xyz(model, ad->xangle, ad->yangle, 0.0f);

	multiply_matrix(ad->mvp, view, model);

	glViewport(0, 0, ad->glview_w, ad->glview_h);

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glVertexAttribPointer(ad->idx_position, 3, GL_FLOAT, GL_FALSE,
			3 * sizeof(float), cube_vertices);
	glVertexAttribPointer(ad->idx_color, 4, GL_FLOAT, GL_FALSE,
			4 * sizeof(float), cube_colors);

	glEnableVertexAttribArray(ad->idx_position);
	glEnableVertexAttribArray(ad->idx_color);

	glUniformMatrix4fv(ad->idx_mvp, 1, GL_FALSE, ad->mvp);

	glDrawElements(GL_TRIANGLES, cube_indices_count, GL_UNSIGNED_SHORT,
			cube_indices);


	//3rd
	glVertexAttribPointer(ad->idx_position, 3, GL_FLOAT, GL_FALSE,
			3 * sizeof(float), cubeBFL_vertices);
	glVertexAttribPointer(ad->idx_color, 4, GL_FLOAT, GL_FALSE,
			4 * sizeof(float), cube_colors);

	glEnableVertexAttribArray(ad->idx_position);
	glEnableVertexAttribArray(ad->idx_color);

	glUniformMatrix4fv(ad->idx_mvp, 1, GL_FALSE, ad->mvp);


	//glRotatef(45,0,1,1);

	i = (i+10)%360;


	glDrawElements(GL_TRIANGLES, cubeBFL_indices_count, GL_UNSIGNED_SHORT,
			cubeBFL_indices);




	glFlush();
	display_fps();
}