Autor Beitrag
kuhlthomas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Di 19.08.03 22:17 
wenn ich mich durch einen glTranslate zu weit von meiner scene entferne so verschwindet sie teilweise oder komplett im nichts. weiss jemand woran das liegen könnte?
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 19.08.03 22:21 
Hi,

das liegt an deiner Near/FarClippingPlane.
ich nehme mal an du benutzt gluPerspective um deine Camera einzustellen, oder??

Der letzte Parameter gibt bei dem Befehl deine FarClippingPlane an, wenn dort z.B. 10 steht, wird alles was weiter als 10 Einheiten von dir weg is weggeclipped (=verschwindet).

Erhöh den wert dort mal (Aber: Desto höher das ist, desto mehr performance wird verbraucht.. also wenn du nur ne Sichtweite von 100 brauchst ist es nich wirklich schlau dort 1000 hinzuschreiben *g*)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
kuhlthomas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Di 19.08.03 22:27 
danke für die schnelle antwort, aber von gluPerspective habe ich noch nei was gehört (benutze opengl seit 1 woche)
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 19.08.03 22:31 
Hi,

was benutzt du denn dann um deine Camera einzustellen??? Evtl glOrtho??? Oder machst du das ganze komplett von hand? :)

Ansonsten poste mal deinen Code von deiner Initialisierung.

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
kuhlthomas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Di 19.08.03 22:36 
bis jetzt habe ich nur einige kleine objekte erstellt und mit gltranslate, glrotate & glscale die sicht verändert

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OpenGL12, AppEvnts;

