[Solved]PB5.10 Beta8 Cannot compile 65535 face barrier

Everything related to 3D programming
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[Solved]PB5.10 Beta8 Cannot compile 65535 face barrier

Post by IdeasVacuum »

The max number of faces in a mesh is 65535. I'm sure that's fine for games because you'll be trying to keep the face count down to the minimum possible. In engineering however, STL files (shapes defined by triangular planar faces) can be huge, far greater than 65535. The CAD apps that handle these files can display them without a problem, so long as the PC has an average amount of grunt. They are using OpenGL for display. Can we do it with PB?
Last edited by IdeasVacuum on Thu Feb 14, 2013 3:19 pm, edited 3 times in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Breaking the 65535 face barrier

Post by Comtois »

Extract from ogre
32-bit indexes are not supported on all cards and will only be used when required, if an index is > 65535.
So it should be possible, never tested.
Please correct my english
http://purebasic.developpez.com/
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Breaking the 65535 face barrier

Post by Comtois »

just tested, yes it's possible

In this example, i have 4202500 index.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Mesh Manual - Flag 
;
;    (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
; 
;

IncludeFile "Screen3DRequester.pb"

#CameraSpeed = 1
#NbX=1024
#NbZ=1024 

Global.f AngleVague, WaveFrequency, WavePeriodX, WavePeriodZ, WaveAmplitude
WaveFrequency=3  ;=waves/second
WavePeriodX  =9  ;=1/Wave lenght
WavePeriodZ  =11 ;=1/Wave lenght
WaveAmplitude=3

Define.f KeyX, KeyY, MouseX, MouseY

Declare UpdateMatrix()
Declare CreateMatrix()

If InitEngine3D()
  
  Add3DArchive("../Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("../Data/Packs/skybox.zip", #PB_3DArchive_Zip)
  Add3DArchive("../Data/Scripts", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    ;-Material  
    GetScriptMaterial(1, "Scene/GroundBlend")
    MaterialCullingMode(1, 1)
    
    ;-Mesh
    CreateMatrix()
        
    ;-Camera
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,0,50,80, #PB_Absolute)
    CameraLookAt(0, 0, 0, 0)
    CameraBackColor(0, RGB(90, 0, 0))
    CameraRenderMode(0,#PB_Camera_Wireframe)
    ;-Light
    CreateLight(0, RGB(255, 255, 255), 20, 150, 120)
    AmbientColor(RGB(90, 90, 90))
    
    ;- Skybox
    SkyBox("stevecube.jpg")
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)
        MouseY = -(MouseDeltaY()/10)
      EndIf
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)  
            
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End

;-Procédures
Procedure DrawMatrix()
  Protected.l a, b, Nb
  Protected.w P1, P2, P3, P4
  
  For b=0 To #Nbz
    For a=0 To #NbX
      MeshVertexPosition(a, 0, b) 
      MeshVertexPosition(a+1, 0, b) 
      MeshVertexPosition(a+1, 0, b+1) 
      MeshVertexPosition(a, 0, b+1) 
      MeshFace(Index, Index + 1, Index + 2)
      MeshFace(Index, Index + 2, Index + 3)
      Index + 4
    Next a
  Next b
  ProcedureReturn Index
EndProcedure  

Procedure CreateMatrix()
  
  CreateMesh(0, #PB_Mesh_TriangleList, #False)
  Index = DrawMatrix()
  FinishMesh(#False)
  SetMeshMaterial(0, MaterialID(1))
  
  CreateNode(0)
  AttachNodeObject(0, MeshID(0))
  ScaleNode(0, 2, 2, 2)
  MessageRequester("Index", Str(Index),0)
EndProcedure
Please correct my english
http://purebasic.developpez.com/
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Breaking the 65535 face barrier

Post by PMV »

IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Breaking the 65535 face barrier

Post by IdeasVacuum »

...so long ago, I'd forgotten about the original post. There were other limitations at the time so I decided to mothball my project. It's not being resurected but the need for very large mesh handling has come up again.

Thank you for the example Comtois.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Breaking the 65535 face barrier

Post by IdeasVacuum »

PB5.10 Beta8 x86 WinXP 32bit

Line 44 of the above example halts the compile: "MaterialCullingMode() is not a function, array, list, map or macro" :?

Edit: Oh, I get the same fail message, Line 111, MeshVertexPosition(). So, something seems to be missing from the PB install?

Edit2: Constant not found: #PB_Mesh_TriangleList
...yet apparently that is fixed? [Done] 5.10 b1 : Missing Constants

Edit3: CreateMesh(0, #PB_Mesh_TriangleList, #False) Incorrect number of parameters
Help shows 1 parameter: CreateMesh(#Mesh)

I'm at a complete loss :shock:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by applePi »

IdeasVacuum , i have the same system PB5.10 Beta8 x86 WinXP 32bit. i saved the file to Examples\3D\Demos , and the code above runs okay for me.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by IdeasVacuum »

Hi ApplePi, I don't think that where the example file is saved is making a difference in this case (I'm saving it in my regular projects file and other non-3D projects are compiling fine from there).

I'm thinking that perhaps there is something missing or inadvertently out of date in the Beta8 install - I installed Beta8 as a fresh, seperate install. Did you also do that, or did you install over an existing PB5.x?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by Fred »

Works here with a freshly installed 5.10b8
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by applePi »

IdeasVacuum , usually i rename the purebasic folder to something else, then i install the new version to c:\purebasic . and when i want the older version i renamed it again to purebasic after renaming the more recent to purebasic_new .
i never uninstalled purebasic, i just rename the older and install the new.
for a possible info :my graphics card Geforce 210
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by IdeasVacuum »

Clutching at straws here. So, we have established that there is nothing wrong with the code, the functions are correct for Beta8. The only significant difference between my setup and ApplePi's setup is that I have un-installed the previous Betas I tried (the most recent Beta on my PC was Beta5).

I'm going to un-install Beta8, whose path is currently C:\Program Files\PureBasic510Beta8\
I'll re-install without editing the destination path in the same way ApplePi has done.

Edit: OK, certainly was something wrong with my install, looking better.

Still got a Compiler issue though, MaterialCullingMode(1,1) fails: "[ERROR] The specified #Material is not initalised"

The proceding line: GetScriptMaterial(1, "Scene/GroundBlend") - I can't find "Scene/GroundBlend", where is it?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: PB5.10 Beta8 Cannot compile Breaking the 65535 face barr

Post by PMV »

IdeasVacuum wrote:The proceding line: GetScriptMaterial(1, "Scene/GroundBlend") - I can't find "Scene/GroundBlend", where is it?
In examples directory (3D) ... thats why it is better to save it there :lol:
Post Reply