Welcome to Phrogram Sign in | Join | Help


FAQ: How do I start writing 3D programs

  •  01-19-2007, 5:37 PM

    FAQ: How do I start writing 3D programs

    Attachment: Simple3D Example.kpl

    ANS:

    The basics for a 3D program

    3D programming is the same as 2D programming but there are a few things you need to know before starting, 3D images are displayed in Frames per second, you need to set up a camera object to view the frames then render the frames so the Camera can see them.

     

    • The Camera is like your eyes in the rendered frames.
    • Only 3D objects can be used in 3D mode, no 2D objects like Sprites are allowed
    • Most other programming elements are the same as 2D programming except in 3D programming you have 3 coordinates to a point instead of 2. Example :
      • X,Y,Z X = Horizontal, Y = Vertical and Z = Depth

     

    A basic 3D program looks like this:

     

    Program Simple3DExample

     

          Method Main()

                // Hide the Phrogram tool bar

                HideToolbar()

     

                // Switch Phrogram to 3D mode, 3D Sprites are not available

    // in this mode, only model3D and SkyBoxs3D are.

                SwitchTo3D()

     

                // define a camera object to view the frames

                Define cam As Camera

     

                // define a SkyBox3D object, this object is the container

    // that all models will be displayed and moved in

                Define sky As Skybox3D

                // load the mesh file that is the SkyBox

                sky.LoadMesh( "Skybox1a.x" )

     

                // Start the main render loop

                While Not IsKeyDown( Escape )

     

                      // Point the Camera object at the 3dPoint you wish to

    // view

                      cam.PointAt(0,0,0)

         

                      // Render the image so the camera can see it

                      RenderFrame()

     

                End While

     

          End Method

     

    End Program

     

    This Example only displays a Skybox, you can add models and keyboard control very easily, to see how open Alen3D.kpl in the Phrogram Examples.

    “5) Advanced Learning Examples \ 3D \ Alen3D.kpl”

     

    Filed under: ,
View Complete Thread