type
  TForm1 = class(TForm)
    ApplicationEvents1: TApplicationEvents;
    procedure FormCreate(Sender: TObject);
    procedure InitGL;
    procedure DrawScene;
    procedure ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
    procedure FormResize(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    procedure SetBArray;
    { Private declarations }
  public
    { Public declarations }
  end;

procedure SetDCPixelFormat(Handle: HDC);
var
  Form1: TForm1;
  h_DC: hDC;
  hRC: HGLRC;
  RotX, RotY,rot :real;
  MouseOld, MouseNew :TPoint;
  move, nLO :Boolean;
  BArray :Array of Array of Integer;
  Level :integer;

implementation



{$R *.dfm}

procedure TForm1.SetBArray;
var i, r, A :integer;
    c,c2 :real;
    EoR :TPoint;
begin
i:=1;
r:=0;
A:=0;
c2:=0;

Level:=0;
while Level>=-16 do
 begin
  c:=0;
  while i<=36 do
   begin
    BArray[A,0]:=Round(sin(c)*r);
    BArray[A,1]:=Level;
    Barray[A,2]:=Round(cos(c)*r);
    i:=i+1;
    A:=A+1;
    c:=c+0.17453292519943295769236907684886;
   end;
  i:=1;
  Level:=Level+1;
  EoR.X:=Round(sin(c2)*18);
  EoR.y:=Round(cos(c2)*18);
  c2:=c2+0.087266463;
  r:=Round(sqrt(sqr(Level-EoR.y)+sqr(0-EoR.x)));
 end;
end;


procedure TForm1.FormCreate(Sender: TObject);
var x:integer;
begin
Level:=18;
x:=0;
SetLength(BArray,1286);
while x<=1285 do
 begin
  SetLength(BArray[x],3);
  x:=x+1;
 end;
SetBArray;
  InitOpenGL;
  h_DC:=GetDC(Handle);
  SetDCPixelFormat(h_DC);
  hRC:=wglCreateContext(h_DC);
  wglMakeCurrent(h_DC,hRC);
end;

procedure SetDCPixelFormat(Handle: HDC);
  var
    nPixelFormat: GLUint;
  const
    pfd: PIXELFORMATDESCRIPTOR = (
        nSize: sizeof( PIXELFORMATDESCRIPTOR );
        nVersion: 1;
        dwFlags: PFD_DRAW_TO_WINDOW
        or PFD_SUPPORT_OPENGL
        or PFD_DOUBLEBUFFER;
        iPixelType: PFD_TYPE_RGBA;
        cColorBits: 16;
        cRedBits: 0;
        cRedShift: 0;
        cGreenBits: 0;
        cBlueBits: 0;
        cBlueShift: 0;
        cAlphaBits: 0;
        cAlphaShift: 0;
        cAccumBits: 0;
        cAccumRedBits: 0;
        cAccumGreenBits: 0;
        cAccumBlueBits: 0;
        cAccumAlphaBits: 0;
        cDepthBits: 16;
        cStencilBits: 0;
        cAuxBuffers: 0;
        iLayerType: PFD_MAIN_PLANE;
        bReserved: 0;
        dwLayerMask: 0;
        dwVisibleMask: 0;
        dwDamageMask: 0
    );
  begin
    nPixelFormat:=ChoosePixelFormat(h_DC, @pfd);
    SetPixelFormat(h_DC,nPixelFormat,@pfd);
  end;

procedure TForm1.InitGL;
begin
  glClearColor(0,0,0,0);
  glClearDepth(1);
  glDepthFunc(GL_LESS);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_DEPTH_TEST);

  glViewport(0,0,Width,Height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;
  <span style="color: red">gluPerspective(45,Width/Height,1,100);</span>
  glMatrixMode(GL_MODELVIEW);
end;

procedure TForm1.DrawScene;
var i :integer;
begin
  i:=0;
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glLoadIdentity;
  //Hier wird später die Scene gezeichnet.
  glTranslate(0,0,-100);
  glRotate(rot,0,1,0);
  rot:=rot+0.2;
  glColor3f(0,1,0);
  while i<=1285 do
   begin
    glBegin(GL_Points);
     glVertex3f(BArray[i,0],BArray[i,1],BArray[i,2]);
    glEnd;
    i:=i+1;
   end;
  SwapBuffers(h_DC);
end;

procedure TForm1.ApplicationEvents1Idle(Sender: TObject;
  var Done: Boolean);
begin
DrawScene; 
Done:=False;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
glViewport(00, form1.clientWidth, form1.clientHeight);    // Setzt den Viewport für das OpenGL Fenster 
glMatrixMode(GL_PROJECTION);        // Matrix Mode auf Projection setzen
glLoadIdentity();                   // Reset View 
<span style="color: red">gluPerspective(45.0, form1.clientWidth/form1.clientHeight, 1100.0);</span>  // Perspektive den neuen Maßen anpassen. 
glMatrixMode(GL_MODELVIEW);         // Zurück zur Modelview Matrix 
glLoadIdentity();
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if move=True then
begin
 GetCursorPos(MouseNew);
 If MouseNew.y>MouseOld.y then RotX:=Rotx+1;
 If MouseNew.y<MouseOld.y then RotX:=Rotx-1;
 If MouseNew.x>MouseOld.X then Roty:=Roty+1;
 If MouseNew.x<MouseOld.X then Roty:=Roty-1;
 MouseOld:=MouseNew;
end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if move=false then move:=true
 else move:=false;
end;

end.


das ist eigendlich das erste worin ich etwas mehr zeit reingesteckt habe (aber komischerweise funktioniert es nicht mehr seit ich eine formel leicht abgeändert habe)

Moderiert von user profile iconAya: Code durch Delphi-Tags ersetzt. (und einen Teil des Codes Rot hervorgehoben)
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 19.08.03 22:42 
Hi,
kuhlthomas hat folgendes geschrieben:
danke für die schnelle antwort, aber von gluPerspective habe ich noch nei was gehört (benutze opengl seit 1 woche)

Dann solltest du dir deinen Code nochmal genauer anschauen... :P

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 19.08.03 22:48 
du hast gluPerspective sehr wohl in deinem Code drinstehen, sogar ganze 2 mal... wenn du dort den letzten Parameter wie von mir erklärt änderst sollte alles gehen.

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!