Показать сообщение отдельно
Старый 13.12.2005, 10:38   #3
pax
Unity/C# кодер
 
Аватар для pax
 
Регистрация: 03.10.2005
Адрес: Россия, Рязань
Сообщений: 7,568
Написано 3,006 полезных сообщений
(для 5,323 пользователей)
Сообщение

вот вся прога со счетчиком фпс... показывает 3-4... на глаз казалось больше

program MY_3D;
const 
 numpoints=8;
 numlines=12;

var 
 points	:array[1..numpoints,1..5] of integer;
 lines :array[1..numlines,1..2] of integer;
 distance     	: integer;
 FPS_LastCount,FPS_Count,MS,MSL:integer;
 rx, ry, rz     : real;
  cx, cy      : integer;
  time: integer; 

Procedure RotatePoint(i:integer);
var 
  ox,tx,ty,tz, x, y, z: real;
  nx,ny    : integer;
  
begin
 x:=points[i,1];
 y:=points[i,2];
 z:=points[i,3];
 //X rotation
 ty := y * Cos(rx) - z * Sin(rx);
 tz := y * Sin(rx) + z * Cos(rx);
 //Y rotation
 tx := x * Cos(ry) - tz * Sin(ry);
 tz := x * Sin(ry) + tz * Cos(ry);
 //Z rotation
 ox := tx;
 tx := tx * Cos(rz) - ty * Sin(rz);
 ty := ox * Sin(rz) + ty * Cos(rz);
 //Calculate new x and y location with perspective
 nx := Trunc(512 * (tx) / (distance - (tz)))+cx;
 ny := Trunc((512 * ty) / (distance - (tz)))+cy;
 points[i,4] := nx;
 points[i,5] := ny;
end;  

Procedure Rotate3D;
var 
  i: integer;
begin
	for i:=1 to numpoints do
 begin
 	RotatePoint(i);
 end;
end; 

Procedure Draw3D;
var 
  i: integer;
begin
	for i:=1 to numlines do
 begin
 	DrawLine(points[lines[i,1],4], points[lines[i,1],5], points[lines[i,2],4], points[lines[i,2],5]); 
 end;
end; 

begin 
	distance:=100;
	cx:=GetWidth/2;
	cy:=GetHeight/2;
	
 points[1,1]:=5;
 points[1,2]:=-5;
 points[1,3]:=-5;
 
 points[2,1]:=5;
 points[2,2]:=-5;
 points[2,3]:=5;

 points[3,1]:=5;
 points[3,2]:=5;
 points[3,3]:=5;
 
 points[4,1]:=5;
 points[4,2]:=5;
 points[4,3]:=-5;
 
 points[5,1]:=-5;
 points[5,2]:=-5;
 points[5,3]:=-5;
 
 points[6,1]:=-5;
 points[6,2]:=-5;
 points[6,3]:=5;

 points[7,1]:=-5;
 points[7,2]:=5;
 points[7,3]:=5;
 
 points[8,1]:=-5;
 points[8,2]:=5;
 points[8,3]:=-5;
 
 lines[1,1]:=1;
 lines[1,2]:=2;
 
 lines[2,1]:=2;
 lines[2,2]:=3;
  
 lines[3,1]:=3;
 lines[3,2]:=4;
  
 lines[4,1]:=4;
 lines[4,2]:=1;
  
 lines[5,1]:=2;
 lines[5,2]:=6;
  
 lines[6,1]:=3;
 lines[6,2]:=7;
  
 lines[7,1]:=4;
 lines[7,2]:=8;
  
 lines[8,1]:=1;
 lines[8,2]:=5;
  
 lines[9,1]:=5;
 lines[9,2]:=6;
  
 lines[10,1]:=6;
 lines[10,2]:=7;
  
 lines[11,1]:=7;
 lines[11,2]:=8;
  
 lines[12,1]:=8;
 lines[12,2]:=5;

 while true do 
  begin 
 SetColor(255, 255, 255);
  FillRect(0, 0, GetWidth, GetHeight); 
 	rx:=rx+ToRadians(1);
 	ry:=2*rx;
 	rz:=3*rx;
 	Rotate3D;
 SetColor(255, 0, 0); 
 	Draw3D;
  
 time := GetCurrentTime; 
 MS:=GetSecond(time);
 If MS<>MSL Then
  begin
 	FPS_LastCount:=FPS_Count;
 	FPS_Count:=0;
 	MSL:=MS;
  end	
 Else
 	FPS_Count:=FPS_Count+1;
 	
 	DrawText('FPS:'+IntegerToString(FPS_LastCount), 0, 0);
 	Repaint;
 	
 	if GetKeyPressed = KE_KEY1 then distance:=distance-10;
 	if GetKeyPressed = KE_KEY3 then distance:=distance+10;
 	if GetKeyPressed = KE_KEY2 then cy:=cy-2;
 	if GetKeyPressed = KE_KEY4 then cx:=cx-2;
 	if GetKeyPressed = KE_KEY6 then cx:=cx+2;
 	if GetKeyPressed = KE_KEY8 then cy:=cy+2;
  end; 
end.
__________________
Blitz3d to Unity Wiki
(Offline)
 
Ответить с цитированием