PureBasic Terrain.png

Started by Pfaber11, October 21, 2019, 18:41:00

Previous topic - Next topic

Coder Apprentice

#15
Older documentation is good for having a kind of reference of techniques but in a case of PureBasic you constantly need to check everything if it has changed or not. In your case, you should rely more on the combination of the supplied sample codes (there are at least 8 material focused samples) and the built in help witch is pretty good. For example the answer to your question is right there in the help file just at the beginning of the material chapter.

"Materials are composed of one or several textures and sometimes of some colors. They are widely used by the other objects of the 3D world like the entities, billboards and particles to give them a skin. Each material has a lot a properties like the shading, ambient and specular color, etc. to allow realistic looking material like wood, water, glass and more."

Studying the material command index below can give you an idea how the whole thing works. Check out all the material focused samples. Trying to learn from a book that hasn't been updated can give you a lot of unnecessary frustration.

Pfaber11

I think I understand the terrain problem now . When I create a terrain I have a blank screen with a square in the middle . Been experimenting and the problem seems to be the files I'm using . I was just using any old .png files that were square 512x512 in size . And the map I was using was from my maze game at 2048x2048  which was a 2d map used for a height map. This I think is where the problem lies . This is way more complex than I am used to in AGK with height maps . Any way I think I nearly understand this stuff but a bit confused about needing 7 pics for a terrain as in desert07.zip in the examples . I've been over this many times and it seems you can't throw just any file in there and it'll work. Thanks for reading any further advice about suitable files would be most welcome .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Coder Apprentice

#17
The desert.zip pack contains 6 pictures named desert07_BK, desert07_DN, desert07_FR, desert07_LF, desert07_RT, desert07_UP, that are used for the SkyBox() that generates a cube object with 6 sides and assigns each picture as a texture to it's respective side of the cube.   

Pfaber11

nice one Kris will have a play with that. I've really gotta make this work . thanks
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

RemiD

what i have described about material properties is the old way to render, now materials have others properties/textures, like normalmap, specularmap, emissive, etc... as Kris mentionned...

Pfaber11

Well I've got the skybox thing nailed so got something to play with now . My first bit of success in days . I was expecting to be a few days on this part of the learning curve . Gotta nail the terrain over the weekend then I'll hopefully know enough to start a project .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

I have tried using the terrain files from the textures nvidia folder but all I get are black squares which are floating and no terrain. Does this sound familiar? I really can't see what I'm doing wrong .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

RemiD

would this help if i post a simple code example (with comments) on how to make a terrain with a color texture + a detail texture (for Blitz3d) ?
(if you want to understand the concept)

Pfaber11

It might do can't hurt to take a look . I have no idea why what I'm doing is not working . I'm even using the example files . I've been over it so many times . Thanks
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

RemiD

maybe your problem is not that you are doing something wrong but that your gpu is too old/crap and not compatible with the rendering way of ogre (the graphics engine that purebasic apparently uses) ?

Pfaber11

#25
You Know I would agree with you but it runs the examples . I have no problem with producing Entities and displaying them on the screen and moving them about and detecting collisions . It's just the terrain . I might put the code up again to see if anybody can tell me where I'm going wrong . In fact I'll do that now.
Here it is maybe if I stare at it long enough it'll work
.UsePNGImageEncoder()
UseJPEGUsePNGImageDecoder()
ImageDecoder()
UseJPEGImageEncoder()
#CameraSpeed =  2
  InitEngine3D() 
  InitSprite()
  InitKeyboard()
  InitMouse()
  OpenScreen(1366,768,32,"")
    Add3DArchive("C:/Users/pfabe/Documents/Textures", #PB_3DArchive_FileSystem)
    Add3DArchive("C:/Users/pfabe/Documents/nvidia", #PB_3DArchive_FileSystem)
    Add3DArchive("C:/Users/pfabe/Documents/New folder", #PB_3DArchive_FileSystem)
    light = CreateLight(#PB_Any ,RGB(190, 190, 190), 4000, 1200, 1000,#PB_Light_Directional)
    SetLightColor(light, #PB_Light_SpecularColor, RGB(255*0.4, 255*0.4,255*0.4))
    LightDirection(light ,0.55, -0.3, -0.75)
    AmbientColor(RGB(255*0.2, 255*0.2,255*0.2))
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,  800, 400, 80,#PB_Absolute)
    SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
   Debug CreateTerrain(0,513, 12000, 600, 3 , "TerrainGroup", "dat") 
   Debug AddTerrainTexture(0,0,100,"paul1.jpg", "paul2.jpg" )
  Debug  AddTerrainTexture(0,1,30,"paul3.jpg" , "paul4.jpg")
  Debug AddTerrainTexture(0,2,200,"paul5.jpg" , "paul6.jpg")
      DefineTerrainTile(0,0,0, "amaze12.png", #False, #True) 
 
    BuildTerrain(0)   
     
   
    SkyBox("desert07.png")
    Repeat   
      If ExamineKeyboard()           
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -5
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = 5
        Else
          KeyX = 0
        EndIf     
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -5
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = 5
        Else
          KeyY = 0
        EndIf       
      EndIf
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      MoveCamera(0, CameraX(0), TerrainHeight(0, CameraX(0), CameraZ(0)) + 20, CameraZ(0), #PB_Absolute)
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)   
      RenderWorld()
      FlipBuffers() 
    Until KeyboardPushed(#PB_Key_Escape)     
    End   
   

 
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

#26
@ RemiD you were very nearly correct but it turned out to be the other way around . I had to download DirectX 9.0c for it to run so in effect I had to downgrade my system. Anyway all working now . Thanks for making me take a look at my system. And thanks to you Kris for all your help . They could of told me this on the official PureBasic forum but there you go got it sorted in the end . happy coding

I'm now going to go and try and make my own hight map now thanks for again for the help. Only thing bugging me now is will my programs run on a new system . Hmm what do you think Kris is this a problem?
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

RemiD

Quote
ou were very nearly correct but it turned out to be the other way around . I had to download DirectX 9.0c for it to run so in effect I had to downgrade my system.
oh, good. maybe it is not downgrading but rather installing missing (old) libs... now you can continue to experiment, good luck !

Pfaber11

Yes you're right missing old bits . I was preparing to admit to myself I couldn't do it but there you go if it wasn't for that directx thing I would of sorted the terrain thing a lot quicker . So glad I didn't give up . I know the terrain code backwards by now so maybe  not such a bad thing . I can't believe the people on the PureBasic website didn't mention this to me and if you hadn't said my computer might not be up to it and got me to look more closely at the required specifications I would probably of gone nuts by now. I've been at the pure basic for about two weeks now and no how to do nearly as much as over a year using AGK .
In some things Pure Basic is easier than AGK2 for example colliding objects in 3D Pure Basic wins out in that respect . For height maps AGK wins . so far anyway. I would put my latest code up that now works but I doubt anybody would like to see it although for someone starting out it might prove useful. I'll leave it for now but if anybody asks I'll be happy to share.
Happy coding .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

Hi Naughty Alien thanks for your input too. Pure Basic has got to be one of the best basics around . Can't wait to get something published with it. Still got plenty to learn but I've got the basics of 3D and 2D game creation coming along nicely . It's what I call a proper Basic  with a modern twist . Really can't believe how quickly I've picked it up . Had a few hiccups but I'm doing very well for 2 weeks in . when I was learning the python using pygame the graphics used to judder a bit and that I found unacceptable none of that with pure basic or AGK2 . Panda3D would of been what I'd be using for the 3D programming in python  and that seemed very uninviting and complicated.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz