December 01, 2020, 05:55:51 PM

Author Topic: PureBasic Terrain.png  (Read 3803 times)

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
PureBasic Terrain.png
« on: October 21, 2019, 06:41:00 PM »
Good evening I'm back again still no terrain . I feel I'm nearly there but would be happy if some kind soul could explain where I'm going wrong . It runs ok up to addmateriallayer , then create terrain , then build terrain . when debugged the all return a 0 . why I don't know .I have tried using different sized .png files and it makes no difference . Anyway here's the code as it stands . I have no idea why it won't work but you might . Thanks for reading .
Code: [Select]
UsePNGImageDecoder()
UsePNGImageEncoder()

InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive("C:/Users/pfabe/Documents",#PB_3DArchive_FileSystem)
OpenScreen(1366,768,32,"")
Debug LoadTexture(1,"blue.png")
Debug LoadTexture(2,"paulstree.png")
Debug LoadImage(4,"amaze12.png")
Debug CreateMaterial(4, TextureID(1))
Debug AddMaterialLayer(4, TextureID(2))
Debug CreateTerrain(4, 513,10240,1,2,"terrain", "dat")
Debug BuildTerrain(4)
CreateCamera(0,0,0,100,100)
CameraLookAt(0,100,10,2000)
CameraBackColor(0,#Green)
Repeat
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_A)
       
        a=a-2
        RotateCamera(0,0,a,0)
      EndIf
      If KeyboardPushed(#PB_Key_D)
       
        a=a+2
        RotateCamera(0,0,a,0)
      EndIf
      If KeyboardPushed(#PB_Key_W)
        b=0
        b=b+2
        MoveCamera(0,0,0,b)
      EndIf
      If KeyboardPushed(#PB_Key_S)
        b=0
        b=b-2
        MoveCamera(0,0,0,b)
      EndIf
     
    Until KeyboardPushed(#PB_Key_Escape)   
   
    End
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #1 on: October 21, 2019, 06:48:07 PM »
By the way blue.png and paulstree.png are both 512x512 and amaze12.png is 2048x2048. Don't know if that makes any difference . could it be a problem with the .png format ? not sure . will keep experimenting while I wait for the answers hopefully . Thanks for taking the time to read this .Bonjour .
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Kris

  • Full Member
  • ***
  • Posts: 116
Re: PureBasic Terrain.png
« Reply #2 on: October 21, 2019, 09:49:06 PM »
Just by looking at your code, I see you did not setup the terrain by the SetupTerrains() function. If you read the manual it tells you at the CreateTerrain() function that SetupTerrains() has to be called before you use it. By checking out SetupTerrains() you would also see that you have to define a light and assign it to the terrain. It's in that bare minimum terrain code I posted in the other terrain topic you created.

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #3 on: October 21, 2019, 10:00:36 PM »
Hey thanks Kris I'm onto it . I've been using the pure basic book from version 4 and I think there's been a few changes since then.
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #4 on: October 21, 2019, 10:50:46 PM »
The only one giving me a debug 0 now is BuildTerrain(0) so must be nearly there . Here's the amended code . I just want to know if I'm doing something really stupid. Does anybody know of a good book on Pure Basic I've got 3 of them
PureBasic a begginers guide
PureBasic Reference Manual 2019
And Programming 2D scrolling Games for Pure Basic 5

PureBasic a begginers guide would be great but I think it's changed a bit since it was written for PB 4
Any way could anybody suggest a recent manual or tutorial . Thanks for reading.
Code: [Select]
UsePNGImageDecoder()
UsePNGImageEncoder()

InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive("C:/Users/pfabe/Documents",#PB_3DArchive_FileSystem)
OpenScreen(1366,768,32,"")

  light = CreateLight(#PB_Any ,RGB(255, 255, 190), 4000, 1200, 1000,#PB_Light_Directional)
    SetLightColor(light, #PB_Light_DiffuseColor, RGB(250,250,230))
    LightDirection(light ,0.55, -0.3, -0.75)
    AmbientColor(RGB(10,10,10))
Debug SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
Debug LoadImage(4,"amaze12.png")
Debug LoadTexture(1,"blue.png")
Debug LoadTexture(2,"paulstree.png")


Debug CreateMaterial(#PB_Any,TextureID(1))
;Debug AddMaterialLayer(#PB_Any, TextureID(2))

Debug CreateTerrain(#PB_Any, 513,600,60,1,"terraingroup", "dat")
Debug BuildTerrain(5)
CreateCamera(0,0,0,100,100)
MoveCamera(0,300,200,200)

CameraLookAt(0,40,10,500)
CameraBackColor(0,#Green)
Repeat
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_A)
       
        a=a-2
        RotateCamera(0,0,a,0)
      EndIf
      If KeyboardPushed(#PB_Key_D)
       
        a=a+2
        RotateCamera(0,0,a,0)
      EndIf
      If KeyboardPushed(#PB_Key_W)
        b=0
        b=b+2
        MoveCamera(0,0,0,b)
      EndIf
      If KeyboardPushed(#PB_Key_S)
        b=0
        b=b-2
        MoveCamera(0,0,0,b)
      EndIf
     
    Until KeyboardPushed(#PB_Key_Escape)   
   
    End
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #5 on: October 22, 2019, 01:19:49 PM »
Well I just junked all my code on building a terrain . I think I was doing things in the wrong order . I'll be laughing at this in a couple of weeks . Gonna start with a fresh sheet . I know more about what I'm doing now . onwards and upwards . Thanks for all the code and advice . Happy coding
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #6 on: October 22, 2019, 04:30:55 PM »
just been going over my code and i'm trying to load my main terrain base as an image file is this correct if not where do I put it to be used . thanks for reading. its the amaze12.png file i'm referring to. bonjour
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #7 on: October 23, 2019, 08:43:24 PM »
Well I've got a bit further I now have something on the screen although not really what I expected . Gonna start again tonight with a fresh sheet.  Have been missing out the create material bit . Hopefully this time around I'll get it right .  been at it a few days now . Thanks for reading .
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #8 on: October 24, 2019, 04:39:57 PM »
Good afternoon just a couple of questions. firstly what is the difference between a texture and a material. or are they both the same. some terrain tutorials say add material layer others add texture.
I have managed to get my terrain onto the screen but it manifests itself as a 2d image of one of my height maps as a square in the middle of the screen . what is going on ? Any suggestions would be quite useful at this point . thanks for reading.
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2867
  • elgol 2021
Re: PureBasic Terrain.png
« Reply #9 on: October 24, 2019, 04:41:35 PM »
It might be best to also ask on the official Pure BASIC Forum too.   :)
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry Pi 400, Pi4, C64, ZX Spectrum Next.

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #10 on: October 24, 2019, 05:16:01 PM »
Yeah thanks Steve. I'll work it out eventually.
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1078
Re: PureBasic Terrain.png
« Reply #11 on: October 24, 2019, 05:29:20 PM »
Quote
what is the difference between a texture and a material. or are they both the same. some terrain tutorials say add material layer others add texture.

a material is a group of things / properties applied to a surface

a mesh can have one/several surface(s)

a surface is made of vertices and triangles

a material has usually these properties :
color
alpha
blend
fx
texture(s) (there can be several textures (one above of an other, and blended with the below one as you define it)

(just in case : a material is called a brush in Blitz3d)

a texture is only made of texels with color/alpha properties. usually it must be "power of two" meaning its width and its height must be of a size of 2 or 4 or 8 or 16 or 32 or 64 or 128 or 256 or 512 or 1024 or 2048 etc, and you use UVs to set how the texture is applied on the surface (which texels in which triangles)

on a terrain, usually you can have a color layer (full texture) (with a texel size each 1.0unit) and a detail layer (tiled texture) (with a texel size really small like each 0.01unit)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Pfaber11

  • Hero Member
  • *****
  • Posts: 549
  • Bonjour
    • FABERSGAMES
Re: PureBasic Terrain.png
« Reply #12 on: October 24, 2019, 06:48:40 PM »
Thanks RemiD I'll get this sorted eventually. Been at it a few days now and am pretty pissed off with it. I think the examples in the book I've been reading are pretty useless and very different to what's in the examples that come with pure basic. Way to complicated. But maybe that's as simple as they could make them . Anyhow I shall persist. Thanks for reading.
Celeron N3060 1.6 ghz duel core  4 Gb ram 32 gig storage  HD400 Graphics 160 gig external hard drive....

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2867
  • elgol 2021
Re: PureBasic Terrain.png
« Reply #13 on: October 24, 2019, 07:01:01 PM »
Yes that's the problem when the language changes so much over time.  I have 2 books on Pure BASIC and neither would compile code today, online sources are your best bet.
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry Pi 400, Pi4, C64, ZX Spectrum Next.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1078
Re: PureBasic Terrain.png
« Reply #14 on: October 24, 2019, 07:16:44 PM »
maybe, to understand the concept, do some experiments with Blitz3d (quite simple, several code examples) or AGK, then try to convert in purebasic.
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal