Subversion Repositories Kolibri OS

Rev

Rev 8849 | Rev 8909 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8849 Rev 8875
Line 3... Line 3...
3
#include 
3
#include 
4
#include 
4
#include 
5
#include 
5
#include 
6
#include 
6
#include 
7
#include 
7
#include 
-
 
8
#include 
Line 8... Line 9...
8
 
9
 
Line 9... Line 10...
9
using namespace Kolibri;
10
using namespace Kolibri;
10
 
11
 
Line 36... Line 37...
36
struct ColorList{
37
struct ColorList{
37
	unsigned char* name;
38
	unsigned char* name;
38
	long int color;
39
	long int color;
39
};
40
};
Line 40... Line 41...
40
 
41
 
41
const long C_COUNT_MAX = 32;
42
const long C_COUNT_MAX = 27;
42
ColorList c_list[C_COUNT_MAX];
43
ColorList c_list[C_COUNT_MAX];
Line 43... Line 44...
43
long c_count = 0;
44
long c_count = 0;
44
 
45
 
Line 68... Line 69...
68
float mat_specular[] = {0.3, 0.3, 0.3, 1.0}; //Цвет блика
69
float mat_specular[] = {0.3, 0.3, 0.3, 1.0}; //Цвет блика
69
float mat_shininess = 3.0; //Размер блика (обратная пропорция)
70
float mat_shininess = 3.0; //Размер блика (обратная пропорция)
70
float white_light[] = {1.0, 1.0, 1.0, 1.0}; //Цвет и интенсивность освещения, генерируемого источником
71
float white_light[] = {1.0, 1.0, 1.0, 1.0}; //Цвет и интенсивность освещения, генерируемого источником
71
float lmodel_ambient[] = {0.3, 0.3, 0.3, 1.0}; //Параметры фонового освещения
72
float lmodel_ambient[] = {0.3, 0.3, 0.3, 1.0}; //Параметры фонового освещения
Line -... Line 73...
-
 
73
 
-
 
74
const long TOOLBAR_H = 29;
-
 
75
char str1[] = "Show active level";
-
 
76
check_box check1 = { {16,280,20,4}, 8, 0xffffff, 0x808080, 0xffffff, str1, ch_flag_middle };
-
 
77
scrollbar sb_tcr = { 200,70,19,4, 16, 1, 20,1,0, 0x808080, 0xffffff, 0x0};
72
 
78
 
73
void SetLight()
79
void SetLight()
74
{
80
{
75
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
81
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
Line 147... Line 153...
147
				glPushMatrix();
153
				glPushMatrix();
148
				glTranslatef(model_list[i].x, model_list[i].y, model_list[i].z);
154
				glTranslatef(model_list[i].x, model_list[i].y, model_list[i].z);
149
				glRotatef(model_list[i].r_x, 1.0,0.0,0.0);
155
				glRotatef(model_list[i].r_x, 1.0,0.0,0.0);
150
				glRotatef(model_list[i].r_y, 0.0,1.0,0.0);
156
				glRotatef(model_list[i].r_y, 0.0,1.0,0.0);
151
				glRotatef(model_list[i].r_z, 0.0,0.0,1.0);
157
				glRotatef(model_list[i].r_z, 0.0,0.0,1.0);
-
 
158
				if((check1.flags&ch_flag_en && model_list[i].t_cr==sb_tcr.position)||
-
 
159
				(!(check1.flags&ch_flag_en) && model_list[i].t_cr<=sb_tcr.position)){
152
				glColor3ub((model_list[i].color>>16)&255,
160
				glColor3ub((model_list[i].color>>16)&255,
153
					(model_list[i].color>> 8)&255,
161
					(model_list[i].color>> 8)&255,
154
					model_list[i].color&255);
162
					model_list[i].color&255);
155
				glCallList(model_list[i].id_l);
163
				glCallList(model_list[i].id_l);
156
			}
164
				}
-
 
165
			}
157
			while(pu_cou){
166
			while(pu_cou){
158
				pu_cou--;
167
				pu_cou--;
159
				glPopMatrix();
168
				glPopMatrix();
160
			};
169
			};
161
		}
170
		}
Line 240... Line 249...
240
	return (bool)b_data;
249
	return (bool)b_data;
241
}
250
}
Line 242... Line 251...
242
 
251
 
