Trouble with Delphi

Blitz3D SDK Forums/Blitz3D SDK Programming/Trouble with Delphi

Hello, I have bought the SDK. Wrapper is OK. Thanks.

Please, can someone put a code to call a event handler for input ouse and keyboard when the Blitz3D window is build inside a panel? My app totally ignoring any input at all.

Thanks in advance

Another question: how can I setup my Error Handling, to avoid Close app when got an error?

Another one: when I set Debug OFF, I can´t run on a custom window. Any Tip?

Sorry for many questions.

I don't think you can prevent the application from closing in case of errors.
For instance LoadMesh: when the mesh can't be loaded, it returns a zero. However, when you load a truely corrupted mesh, it returns with an illegal memory something. I'm not a real Delphi expert, but I think you can't deal with such an error since it is given by the .dll itself.
With Debug off, it doesn't run in a custom window: to me, that sounds like the difference beween Graphics3D 800, 600 and Graphics 800, 600, 0, 2 ?
In my test applications, a while back, I used FormKeyDown to get the keyboard input initially. I can't really remember if I got KeyDown/Hit working. They do work in BMax, so they should be able to work.

Thanks Warner

I´m making some progress, but do you know if this a BUGGY command?

bbTurnEntity (Entity,X,Y,Z,1);

The last parameter (1 for Global) is not working at all. I have tested with 0, -1 etc and it dos not make any effect!

Thanks.

I'm not sure if this 'global' parameter works or not. I vaguely remember trying it once in the common version of blitz3d, and I remember that I was able to turn meshes independent of their orientation, but I can't seem to recall if I wrote something myself to do that. You can allways assign a pivot as a parent to the object, and rotate it.
Anyway, I installed the sdk for Delphi again, and adapted the original example to use SetHWND and the callback:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Blitz3D;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
     camera, cube : integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//event handler
procedure dBBEventHandler(hWnd, Msg, wParam, lParam : integer);
begin
  Form1.Caption := 'Event = ' + inttostr(Msg) + ' ' + inttostr(wParam) + ' ' + inttostr(lParam);
end;

//setup b3d
procedure TForm1.FormCreate(Sender: TObject);
begin
  bbSetBlitz3DDebugMode(0);
  bbSetBlitz3DHWND(form1.Handle);
  bbSetBlitz3DEventCallback(@dBBEventHandler);
  bbBeginBlitz3D;
  bbGraphics3D(320,240,0,3);
  bbCreateLight;
  camera:=bbCreateCamera;
  cube:=bbCreateCube;
  bbPositionEntity(camera,0,0,-4);

  Timer1.enabled := true;
end;

//update b3d on timer
procedure TForm1.Timer1Timer(Sender: TObject);
begin
    bbTurnEntity(cube,1,2,3);
    bbRenderWorld;
    bbFlip;
end;

//destroy b3d when form is closed
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if (Action = caFree) then
  begin
    Timer1.enabled := false;

    bbEndGraphics;
    bbEndBlitz3D;
  end;
end;

//form1 respond to keydown
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key = VK_SPACE then caption := 'hello';
end;

end.

edit: please note that i named my include file 'blitz3d.pas', where it should have been blitz3dsdk.pas
I created a form with a timer. You should assign FormCreate/FormClose/FormKeyDown to the form Events in the object inspector, and assign Timer1Timer to the timers OnTimer.

Warner, THANK YOU VERY MUCH for the callback example. :)

About the rotation, I went on 3D Studio and reset each pivot for each tooth. Now it works. I think they was parented to the Mouth main Pivot. Thanks a lot. Now I´m moving on. :)