Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Loading Problem  (Read 399 times)
Odem1002
Community Member
*
Posts: 1


« on: November 21, 2010, 11:25:50 AM »

Hello

First my English is not soo good, because I'm coming form Austria.
I need help:
I want to load a DirectX.x File in Delphi and i thought that the code is right but the object is not shown:
{ ________________________________________________________________________
' TRUEVISION8                        (web: http://www.truevision3d.com)
' ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
' Tutorial B10 : FPS Smooth Movement
' ŻŻŻŻŻŻŻŻŻŻ
' Description : This tutorial shows the way to do Smooth FPS Movement that you
' ŻŻŻŻŻŻŻŻŻŻŻ   so often see in FPS games.
'
' }

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleServer, TrueVision3D, Direct3D8;

type
  TForm1  = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure EngineCreate;
    Procedure EngineInit;
    Procedure Input;
  private
    { Private declarations }
    procedure AppIdle(Sender: TObject; var Done: Boolean);
  public
    { Public declarations }
    TV: TTVEngine;
    Inp: TTVInputEngine;
    Global: TTVDelphiGlobals;
    Scene: TTVScene;

    Land: TTVLandscape;
    TexFactory: TTVTextureFactory;
    Camera: TTVCamera;

    PlayerPosition : D3DVECTOR;
    PlayerAngleY, PlayerAngleYSpeed, PlayerAngleYAim : Single;
    PlayerAngleX, PlayerAngleXSpeed, PlayerAngleXAim : Single;

    PlayerSpeed : Single;
    PlayerSpeedStrafe : Single;

    Bus : TTVMesh;
  end;
var
  Form1 : TForm1 ;
implementation
{$R *.DFM}

Procedure TForm1.EngineCreate;
begin
    TV := TTVEngine.Create(self);
    Inp := TTVInputEngine.Create(self);
    Global := TTVDelphiGlobals.Create(self);
    Scene := TTVScene.Create(self);
    Bus := TTVMesh.Create(self);
    Land := TTVLandscape.Create(self);
    TexFactory := TTVTextureFactory.Create(self);
    Camera := TTVCamera.Create(self);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
//Call the procedures here
//This must be called to create the objects before using them in the next proc.
EngineCreate;
//This one sets up the engine with the init code.
EngineInit;

//This tells the program to go to our Loop wich is located at AppIdle.
//Thats where the rendering code goes.
Application.OnIdle := AppIdle;
end;

procedure TForm1.AppIdle(Sender: TObject; var Done: Boolean);
begin
done := false;
//Loop Code goes here
//Check the input procedure.
Input;

//Clear the screen.
TV.Clear(false);



   Bus.Render;
//And finally call rendertoscreen to make it all show up.
TV.RenderToScreen;
end;

procedure TForm1.EngineInit;
begin
//Init code
form1.Show;
//THis will init the to the handle specified, in this case our forms handle.
//You can wirite "Form1.Handle" instead if you want, or even specify a handle of
//Something else like a picturebox.
//TV.Init3DFullscreen(1280, 1024, 32, FALSE, TRUE, TV_DEPTHBUFFER_32BITS,0,handle);
TV.Init3DWindowedMode(handle,true);
TV.SetSearchDirectory(ExtractFilePath(Application.ExeName));

//We set the DisplayFPS to true, so we can se our FPS count.
//FPS Stands for Frames Per Second.
TV.DisplayFPS:= true;

Scene.SetSceneBackGround(0.2, 0.6, 0.Cool;


   Bus.LoadXFile('untitled.x',true,true);

   PlayerPosition := Global.Vector3(0, 0, 0);


end;

procedure TForm1.Input;
var mx,my : integer;
var intnull: integer;
var sinnull: single;
var sminull: smallint;
begin
//Input code goes here
//If the ESCAPE key is pressed we end the program, thus making it end the render.
if inp.IsKeyPressed(TV_KEY_ESCAPE) then close;

inp.GetMouseState(mx,my,sminull,sminull,sminull,intnull);

     // Change the aim angle
     PlayerAngleYAim := PlayerAngleYAim + 0.005 * -mx;
     PlayerAngleXAim := PlayerAngleXAim + 0.005 * -my;

     If PlayerAngleXAim > 1.52 Then PlayerAngleXAim := 1.52;
     If PlayerAngleXAim < -1.52 Then PlayerAngleXAim := -1.52;
     
     PlayerAngleXSpeed := (PlayerAngleXAim - PlayerAngleX) * 0.03;
     PlayerAngleYSpeed := (PlayerAngleYAim - PlayerAngleY) * 0.03;
     
     PlayerAngleX := PlayerAngleX + PlayerAngleXSpeed;
     PlayerAngleY := PlayerAngleY + PlayerAngleYSpeed;

     //Normal move :
     If Inp.IsKeyPressed(TV_KEY_UP) = True Then
         PlayerSpeed := PlayerSpeed + 0.003 * TV.TimeElapsed;

     If Inp.IsKeyPressed(TV_KEY_DOWN) = True Then
         PlayerSpeed := PlayerSpeed - 0.003 * TV.TimeElapsed;

     If PlayerSpeed > 2 Then PlayerSpeed := 2;
     If PlayerSpeed < -2 Then PlayerSpeed := -2;
     PlayerSpeed := PlayerSpeed * 0.97;

     PlayerPosition.x := PlayerPosition.x + Cos(PlayerAngleY) * PlayerSpeed;
     PlayerPosition.z := PlayerPosition.z + Sin(PlayerAngleY) * PlayerSpeed;
     PlayerPosition.y := land.GetHeight(PlayerPosition.x, PlayerPosition.z) + 15;

     Camera.SetCamera(PlayerPosition.x, PlayerPosition.y, PlayerPosition.z, PlayerPosition.x + Cos(PlayerAngleY), PlayerPosition.y + Sin(PlayerAngleX), PlayerPosition.z + Sin(PlayerAngleY));
     Camera.RotateZ(Cos(TV.TickCount * 0.01) * PlayerSpeed * 0.08); //The smoothment value
end;
end.


Thx
Lukas
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks