Autor Beitrag
Slowmo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 29

Suse Linux 10.1
Lazarus v.0.9.18
BeitragVerfasst: So 20.11.05 20:38 
Ich habe eine OpenGl-Szene die ich per Rechte Maustastegedrückt & Mausbewegung Rotieren lassen möchte. Soweit so gut, die Szene dreht sich auch schön, aber jedes Mal wenn ich von der rechten Maustaste runtergehe und dann die Drehung neu Anfange springt die Szene.

Hier mein Quelltext zur Drehung:
View ist ein Array of Real wobei
[0] die Drehung entlang der y-Achse darstellt und
[1] die Drehung entlang der x-Achse
ausblenden 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:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if (ssRight in Shift) then
  begin
    if (Oldx=0) and (Oldy=0) then
      begin
        Oldx:=x;
        Oldy:=y;
      end
      else
      begin
       View[0]:=Oldx-x*1.5;
        View[1]:=Oldy-y*1.5;
         if View[0]>360 then View[0]:=View[0]-360;
         if View[1]>360 then View[1]:=View[1]-360;
       Oldx:=x/2;
       Oldy:=y/2;
      end;
  end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Oldx:=0;
Oldy:=0;
end;
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 27.11.05 01:07 
Ohne den Code genauer anzuschauen oder auszuprobieren, kann ich dir nicht helfen. Könntest du das nochmals neu formulieren?

Hast du kein FormMouseDown definiert? Im FormMouseUp wäre das ssRight in Shift vielleicht noch gut. Von Konstruktionen wie if (Oldx=0) and (Oldy=0) then würde ich im Übrigen abraten. Das ist kein besonders guter Programmierstil.
Slowmo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 29

Suse Linux 10.1
Lazarus v.0.9.18
BeitragVerfasst: So 27.11.05 15:43 
Das problem hat sich inzwischen erledigt, ich habs etwas einfacher Gemacht:
ausblenden 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:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if (ssRight in Shift) then
  begin
    if (Oldx=0) and (Oldy=0) then
      begin
        Oldx:=x;
        Oldy:=y;
      end;
         if x>Oldx then View[0]:=View[0]+(Oldx-x);
         if x<Oldx then View[0]:=View[0]+(Oldx-x);
         if y>Oldy then View[1]:=View[1]+(Oldy-y);
         if y<Oldy then View[1]:=View[1]+(Oldy-y);
         if View[0]>360 then View[0]:=View[0]-360;
         if View[1]>360 then View[1]:=View[1]-360;
       Oldx:=x;
       Oldy:=y;
  end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Oldx:=0;
Oldy:=0;
end;


PS: MouseDown is ja nicht nötig da ich die Abfrage ob eine Taste gedrückt is ja schon mit if (ssRight in Shift) then drin habe.