243
bool init_model()
252
bool init_model()
244
{
253
{
245
	long i, n;
254
	long i, n, max_time=0;
246
	char *ft = strstr(f_data, "const");
255
	char *ft = strstr(f_data, "const");
247
	char *fe; //end ']'
256
	char *fe; //end ']'
Line 248... Line 257...
248
	char *fp; //perv ','
257
	char *fp; //perv ','
Line 299... Line 308...
299
 
308
 
300
		fp=ft;
309
		fp=ft;
301
		ft=strchr(ft, ',')+1;
310
		ft=strchr(ft, ',')+1;
302
		ft[-1]=0;
311
		ft[-1]=0;
-
 
312
		model_list[i].t_cr=StrToInt(fp);
Line 303... Line 313...
303
		model_list[i].t_cr=StrToInt(fp);
313
		if(model_list[i].t_cr>max_time) max_time=model_list[i].t_cr;
304
 
314
 
305
		fp=ft;
315
		fp=ft;
306
		ft=strchr(ft, ',')+1;
316
		ft=strchr(ft, ',')+1;
Line 347... Line 357...
347
	}
357
	}
348
	trans_z = (mz_max-mz_min)/2.0;
358
	trans_z = (mz_max-mz_min)/2.0;
349
	scale_o = .5/trans_z;
359
	scale_o = .5/trans_z;
350
	angle_x = 135.0;
360
	angle_x = 135.0;
351
	angle_z = -45.0;
361
	angle_z = -45.0;
-
 
362
	sb_tcr.max_area = max_time+1;
-
 
363
	sb_tcr.position = max_time;
Line 352... Line 364...
352
 
364
 
353
	return true;
365
	return true;
Line 354... Line 366...
354
}
366
}
Line 402... Line 414...
402
{
414
{
403
	kos_start.Left = 10;
415
	kos_start.Left = 10;
404
	kos_start.Top = 40;
416
	kos_start.Top = 40;
405
	kos_start.Width = 640;
417
	kos_start.Width = 640;
406
	kos_start.Height = 480;
418
	kos_start.Height = 480;
407
	kos_start.WinData.WindowColor = 0xFFFFFF;
419
	kos_start.WinData.WindowColor = 0x333333;
408
	kos_start.WinData.WindowType = 0x33; // 0x34 - fixed, 0x33 - not fixed
420
	kos_start.WinData.WindowType = 0x33; // 0x34 - fixed, 0x33 - not fixed
409
	kos_start.WinData.Title = header;
421
	kos_start.WinData.Title = header;
Line 410... Line 422...
410
 
422
 
411
	if(LoadLibrary("proc_lib.obj", library_path, "/sys/lib/proc_lib.obj", &import_proc_lib))
423
	if(LoadLibrary("proc_lib.obj", library_path, "/sys/lib/proc_lib.obj", &import_proc_lib))
Line 425... Line 437...
425
		ofd.x_start = 10;
437
		ofd.x_start = 10;
426
		ofd.y_size = 320;
438
		ofd.y_size = 320;
427
		ofd.y_start = 10;
439
		ofd.y_start = 10;
428
		OpenDialog_Init(&ofd);
440
		OpenDialog_Init(&ofd);
429
	} else return false;
441
	} else return false;
-
 
442
	if(LoadLibrary("box_lib.obj", library_path, "/sys/lib/box_lib.obj", &import_box_lib))
-
 
443
	{
-
 
444
		check_box_init(&check1);
-
 
445
		sb_tcr.ar_offset=1;
-
 
446
	} else return false;
430
	if(LoadLibrary("tinygl.obj", library_path, "/sys/lib/tinygl.obj", &import_tinygl))
447
	if(LoadLibrary("tinygl.obj", library_path, "/sys/lib/tinygl.obj", &import_tinygl))
431
	{
448
	{
-
 
449
		long h = kos_start.Height-TOOLBAR_H;
432
		kosglMakeCurrent(0,0,kos_start.Width,kos_start.Height,&ctx1);
450
		kosglMakeCurrent(0,TOOLBAR_H,kos_start.Width,h,&ctx1);
433
		rat_h = kos_start.Height;
451
		rat_h = h;
434
		rat_h /= kos_start.Width;
452
		rat_h /= kos_start.Width;
435
		angle_dwm = kos_start.Width/180.0;
453
		angle_dwm = kos_start.Width/180.0;
436
		angle_dhm = kos_start.Height/180.0;
454
		angle_dhm = h/180.0;
437
		glEnable(GL_DEPTH_TEST);
455
		glEnable(GL_DEPTH_TEST);
438
		glClearColor(0.2,0.2,0.2,0.0);
456
		glClearColor(0.2,0.2,0.2,0.0);
439
		glEnable(GL_NORMALIZE);
457
		glEnable(GL_NORMALIZE);
440
		//draw_3d();
-
 
441
		if(init_block()){
458
		if(init_block()){
442
			if(CommandLine[0]) OpenModel(CommandLine);
459
			if(CommandLine[0]) OpenModel(CommandLine);
443
			return true;
460
			return true;
444
		}
461
		}
445
	}
462
	}
