Page 1 of 2

Terrain bugs

Posted: Mon Jul 22, 2013 6:40 am
by Lexicon
Hi!
I'm noob in PB. :( And I have a problem on my terrain. Please see this shot:

http://stalkerfangroup.ru/Stalker_2/terrain_bugs.jpg

What is it and how can I fix it?
Thanks!

Re: Terrain bugs

Posted: Mon Jul 22, 2013 8:36 am
by Fred
You will need to post some code to get help.

Re: Terrain bugs

Posted: Mon Jul 22, 2013 9:15 am
by Lexicon
Fred wrote:You will need to post some code to get help.
Ok, thanks Fred.

Code: Select all

EnableWorldPhysics(1)
EnableWorldCollisions(1)
WorldShadows(#PB_Shadow_Modulative, 0, RGB(180, 180, 180))
MaterialFilteringMode(#PB_Default, #PB_Material_Anisotropic, 8)

SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
CreateTerrain(0, 1025, 10000, 300, 5, "Workspace/terrain_entr", "Dat")
TerrainLocate(0, 5000, 0, 5000)
AddTerrainTexture(0,  0, 70, "grass_tile1.dds", "terrain_heightmap.dds")
AddTerrainTexture(0,  1, 50, "asphalt_tile1.jpg", "grass_green-01_normalheight.dds")
AddTerrainTexture(0,  2, 50, "asphalt_tile2.jpg", "grass_green-01_normalheight.dds")
AddTerrainTexture(0,  3, 50, "grnd_tile1.dds", "grass_green-01_normalheight.dds")
AddTerrainTexture(0,  4, 50, "scale512.png", "grass_green-01_normalheight.dds")
DefineTerrainTile(0, 0, 0, "terrain513.png", 0, 0)
BuildTerrain(0)
UpdateTerrain(0)
SaveTerrain(0, #False)
TerrainRenderMode(0, #PB_Terrain_CastShadows)
TerrainPhysicBody(0, 0.2, 0.2)
Link to terrain height map: http://stalkerfangroup.ru/Stalker_2/terrain513.png
I need help really.

Re: Terrain bugs

Posted: Mon Jul 22, 2013 3:39 pm
by Lexicon
And another question... :oops:

What function will flipping mesh like FlipMesh from Blitz3D? Or how can I do it in PB?
I want to create a sky via place a sphere. But I need to texturing inside this mesh.

Thanks.

Re: Terrain bugs

Posted: Mon Jul 22, 2013 6:23 pm
by DK_PETER
Lexicon wrote:I want to create a sky via place a sphere. But I need to texturing inside this mesh.
I don't think you can in PB. Negative values are not allowed and will produce an "'Assertion Failed!'".
I haven't been able to solve this in PB, but:
what you can do is :
1. create a sphere in 'DeleD' http://sourceforge.net/projects/deled/, make it hollow and export your creation as Ogre mesh.
2. Load it using LoadMesh() and apply the texture/material.
Only minor 'drawback' is, that you'll have the texture both on the inside and the outside.

Have fun.

Re: Terrain bugs

Posted: Mon Jul 22, 2013 6:53 pm
by Comtois
Lexicon wrote:And another question... :oops:

What function will flipping mesh like FlipMesh from Blitz3D? Or how can I do it in PB?
I want to create a sky via place a sphere. But I need to texturing inside this mesh.

Thanks.
you can use SkyDome() , or use MaterialCullingMode() :

Code: Select all

    ;Sky
    CreateMaterial(2, LoadTexture(2, "DosCarte.png"))    
    MaterialCullingMode(2, #PB_Material_AntiClockWiseCull)
    CreateSphere(2, 350)
    CreateEntity(2, MeshID(2), MaterialID(2))
[EDIT]
Please, use 3D programming forum, it makes it easier to find everything about 3D :)

Re: Terrain bugs

Posted: Mon Jul 22, 2013 7:03 pm
by DK_PETER
Hi Comtois.

Sorry...MaterialCullingMode won't do the job. I've already tried that.
(#PB_Material_AntiClockWiseCull and #PB_Material_ClockWiseCull) without the desired result.

And yeah...This and my 3D Specifics questions should be in the 3D section too. ;-)

Best regards
Peter

Re: Terrain bugs

Posted: Mon Jul 22, 2013 7:08 pm
by Comtois
well, this work for me (save it in your folder "Examples/3D")

if you need texture inside and outside, use :

Code: Select all

MaterialCullingMode(2, #PB_Material_NoCulling)

Code: Select all

;
IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY, SpriteX, SpriteY 

Global Dim MeshDataVertex.PB_MeshVertex(0)
Global Dim MeshDataIndex.PB_MeshFace(0)

If InitEngine3D()
  
  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Models", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/Desert.zip", #PB_3DArchive_Zip)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    
    ;- Ground
    ;
    CreateMaterial(0, LoadTexture(0, "Dirt.jpg"))
    CreatePlane(0, 1500, 1500, 40, 40, 15, 15)
    CreateEntity(0,MeshID(0),MaterialID(0))
    EntityRenderMode(0, 0)
    
    CreateCube(1, 50)
    CreateEntity(1, MeshID(1), GetScriptMaterial(1, "Color/Blue"), 0, 50, 0)
    
    ;Sky
    CreateMaterial(2, LoadTexture(2, "DosCarte.png"))    
    MaterialCullingMode(2, #PB_Material_AntiClockWiseCull)
    CreateSphere(2, 600)
    CreateEntity(2, MeshID(2), MaterialID(2), 0, 300, 0)
    
    ;- Camera
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 120, 500, #PB_Absolute)
    CameraBackColor(0, $FF)
    
    ;- Light
    ;
    CreateLight(0, RGB(255, 255, 255), -40, 100, 80)
    AmbientColor(RGB(80, 80, 80))
    
    
    
    Repeat
      
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX()/10 
        MouseY = -MouseDeltaY()/10
      EndIf
      
      
      If ExamineKeyboard()
        
        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
        
      EndIf
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld() 
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

Re: Terrain bugs

Posted: Mon Jul 22, 2013 7:11 pm
by Comtois
DK_PETER wrote:And yeah...This and my 3D Specifics questions should be in the 3D section too. ;-)
Where are your specifics questions ? :P

Re: Terrain bugs

Posted: Mon Jul 22, 2013 7:15 pm
by DK_PETER
@Comtois.

What the??? How did you??? CHRIST DUDE!! Is there ANYTHING you can't code in a couple of seconds?? :-D

My bad...You sample works as it should. (Even better than I expected)..

My question are further down the list...Forget about it..Everything is good.


See you later, my master. ;-)

Re: Terrain bugs

Posted: Mon Jul 22, 2013 8:13 pm
by Lexicon
Thanks so much DK_PETER & Comtois! :D
I will try.

Re: Terrain bugs

Posted: Tue Jul 23, 2013 5:26 am
by Lexicon
Guys! I need help again for another problem. :)

Code: Select all

CreateMesh(11, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)

MeshVertexPosition(0, 0, 0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(0, 5000, 0)
MeshVertexTextureCoordinate(0, 0)
MeshVertexPosition(5000, 5000, 0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(5000, 0, 0)
MeshVertexTextureCoordinate(1, 1)

MeshFace(0, 1, 2)
MeshFace(0, 3, 2)

FinishMesh(#False)
NormalizeMesh(11)

CreateNode(11)
AttachNodeObject(11, MeshID(11))
ScaleNode(11, 1, 1, 1)

CreateMaterial(11, LoadTexture(11, "sky_up.dds"))
DisableMaterialLighting(11, #True)
MaterialShadingMode(11, #PB_Material_Solid)
MaterialCullingMode(11, #PB_Material_NoCulling)
SetMeshMaterial(11, MaterialID(11), 0)

Result = CreateEntity(11, MeshID(11), MaterialID(11))
I see this mesh with texture but Result = 0 and entity was not created.
Why? Please help!

Re: Terrain bugs

Posted: Tue Jul 23, 2013 7:23 am
by Rings
@lexicon:

try to create new topics for different questions please.
thx

Re: Terrain bugs

Posted: Tue Jul 23, 2013 9:27 am
by applePi
Hi Lexicon
you write FinishMesh(#False), to create entity the FinishMesh should be true. FinishMesh(#True)

Re: Terrain bugs

Posted: Thu Jul 25, 2013 4:23 pm
by applePi
refering to Comtois example http://www.purebasic.fr/english/viewtop ... 34#p418511
seems to me the only way to texture a sphere room inside different than outside is to use two spheres with slight different radius centered to the same point and textured with different textures and then i use
MaterialCullingMode(tex1, #PB_Material_NoCulling )
MaterialCullingMode(tex2, #PB_Material_NoCulling )
Edit: the second line not necessary for the outside sphere unless we want to make a tour between the two walls

Code: Select all

;
IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY, SpriteX, SpriteY 

Global Dim MeshDataVertex.PB_MeshVertex(0)
Global Dim MeshDataIndex.PB_MeshFace(0)

If InitEngine3D()
  
  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Models", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/Desert.zip", #PB_3DArchive_Zip)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    
    ;- Ground
    ;
    CreateMaterial(0, LoadTexture(0, "Dirt.jpg"))
    CreatePlane(0, 1500, 1500, 40, 40, 15, 15)
    CreateEntity(0,MeshID(0),MaterialID(0))
    EntityRenderMode(0, 0)
    
    CreateCube(1, 50)
    CreateEntity(1, MeshID(1), GetScriptMaterial(1, "Color/Blue"), 0, 50, 0)
    
    ;Sky
    CreateMaterial(2, LoadTexture(2, "DosCarte.png"))  
    CreateMaterial(3, LoadTexture(3, "Geebee2.bmp"))
    MaterialCullingMode(2, #PB_Material_NoCulling  )
    MaterialCullingMode(3, #PB_Material_NoCulling  )
    CreateSphere(2, 600)
    CreateEntity(2, MeshID(2), MaterialID(2), 0, 300, 0)
    CreateSphere(3, 610)
    CreateEntity(3, MeshID(3), MaterialID(3), 0, 300, 0)
    
    ;- Camera
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 120, 500, #PB_Absolute)
    CameraBackColor(0, $FF)
    
    ;- Light
    ;
    CreateLight(0, RGB(255, 255, 255), -40, 100, 80)
    AmbientColor(RGB(80, 80, 80))
    
    
    
    Repeat
      
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX()/10 
        MouseY = -MouseDeltaY()/10
      EndIf
      
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -10
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = 10
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -10
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = 10
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld() 
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End