Page 3 of 3

Posted: Wed Mar 08, 2006 6:38 pm
by Roger
Working on it, but you'll find that it's just a modified version of PB's terrain example with a different terrain and a cube added for the water.

At the moment it's a bit of a mess, but as soon as I got it to work I'll make you a nice little, shiny new .zip package containing the code ;)

Posted: Wed Apr 05, 2006 9:22 pm
by Progi1984
Hi, i try to work on this point.

I find a blitz3D code http://www.blitzbasic.com/codearcs/code ... ?code=1110
But I don't arrive to transform it in Pure.

Code: Select all

Define.f KeyX, KeyY,KeyXCam, KeyYCam, MouseX, MouseY
Define.l actif
Global actifmesh.s

IncludeFile "Screen3DRequester.pb"
Declare WaterEffect()



Enumeration
  #TrackEntity
  #OgreEntity
  #CubeEntity
  #NinjaEntity
  #SphereEntity
EndEnumeration

actif=#CubeEntity
actifmesh="Cube"

If InitEngine3D()

  Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
  Add3DArchive("Data\Dragon.zip", #PB_3DArchive_Zip)
 
  Add3DArchive("Data\Ogre\"   , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Circuit\", #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Cube\"   , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Ninja\"  , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\Sphere\" , #PB_3DArchive_FileSystem)
  Add3DArchive("Data\"        , #PB_3DArchive_FileSystem)
 
  Parse3DScripts()
 
  InitSprite()
  InitKeyboard()
  InitMouse()
 
  If Screen3DRequester()
 
    AmbientColor(RGB(128,128,128))
       
    EnableWorldPhysics(1)
   
    WorldShadows(#PB_Shadow_Additive)
   
    EnableWorldCollisions(1)

   
    OgreMesh   = LoadMesh(#PB_Any, "OgreHead.mesh")
    TrackMesh  = LoadMesh(#PB_Any, "racingcircuit.mesh")
    CubeMesh   = LoadMesh(#PB_Any, "Cube.mesh")
    SphereMesh = LoadMesh(#PB_Any, "Sphere.mesh")
   
    Text = LoadTexture(#PB_Any, "r2skin.jpg")
    Mat = CreateMaterial(#PB_Any, TextureID(Text))
   
    Steel = LoadTexture(#PB_Any, "RustySteel.jpg")
    SteelMaterial = CreateMaterial(#PB_Any, TextureID(Steel))
   
    DisableDebugger
    CreateEntity(#OgreEntity  , MeshID(OgreMesh), 0, 10, 0, 0)
    CreateEntity(#TrackEntity , MeshID(TrackMesh), 0, 0, 00, 0)
    CreateEntity(#CubeEntity  , MeshID(CubeMesh), MaterialID(Mat), 20, 0, 0)
    CreateEntity(#SphereEntity, MeshID(SphereMesh), MaterialID(SteelMaterial), 0, 0, 0)
    EnableDebugger

    EntityPhysicBody(#TrackEntity, #PB_Entity_StaticBody)
    EntityRenderMode(#TrackEntity, 0)
    EntityRenderMode(#OgreEntity, 0)
    ScaleEntity(#OgreEntity, 0.1, 0.1, 0.1)
    EntityRenderMode(#SphereEntity,0)
    ScaleEntity(#SphereEntity, 0.05, 0.05, 0.05)
    EntityRenderMode(#CubeEntity,0)
    ScaleEntity(#CubeEntity, 0.1, 0.1, 0.1)

    Fog(RGB(50,100,150),1,-100,200)   
    CreateLight(0, RGB(255,255,255),  100.0, 100, 0)
   
    SkyBox("desert07.jpg")
   
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0,0,0,30)
     
    Repeat
      Screen3DEvents()
     
      ClearScreen(RGB(0, 0, 0))
           
      If ExamineKeyboard()
        If KeyboardPushed(#PB_Key_Pad1) Or KeyboardPushed(#PB_Key_1)
          actif=#CubeEntity
          actifmesh="Cube"
        ElseIf KeyboardPushed(#PB_Key_Pad2) Or KeyboardPushed(#PB_Key_2)
          actif=#SphereEntity
          actifmesh="Sphere"
        ElseIf KeyboardPushed(#PB_Key_Pad3) Or KeyboardPushed(#PB_Key_3)
          actif=#OgreEntity
          actifmesh="Ogre"
        EndIf
       
       
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -1
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = 1
        Else
          KeyX = 0
        EndIf
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -1
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = 1
        Else
          KeyY = 0
        EndIf
       
        If KeyboardPushed(#PB_Key_A)
          KeyXCam = -1
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyXCam = 1
        Else
          KeyXCam = 0
        EndIf
        If KeyboardPushed(#PB_Key_W)
         KeyYCam = -1
        ElseIf KeyboardPushed(#PB_Key_S)
          KeyYCam = 1
        Else
          KeyYCam = 0
        EndIf
             
        If KeyboardPushed(#PB_Key_Space)
          MoveEntity(#OgreEntity, 10, 40, 0)
        EndIf
   
      EndIf
     
      If ExamineMouse()
        MouseX = -MouseDeltaX()/10
        MouseY = -MouseDeltaY()/10
      EndIf
      RotateCamera(0, MouseX, MouseY, 0)
      MoveCamera  (0, KeyXCam, 0, KeyYCam)
      MoveEntity(actif,KeyX, 0, KeyY)
      RenderWorld()
      WaterEffect()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
   
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
 
End

Procedure WaterEffect()
  gw=WindowWidth(0)
  gh=WindowHeight(0)
  CreateSprite(0,gw,gh)
  GrabSprite(0,0,0,gw,gh)
  StartDrawing(ScreenOutput())
    underw_a=(underw_a+4)
    steph.f=gh/32
    mu8.f=gh/60
    If underw_a>359
      underw_a=0
    EndIf
    iiff=Int((gh-4)*100)
    For iif=0 To iiff Step 1
      int.l=Int(underw_a+iif)
      mod=int % 360
      wsin.f=Sin(mod)*mu8
      ClipSprite(0,0,iif, gw,steph+4)
       DisplaySprite(0,0,iif+wsin)
    Next
  StopDrawing()
  FreeSprite(0)
EndProcedure

Posted: Sat Apr 08, 2006 8:34 pm
by fsw
Num3 wrote:Here it is!
Get it while it's hot ;)

File:363kb->Water.zip
Tested it with V4 and it crashes, the textures are not loaded.

Posted: Sat Apr 08, 2006 9:13 pm
by LuCiFeR[SD]
I think it's because the files that came with the ogre beta (Fred released some time ago and it seems to be no longer available from the beta area) are not included with PB4 beta's and alas, I no longer have those files either and it crashes for me to :(. Oh well.

Posted: Sat Apr 08, 2006 9:20 pm
by Num3
Hey just put these textures with the correct name's in the data directory :P

Image
Image

Posted: Sat Apr 08, 2006 11:21 pm
by blueznl
num3, textures is one thing, how about using animated ones? water moves, ya know... :-)

Posted: Sun Apr 09, 2006 11:27 am
by Num3
ScrollMaterial(3, 0.0009,0.005, #PB_Material_Animated,1) ;)

Posted: Tue Apr 11, 2006 8:56 am
by Thalius
Something maybe to port to PB ...

Reallyreally nice:
http://graphics.cs.lth.se/theses/projects/projgrid/

Thalius

Posted: Tue Apr 11, 2006 12:04 pm
by dagcrack
Num3 wrote:ScrollMaterial(3, 0.0009,0.005, #PB_Material_Animated,1) ;)
Oh boy.. Oh god.. We are in 2006 did you figure that out? need a calendar!? :lol: :lol:

Posted: Tue Apr 11, 2006 12:13 pm
by dell_jockey
Thalius wrote:Something maybe to port to PB ...

Reallyreally nice:
http://graphics.cs.lth.se/theses/projects/projgrid/

Thalius
Nice reference. Thanks Thalius!