38
GLScene Руководство новичка by Jat-Studio 2009 GLScene руководство новичка, Jat-Studio, 2009

Gl Scener Us

Embed Size (px)

DESCRIPTION

Gl scene

Citation preview

  • GLScene

    by Jat-Studio

    2009

    GLScene , Jat-Studio, 2009

  • . 1. 2. GLScene ? 3. GLScene 4. ? 5. ! 6. 3D

    6.1. 6.2. 6.3. 6.4. () 6.5. OpenGL

    7. 7.1. GLScene 7.2. GLScene PFX 7.3. GLScene Utils 7.4. GLScene Shaders

    8. 8.1. 8.2. 8.3. 8.4. (Mesh) 8.5. , 8.6. 8.7. 8.8. HUD 8.9. GUI 8.10. 8.11. (Doodad object) 8.12.

    9. (Runtime) 9.1.

    10. : 3D 10.1. 10.2. 10.3. T3DTBlock 10.4.

    11. 12.

    GLScene , Jat-Studio, 2009

  • . ,

    GLScene. GLScene, . , . , . GLScene . GLScene , , , - .

    , GLScene, . GLScene, , .

    , . [ ].

    Jat-Studio, , 2009. [email protected]

    GLScene , Jat-Studio, 2009

  • GLScene . , GLScene,

    . , GLScene Delphi OpenGL. OpenGL API, Silicone Graphics. OpenGL , . GLScene OpenGL- . GLScene-, Delphi , , Windows. GLScene Kylix, () Linux. , . Mac.

    GLScene (Mike Lischk) (OpenSource) (Programmers Community). (Eric Grange) . GLScene. GLScene http://www.sourceforge.net. , GLScene, .

    GLScene , Jat-Studio, 2009

  • GLScene . GLScene.

    , GLScene.

    . : http://glscene.sourceforge.net/download.htm

    GLScene C:\library\GLScene : Delphi. Tools Environment Options Library.

    Library path

    GLScene.

    GLScene , Jat-Studio, 2009

  • . . GLScene.

    GLScene *.dll*. Windows\system32.

    GLScene.inc Source Delphi6.dpk

    GLScene , Jat-Studio, 2009

  • Delphi. Delphi .

    . . File - Close All. GLScene Delphi6. Delphi

    . File Open GLScene6.dpk.

    (compile) (install) .

    ( ). , :

    GLScene , Jat-Studio, 2009

  • ? . , , Delphi VCL

    (Design time). Delphi- . , , . GLScene . . GLScene.

    Delphi GLScene TGL

    , , GLScene, Delphi, . , . . . parent child ( ). . TGLScene, , . GLScene . . . TGLScene, , . TGLScene.Objects.

    GLScene : (Components) (Scene objects). . (object inspector). , . , (Scene editor). (rendering) . , . , , .

    GLScene. TGLScene. . , , , . .

    GLScene , Jat-Studio, 2009

  • ! . !.

    !. , - . - .

    , , GLScene: 1. Delphi. 2. GLScene GLScene1

    GLScene. 3. GLSceneViewer GLSceneViewer1

    GLScene. 4. alClient Align GLSceneViewer1

    . 5. GLCadencer GLCadencer1

    GLScene GLScene. 6. GLScene1 Scene GLCadencer1

    . 7. GLScene1

    (Scene Editor). 8. Cameras Add Camera. 9. GLCamera1 Position.X := 5, Position.Y := 5, Position.Z

    := 5 ; . 10. Scene objects Add object LightSource

    . 11. GLLightSource1 Position.Z := 10

    , . 12. Scene object Add object Basic Geometry

    Cube . 13. GLCamera1 TargetObject := GLCube1

    . 14. GLSceneViewer1 Camera := GLCamera1

    , . 15. GLCube1 Object TreeView Progress

    . 16. : GLCube1.TurnAngle := GLCube1.TurnAngle + deltaTime * 100;

    Z. 17. F9 ! , .

    GLScene, , , GLScene, , . GLScene . , , , , , OpenGL . , , .

    GLScene , Jat-Studio, 2009

  • . GLScene , -

    . , . . , GLScene.

    . X, Y Z.

    ( ) [0, 0, 0] 90 . . : - Y, - X Z. OpenGL : - Z, - X , , Y . , , OpenGL , , . ShowAxes := True . , , , . , TGLGraph TGLTerrainRenderer.

    , . . Y. () Z.

    () . GLScene () . () , , , () . , , .

    . OpenGL (single) . ?

    , 8 . . ( ). (). () , . . ? , 3.14 3.1415926535. Delphi . Delphi y , single, double extended. single 8 , 8 . . () 3.1415926 single. , , 1000? 3000.1415926, single. : 3000.1415.

    , , single . , - , extended, . OpenGL, extended single.

    GLScene , Jat-Studio, 2009

  • ,

    GLScene. . - .

    . , ,

    , . GLScene . , , , . : Vector3f, Vector4f, AffineVector. [X, Y, Z]. W. , - () . GLScene overload, .

    OpenGL , . : 4x4 . , . . , GLScene . VectorGeometry. . .

    (). 3 ().

    . , . . (face) (back), . , . . . (smoothing edges) . , . 0 1. U V . .

    () , , ( ). . () , , , . () Z . Z Z . , () , , Z , Z ( ). , , , .

    OpenGL. , .

    OpenGL, GLScene, , , .

    GLScene , Jat-Studio, 2009

  • . ,

    GLScene: GLScene, GLScene PFX, GLScene utils and GLScene shaders. GLScene

    GLScene . , .

    GLSceneViewer ,

    . . , . (TGLCamera), GLSceneViewer (TGLScene). Buffer. .

    GLFullScreenViewer GLSceneViewer, , ,

    . (resolution) . , , 800x600 1024x768.

    GLMemoryViewer Memory Viewer (canvas).

    . . (TGLCube) .

    GLMaterialLibrary Material Library .

    . .

    , GLScene. , , material. . material (Material Editor). .

    : 1. Front properties .

    (Diffuse) . . (Ambient) . (Specular) . (Emission)

    GLScene , Jat-Studio, 2009

  • . , (Diffuse). .

    2. Back properties front properties , . , (culling) .

    3. Texture .

    disabled. - , , . (Back Front properties). , disabled . GLScene jpg, tga, bmp. uses jpeg tga . Texture Mode tmModulate. , , . : 2,4,8,16,32,64,128,256,512,1024 . . . , , 32x512. , , GLScene .

    blending mode. , . (bmOpaque) . (bmTransparent) . , . (bmAdditive) .

    , (GLMaterialLibrary). . , 100 100 . MaterialLibrary , . GLCube.Material.MaterialLibrary GLCube.Material.LibMaterialName , . ! MaterialLibrary Material.MaterialLibrary. !

    : AddTextureMaterial. (). :

    Texture.Disabled := False; Texture.Modulation := tmModulate;

    GLCadencer , GLScene, ()

    . . . . , . , , .

    GLScene , Jat-Studio, 2009

  • , . .

    GLCadencer. . .

    () Progress GLScene. GLScene onProgress, , () . onProgress.

    Progress deltaTime. , . , , . 30 . deltaTime 0,033333. - deltaTime . , X 10 , : GLCube.Position.X := GLCube.Position.X + 10 * deltaTime.

    Cadencer enabled. . . Cadencer (GLCadencer.Mode). cmASAP , , . cmIdle cmManual . Cadencer.minDeltaTime. , , , . . Cadencer.maxDeltaTime cadencer .

    GLGuiLayout GUI (Grafical User Inteface) .

    GUI , Delphi , , , , . GUI Manager GUI, .layout GUI Editor. , . 8.9 GUI Objects.

    GLBitmapFont . TGLBitmapFont

    TGLHUDText. , , . , . GLBitmapFont.Ranges , . range ASCII. GLBitmapFont , . GLHUDText . GLBitmapFont . . , I , M. , .

    GLScene , Jat-Studio, 2009

  • GLWindowsBitmapFont ,

    Windows. Font, GLHUDText . TrueType . , .

    GLStoredBitmapFont , -,

    GLScene. . .glsf. Windows, . , . .glsf . GLWindowsBitmapFont GLStoredBitmapFont . .

    GLScriptLibrary [ ]

    GLSoundLibrary GLScene ,

    . GLSoundLibrary GLMaterialLibrary, . GLSoundLibrary.Samples . mp3 wav . mp3 . . GLSoundLibrary GLSMWaveOut, GLSMBass GLSMFMod. (behavior) . , GLSoundLibrary. .

    GLSMWaveOut [ ]

    GLODEManager ODE (Open Dynamic Engine) .

    . http://www.ode.org/. . ODE *.dll*. (ode.dll) , Windows/system32. ODE behavior, , . , , . ODE ODE behavior. ODE:

    1. , .

    . , . 2. ,

    ( - joints). , , .

    GLScene , Jat-Studio, 2009

  • . , , . , , , mesh- . , .

    ODE Manager ode.dll . Step , . onProgress GLCadencer.

    GLODEJointList ODE,

    GLODEJointList. , , , , , , . . http://www.ode.org/.

    GLSMBass Bass . bass.dll

    Windows *.exe* . GLBass , GLSoundLibrary sound behavior .

    GLSMFMOD , GLBass, fmod.dll. GLScenePFX

    . PFXManager

    , , , . , . . Effects . (renderer).

    GLCustomPFXManager [ ]

    GLPolygonPFXManager ,

    . . (inner) (outer) . . .

    GLPointLightPFXManager [ ]

    GLCustomSpritePFXManager [ ]

    GLScene , Jat-Studio, 2009

  • GLPerlinPFXManager PerlinPFX , .

    .

    GLFireFXManager , .

    . (particle size) .

    GLThorFXManager .

    . . GLSceneUtils

    AsyncTimer TTimer, Delphi.

    GLScene. onTimer. onProgress GLCadencer. AsyncTimer GLCadencer. .

    GLStaticImposterBuilder Imposter .

    Imposters , , . , , , - , . . ( ), .

    ImposterBuilder . , . . . , 0 15 24 , imposter 15 15 . RequestImposterFor .

    HDS. Height Data Source

    GLTerrainRenderer. (terrain) , . HDS .

    GLBitmapHDS . BitmapHDS -

    , . , ,

    GLScene , Jat-Studio, 2009

  • . - 16 . , - 8 . 16 , .

    GLCustomHDS [ ]

    GLHeightTileFileHDS HeightTileFileHDS *.htf*.

    . , TileSize *.htf*. TileSize , *.htf*.

    GLBumpmapHDS [ ]

    GLPerlinHDS [ ]

    CollisionManager [ ]

    GLAnimationController GLAnimationController TGLActor. ,

    . *.md2* (Quake) *.smd* (Valve). . , .

    Joystick [ ]

    ScreenSaver ,

    Windows.

    AVIRecorder *.avi*.

    GLTimeEventsMGR [ ]

    GLVfsPAK [ ]

    GLNavigator [ ]

    GLUserInterface [ ]

    GLScene , Jat-Studio, 2009

  • GLFPSMovementManager [ ]

    GLMaterialScripter [ ]

    GLDCEManager [ ]

    ApplicationFileIO [ ] GLSceneShaders

    . .

    .

    GLTexCombineShader [ ]

    GLMultiMaterialShader [ ]

    GLUserShader [ ]

    GLOutLineShader [ ]

    GLHiddenLineShader [ ]

    GLCelShader [ ]

    GLBumpShader [ ]

    GLPhongShader [ ]

    GLScene , Jat-Studio, 2009

  • . .

    ? GLScene

    , Delphi. GLScene , Scene Editor. . .

    GLScene Editor, . GLScene Editor GLScene Delphi. . Scene, : Cameras Scene Objects. Scene GLScene.Objects ( ) GLScene. Cameras Add camera . GLScene. , , Scene Objects. Scene Objects . , . .

    GLScene Editor . . , , . , . . , . ( HUD ) , , , . ( , ) Move object down Move object up.

    GLScene ,

    . , : Bechaviors {} ,

    . , . . GLSceneUtils.

    : - Collision; - Simple Inertia; - Simple Acceleration; - Sound Emitter; - Movement controls; - FPS Movement; - DCE Static Collider; - DCE Dynamic Collider; - ODE Dynamic; - ODE Static; - ODE HeightField Collider;

    GLScene , Jat-Studio, 2009

  • Children {} . . , .

    Count {} . , .

    Direction {} , . ( 1). - [0,0,1].

    Effects {} . PFX, .

    : - PFXSource; - FireFX; - ThorFX; - ExplosionFX; Objects Sorting { } . Material {} GLScene. Parent {} .

    . Pitch Angle { } , Y,

    . Position {} , 3D .

    [0, 0, 0]. Roll Angle { } , X,

    . . Direction Up, .

    Scale {} . , , X. . [1, 1, 1].

    Show Axes { } , X, Y Z .

    Tag Float { } Delphi Tag, single.

    Turn Angle { } , Z, . . Direction Up, .

    Up {} , Direction, , 3D . Up Direction ( 1). - [0, 1, 0].

    Visibility Culling { } Visibility culling , . , , . . Visibility culling , .

    Visible {} . , onProgress, .

    GLScene , Jat-Studio, 2009

  • GLCamera ,

    . , , position, direction up. C . 3D . Target, , .

    FieldOfView , . , (zoom). , , .

    - (culling planes). , , , . , , (near) (far) . NearFrustrumRange FarFrustrumRange. . . , . . GLSceneViewer.Buffer (fog). . , . , , GLSceneViewer .

    GLScene , Jat-Studio, 2009

  • GLLightSource , GLScene. .

    . . . . .

    LightSource . , , , . , . , . , Lightmaps, Z-Shadows Shadow Volumes.

    : 1. Omni Light .

    . , , , - .

    2. Spot Light .

    . 360, Omni. Spot Light .

    3. Parallel Light

    , . . .

    GLDummyCube

    GLScene . . , DummyCube , . DummyCube . , , , DummyCube, DummyCube. , DummyCube, DeleteChildren DummyCube. . DummyCube, DummyCube .

    DummyCube VisibleAtRuntime. DummyCube .

    .

    . , .

    GLSprite

    , . . HUD , GLSprite 3D . , . . , Rotation.

    GLScene , Jat-Studio, 2009

  • GLPoints , .

    3D . Size, . 3, , , . . , .

    GLLines

    , . . . , , . . , , .

    GLPlane

    GLPlane . , . . (Direction) . . , , , . , , . , , (Direction) .

    Vertex shading , . , .

    GLPolygon

    [ ]

    GLCube GLCube () ,

    . CubeWidth (), CubeHeight () CubeDepth ().

    GLFrustrum

    GLFrustrum (- ) , .

    GLSphere

    GLSphere () Radius () , Segments () , , .

    GLDisk

    [ ]

    GLCone [ ]

    GLCylinder [ ]

    GLDodecahedron [ ]

    GLScene , Jat-Studio, 2009

  • GLIcosahedron [ ] , , .

    GLAnimationSprite GLAnimationSprite ( ) ,

    . . . . , .

    GLArrowLine

    GLArrowLine ( ). . Direction.

    GLAnnulus

    .

    GLExtrusionSolid [ ]

    GLMultiPolygon [ ]

    GLPipe [ ]

    GLRevolutionSolid [ ]

    GLTorus [ ] (mesh) , ,

    . . 3D . , , 3DSMax, Maya, Milkshape. *.3ds*, *.obj*, *.md2*, *.md3*, *.smd* .

    GLActor

    , 3D . , . GLActor GLFreeForm, . Animations. GLActor AnimationControler. Quake *.md2* . (meshes) . . .

    GLScene , Jat-Studio, 2009

  • HalfLife *.smd*. . , . . .

    GLFreeForm

    . (mesh). , uses . , *.3ds* GLFile3DS. LoadFromFile GLFreeForm. . ( ) . Mesh list. .

    GLMesh

    [ ]

    GLTilePlane [ ]

    GLPortal [ ]

    GLTerrainRenderer GLTerrainRenderer .

    GLTerrainRenderer , LOD. LOD Level Of Detail . (quads). , , , . , , . ( ), . GLTerrainRenderer HDS, . Up GLTerrainRenderer Z .

    , - .

    .

    GLFlatText [ ]

    GLHeightField [ ]

    GLXYZGrid X, Y Z.

    . . ,

    . , , , , .

    GLScene , Jat-Studio, 2009

  • GLParticles [ ]

    GLPFXRenderer GLPFXRenderer ,

    , , , . : PFXManager , Effects , , PFXRenderer . , .

    -.

    SceneViewer.Buffer.BackgroundColor. , (Environment objects).

    GLEarthSkyDome

    [ ]

    GLSkyDome GLSkyDome ( ) ,

    . , . () Stars. .

    GLSkyBox

    GLSkyBox , , , . , .

    HUD HUD Head Up Display {: ( )}.

    (). X Y. X , Y HUD . [0, 0] . ( ), .

    GLHUDSprite

    HUD . . GLMaterialLibrary, . . . Width Height. GLHUDSprite , Rotation.

    GLHUDText

    HUD , Text. GLScene.

    GUI

    GLScene , Jat-Studio, 2009

  • [ ] GUI :

    GLRootControl

    GLPopupMenu

    GLForm

    GLPanel

    GLButton

    GLCheckBox

    GLEdit

    GLLabel

    GLAdvancedLabel

    GLScrollBar

    GLStringGrid

    GLBitmapControl .

    GLLensFlare GLLensFlare ,

    . . GLLensFlare , . GLLensFlare. , . GLLensFlare , , .

    GLTextureLensFlare

    [ ]

    GLMirror [ ]

    GLShadowPlane GLShadowPlane .

    . (stencil buffer) GLSceneViewer. , . Z-plane.

    GLShadowVolume

    [ ]

    GLScene , Jat-Studio, 2009

  • GLZShadows [ ]

    GLTextureEmitter [ ]

    GLProjectedTextures [ ]

    GLBlur [ ]

    GLTrail [ ] (Doodad objects) , .

    GLSpaceText .

    Windows . (Extrusion).

    GLTeapot , 3DS MAX.

    GLTree C .

    , . , . ( ) Depth. .

    GLWaterPlane

    .

    GLDirectOpenGL OpenGL. OpenGL,

    .

    GLProxyObject , ,

    GLFreeForm, , , GLProxyObject. . GLProxyObject , Master object. , , .

    GLMultiProxy

    GLMultiProxy GLProxyObjects. Master object, .

    GLScene , Jat-Studio, 2009

  • , . , .

    GLRenderPoint

    [ ]

    GLImposterSprite [ ]

    GLOpenGLFeedBack [ ]

    GLScene , Jat-Studio, 2009

  • (Runtime) . GLScene

    (design time). , GLScene, (run time). Delphi Create. -. GLScene, , . , , MyGLSphere GLCube1, :

    var MyGLSphere: TGLSphere; begin MyGLSphere := TGLSphere(GLCube1.AddNewChild(TGLSphere)); end; ,

    GLCube1. GLCube1, AddNewChildFirst AddNewChild. MoveUp MoveDown Parent. MyGLSphere.Free.

    GLScene. , Delphi. , , (spinning cube).

    type TGLSpinningCube = class(TGLCube) private FSpinSpeed: single; published property SpinSpeed read FSpinSpeed write FSpinSpeed; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure DoProgress(const progressTime: TProgressTimes); override; end; constructor TGLSpinningCube.Create(AOwner: TComponent); begin inherited; FSpinSpeed := 1000; end; destructor TGLSpinningCube.Destroy; begin inherited; end;

    GLScene , Jat-Studio, 2009

  • procedure TGLSpinningCube.DoProgress(const progressTime: TProgressTimes); begin inherited; TurnAngle := TurnAngle + progressTime.DeltaTime * FSpinSpeed; end; Delphi

    onProgress. ProgressTime DeltaTime. inherited, . , , , , GLScene GLSceneEditor.

    GLScene , Jat-Studio, 2009

  • : 3D .

    GLScene. , . . , 3D .

    , -. , .

    . 2.5D . . , .

    . , . (Label) . .

    . . . , , . .

    GLScene, GLSceneViewer, GLCadencer,

    GLWindowsBitmapFont. 11 X 21 Z. Z. . [0, 0, -0,5], GLCube [-6, 0, 10] [6, 0, 10] , 10 . design time. . , .

    , . single.

    var FloodLevels: array [-5..5] of single; ,

    . , , - . . , , FloodLevels . , . , FloodLevels . 0,5 .

    IsKeyDown GLScene Keyboard.pas. , . :

    T3DTInput = (inpNone, inpMoveL, inpMoveR, inpRotateL, inpRotateR);

    GLScene , Jat-Studio, 2009

  • var UserInput: T3DTInput; onProgress GLCadencer

    UserInput. UserInput := inpNone; If IsKeyDown(VK_LEFT) then UserInput := InputMoveL; .

    () . OnMouseMove , . Windows , . , . OnProgress GLCadencer . OnMouseMove Mouse.X := X; Mouse.Y := Y.

    GLCadencer GLHUDText, .

    3DTBlock , GLDummyCube.

    . GLDummyCube , . GLCube . Z FloodLevels, . Round, X .

    [0, 0, 0]. GLCube [0, 0, 0]. GLCube . , , L- . . 0,95 . [1, 0, 0], [2, 0, 0], [0, 0, 1], [0, 0, 2], [-1, 0, 0] . Y 0. , , X. ( Boolean) Active := True. , , , Active False.

    , Z, OnProgress :

    Position.Z := Position.Z deltaTime * speed; .

    (X < -5 X > 5) (Z < 0) . , .

    var absPos: TVector; setVector(absPos, Children[i].AbsolutePosition); if (absPos[2] - 1) < FloodLevels[Round(absPos[0])] then

    GLScene , Jat-Studio, 2009

  • , Children[i], , FloodLevels . absPos. , . . FloodLevels, X . , Active False, , .

    , T3DTInput , , :

    case Form1.UserInput of inpMoveL: Slide(-1); inpMoveR: Slide(1); inpRotateL: Pitch(-90); inpRotateR: Pitch(90); end; Slide Pitch GLScene .

    , .

    . OnProgress GLCadencer. FloodLevels 20. , , GLCadencer , .

    .

    , , , . , GLScene. , . , . , , . :

    - . .

    Delphi GUI GLScene. .

    . CollisionManager

    . , .

    . . , , ,

    . ,

    . .

    . , SkyBox, LensFlare. , . , .

    GLScene , Jat-Studio, 2009

  • , , - . .

    . ,

    - . . , . . X, Y Z .

    - . ! . ,

    . . , . , . , . . freeware , . !

    GLScene , Jat-Studio, 2009

  • .

    http://www.glscene.org/ GLScene

    http://www.opengl.org/ Web- OpenGL

    http://www.glscene.ru/ GLScene

    http://www.gamedev.ru/

    GLScene ,

    . . .

    GLScene , Jat-Studio, 2009

  • . ,

    GLScene, . GLScene. , , , . - GLScene. , ! - GLScene.

    ! Jat-Studio 2009 , 2005

    Jan Zizka, , .