Building Direct3D Application from Delphi
Firstly, you have to create a 3D object and export it to 3DS format file and then re-convert to X format file with tool conv3ds just like ussual (give a final file name with my_object.x). The texture design also have the same manner. You have to provide a picture with 256x256 pixel from image editor you likes and named it with my_pic.bmp.
The main differences came since i've use a component dedicatedly as an Direct3D retained mode (D3DRM) programming level. So, the code will absolutely more shorter because the primary initialization handled by the component. See this complete example below about how to show the 3D object on form:
Pretty simple, isn't it? Okay, make a compile and here it is a snapshot of the application i've been made (a simulation of physic lessons material).uses dxtools, d3drm, d3drmobj, D3DTypes, D3DRMDef, DDraw, D3D, D3DCaps;
protected
procedure WMActivate(var Msg: TMessage); message WM_ACTIVATE;
//-----------------------------------------------------------//
//
template D3D //
//-----------------------------------------------------------//
procedure TForm.simulasiGO();
var cpos: D3DVECTOR;
begin
with D3DRM do
begin
if Initialized and not Failed then
begin
CenterScene;
DXCheck(Camera.GetPosition(Scene, cpos));
DXCheck(Camera.SetPosition(Scene, cam_x, cam_y , cam_z));
DXCheck(SubScene.GetPosition(Scene, cpos));
end;
end;
end;
procedure TForm.WMActivate(var Msg: TMessage);
begin
inherited;
D3DRM.ActivateCallback(Msg);
end;
procedure
TForm.D3DRMBuildScene(
Sender: TObject);
begin
D3DGM.LoadFile(my_object.x');
end;
procedure
TForm.Timer1Timer(Sender: TObject);
begin
timer_counter:=timer_counter+10;
with D3DRM do
begin
if (timer_counter<=(t*1000)) then DXCheck(SubScene.SetRotation(Scene,0,0,1,akselerasi)) else DXCheck(SubScene.SetRotation(Scene,0,0,0,0));end;
end;
PS: If you've benefit from this blog, you can support it by making a small contribution. |
KEMDAU said,
Friday, April 22, 2011 7:34:00 AM
Oh, thank you very muck :)
I want know more about it!!!
let's send to email: tut4ever@ymail.com
thanks =='