Line 449... Line 466...
449
void KolibriOnPaint(void)
466
void KolibriOnPaint(void)
450
{
467
{
451
	kosglSwapBuffers();
468
	kosglSwapBuffers();
Line 452... Line 469...
452
 
469
 
453
	// If button have ID 1, this is close button
470
	// If button have ID 1, this is close button
454
	DrawButton(2,0xf0f0f0, 10,10,50,20);
471
	DrawButton(2,0xf0f0f0, 10,4,50,19);
-
 
472
	DrawText(20,10,0,"Open");
-
 
473
	DrawText(10,TOOLBAR_H+3,(1<<24)|0xffffff,DoubleToStr(sb_tcr.position,0,true));
-
 
474
	sb_tcr.all_redraw=1;
-
 
475
	scrollbar_h_draw(&sb_tcr);
455
	DrawText(20,16,0,"Open");
476
	check_box_draw(&check1);
Line 456... Line 477...
456
}
477
}
457
 
478
 
458
void KolibriOnButton(long id, TThreadData /*th*/)
479
void KolibriOnButton(long id, TThreadData /*th*/)
Line 493... Line 514...
493
	};
514
	};
494
}
515
}
Line 495... Line 516...
495
 
516
 
496
void KolibriOnMouse(TThreadData /*th*/)
517
void KolibriOnMouse(TThreadData /*th*/)
497
{
-
 
498
	int m = GetMouseButton();
518
{
Line -... Line 519...
-
 
519
	short m_x_old, m_y_old;
-
 
520
 
-
 
521
	long f, m = sb_tcr.position;
-
 
522
	f = check1.flags;
-
 
523
	scrollbar_h_mouse(&sb_tcr);
-
 
524
	check_box_mouse(&check1);
-
 
525
	if(sb_tcr.position!=m || check1.flags!=f){		
-
 
526
		draw_3d();
-
 
527
		Invalidate();
-
 
528
		return;
-
 
529
	}
499
	short m_x_old, m_y_old;
530
 
500
 
531
	m = GetMouseButton();
501
	if(m&1 && mouse_drag){
532
	if(m&1 && mouse_drag){
502
		//mouse l. but. move
533
		//mouse l. but. move
503
		m_x_old = mouse_x;
534
		m_x_old = mouse_x;
Line 518... Line 549...
518
		mouse_drag=false;
549
		mouse_drag=false;
519
	}
550
	}
520
	if(m&0x100){
551
	if(m&0x100){
521
		//mouse l. but. press
552
		//mouse l. but. press
522
		GetMousePosPicture(mouse_x, mouse_y);
553
		GetMousePosPicture(mouse_x, mouse_y);
523
		if(mouse_x>0 && mouse_y>0) mouse_drag=true;
554
		if(mouse_x>0 && mouse_y>TOOLBAR_H) mouse_drag=true;
524
	}
555
	}
Line 525... Line 556...
525
 
556
 
526
	GetMouseScrollData(m_x_old, m_y_old);
557
	GetMouseScrollData(m_x_old, m_y_old);
527
	if(m_y_old<0 && scale_o<0.5){
558
	if(m_y_old<0 && scale_o<0.5){
Line 539... Line 570...
539
void KolibriOnSize(int window_rect[], TThreadData /*th*/)
570
void KolibriOnSize(int window_rect[], TThreadData /*th*/)
540
{
571
{
541
	unsigned short int width, height;
572
	unsigned short int width, height;
542
	GetClientSize(width, height);
573
	GetClientSize(width, height);
543
	if(!width || !height) return;
574
	if(!width || !height) return;
-
 
575
	height-=TOOLBAR_H;
544
	if(width<100) width=100;
576
	if(width<100) width=100;
545
	if(height<80) height=80;
577
	if(height<80) height=80;
546
	rat_h = (float)height / (float)width;
578
	rat_h = (float)height / (float)width;
547
	angle_dwm = (float)width/180.0;
579
	angle_dwm = (float)width/180.0;
548
	angle_dhm = (float)height/180.0;
580
	angle_dhm = (float)height/180.0;