you don't need to draw the objects but yes if your objects are more mesh intensive it will of course take longer, i used some basic cubes and capsules and it doesn't take that long to place up to around 30k objects but i did find it crashes if you try to loop more than 60k objects (no error given, just a blank runtime error screen, i assume it's running out of memory even though i delete all the objects each time)
based on my heightmap i was placing just over half the objects but even if the reported timer felt a little generous it was still quick for a loading time.
(press space bar to increase the object limit)
// Project: procedural map
// Created: 2019-09-02
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "procedural map" )
resox = 1920
resoy = 1080
aspect# = (resoy * 1.0/resox)
SetWindowSize( resox, resoy, 1 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( resox, resoy ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetCameraPosition(1,1024,1500,1024*aspect#)
SetCameraLookAt(1,1024,0,1024*aspect#,0)
SetCameraRange(1,0.1,99999)
objectCount = 60
map = CreateObjectFromHeightMap("heightmap.png",2048,81,2048*aspect#,0,1)
SetObjectColor(map,0,100,0,255)
arbr1 = CreateObjectBox(10,10,10)
SetObjectColor(arbr1,255,0,0,255)
arbr1b = CreateObjectCapsule(10,30,10)
SetObjectColor(arbr1b,0,0,255,255)
restart:
ResetTimer()
timer# = 0.0
compteur_sapin = 0
firstID = 0
lastID = 0
For i=1 to objectCount
x#=random(1,2048)
z#=random(1,2048*aspect#)
y#=GetObjectHeightMapHeight(map,x#,z# )
hauteur_sapin#=random(0.55,3)
if y#>50 and y#<63 // ON FIXE L'ALTITUDE de generation
arbr1C=CloneObject(arbr1)
if firstID = 0 then firstID = arbr1bC
//arbr1C=LoadObject("assets/tree1b.obj",2)
SetObjectPosition(arbr1C,x#, y#, z# )
SetObjectScale (arbr1C, 1, hauteur_sapin#, 1)
arbr1bC=CloneObject(arbr1b)
//arbr1bC=LoadObject("assets/tree1b.obj",2)
SetObjectPosition(arbr1bC,x#, y#, z# )
SetObjectScale (arbr1bC, 1, hauteur_sapin#-0.5, 1)
//SetObjectCastShadow( arbr1C, 1 )
//SetObjectCastShadow( arbr1bC, 1 )
lastID = arbr1bC
compteur_sapin=compteur_sapin+2
Endif
Next i
timer# = GetMilliseconds()/1000.0
do
if GetRawKeyPressed(27) then end
Print(ScreenFPS())
Print("Took "+str(timer#,2)+" s to load "+str(compteur_sapin)+" objects out of "+str(objectCount*2))
print("drew "+str(GetPolygonsDrawn())+" polygons")
if GetRawKeyReleased(32)
for a = firstID to lastID
if GetObjectExists(a) then DeleteObject(a)
next a
sync()
inc objectCount, objectCount
if objectCount > 29999 then objectCount = 29999
goto restart
endif
sync()
loop
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu