Including 3D objects as binary resources

This operation is quite simple since the HB++ IDE lets you embed binary resources in your project, simply set the Type and the ID of each resource:

 

Here is a code sample that creates "on the fly" a database with a 3d scene included as binary resources:

Public Function CreatePDB(dbName As String, dbType As String, ResType As String, ResStartIndex As Integer, ResEndIndex As Integer)As Boolean
Dim i As Integer
Dim Res As StreamRecord
Dim PDB As new StreamFileDB
  TRY
    'Create database with default creator
    PDB.Open dbName,hbModeCreateAlways+hbModeWrite ,dbType
    'Get resource reference
    For i=ResStartIndex to ResEndIndex
      Set Res = App.Resource(ResType,i)
      Res.SeekToBegin
      PDB.Write Res
    Next
    CreatePDB=True
  CATCH
    CreatePDB=False
  END CATCH
  Set Res=Nothing
End Function 

 

This code is used in the fourth sample project.

You can also use the StreamComposite class for merging several resources and thus use this class to load a large scene without the need of a database.