Problem with the maximum number of 3D objects.

Previous topic - Next topic

SnooPI

Normally, GENX_OBJ() only returns -1 if there is not enough memory but that is not the case.
It seems that GLBASIC don't allow more than 4096 3d object.

------
EDIT
------
In fact, the GENX_OBJ()  function gives 4095 at the beginning and decreases with each call, it has nothing to do with the memory, this function is probably just in relation to a memory array of 4096.
It is very restrictive that the maximum number of objects is not related to the available memory (as the help says), but only with a precalculated memory array, because a 3D world can often contain more than 4096 objects  :(

Hemlos

actually its 4224=4096+128 objects, but whos counting anyways? lol

i realize this defeats the purpose of having no extra files to load, yet...
u can reuse object ID numbers, and can save infinite amounts of objects to drive.

Code (glbasic) Select

INC num, 1 ////etc etc etc
CreateCube(num, sz)

// ------------------------------------------------------------- //
// -=#  CREATECUBE_NO_TEXTURE: Fast but without texture  #=-
// ------------------------------------------------------------- //
FUNCTION CreateCube_no_texture:  num, sz
// Diese Variablen sind als LOCAL definiert:
// num, sz,

// 2-4-3-1
// | | | |
// 6-8-7-5
//   | |
//   6-5
//   | |
//   2-1
//   | |
//   4-3 Strip: 4 3 8 7 5 3 1 4 2 8 6 5 2 1

// Normals + culling is wrong!!

LOCAL s[], n, m, x,y,z
DIM s[14]
s[0]=4; s[1]=3; s[2]=8; s[3]=7; s[4]=5
s[5]=3; s[6]=1; s[7]=4; s[8]=2; s[9]=8
s[10]=6;s[11]=5;s[12]=2;s[13]=1
X_OBJSTART 0
FOR m=0 TO 13
n=s[m]-1
x = MOD(n, 2)
y = 1-INTEGER(n/4)
z = 1-MOD(INTEGER(n/2), 2)
X_OBJADDVERTEX  x-.5, y-.5, z-.5, 0, 0, RGB(255,255,255)
NEXT
X_OBJEND
X_SAVEOBJ "Filename" + num + ".png", 0
ENDFUNCTION


Bing ChatGpt is pretty smart :O

SnooPI

Hmm, I think you didn't understand the problem, but perhaps I'm poorly explained.
While you were answering me I wrote a modification in my first message, maybe it's clearer no?

If you exceed the number of 4096 objects in your program, your program crashes completely.

Hemlos

Bing ChatGpt is pretty smart :O

SnooPI

Yes  :(

By cons, you are right in my test program it's not 4096 but 4224 the max  :D  :S 

I'm going to bed, this bug gives me a headache :sick:

Thank You Hemlos.


spacefractal

confirmed.

howover if you have access to the source code and download it. Not sure why Gernot limit it, since its could been higher. its currectly limited to 4096. If you ask me, this should been possible to change to whatever limit, so its a array issue.

But if you have download the source code, you can change this line in the file rainbows3d.h to a higher value:

#define GLR_MAX_OBJECTS      0x1000

0x1000 is set to extractly 4096 and not sure its possible to REDIM it.

You can actuelly download the source code and recompile it.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

SnooPI

Indeed, recompiling the source code could be a good idea, but my code will not be portable from one version to another  :(
Moreover, it's unfortunate that memory allocations are static and not dynamic (no difference between a cube or a complex object) and I guess it's the same for all other resources: sprites, sounds, ... 

For now I think I will dynamically allocate / deallocate objects in real time in my program (trying not to have too much slowdown).

Thanks for the confirmation Spacefractal.

spacefractal

There is a _build.bat for every platform, which will compile the whole platform. Then done then you can build as normal. There is a limit of 4096 objects in this case, but would been nice if you can set it  to any number by your self. but for now, this is the way for go.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

You need more than 4000 different 3D objects? Really?

SnooPI

Yes, it's not so strange :)

Here are some reasons:
1 / We can only assign one texture per object (it's also a problem for the lightmapping).
2 / You have implemented a frustrum optimization by object (thanks, needless to do it), so it's interesting for speed.
3 / For example, games like Minecraft require a lot of objects.
4 / Moreover, what is important for the speed (and the memory) in Opengl is not the number of objects but the complexity of each object.

But rest assured, on the maps where I need more, I will assign them on the fly (I hope without much slowdown).

Thank you for your interest and long life to GLB on Steam  :good:

--- EDIT ---

Hmm ... after Gernot's intervention, I thought about it and maybe I was wrong.
I'm looking for too much speed, I'll see my algorithm again tomorrow.

Thank you Gernot you helped me without even answering me  :D

Kitty Hello

You don't need a separate object if you want to switch the texture.

SnooPI

Yes, of course, but not the coordinates of the texture, as I have said, it's a problem for the lightmapping.
In fact, I had:
- different objects.
- similar objects but with different texture coordinates.
- but also similar objects with the same texture coordinates ... it's stupid  =D (especially for the low speed gained during the display).

I take this topic to ask you if one day the problem to make a lightmapping will be solved?
In summary, the possibility to assign multiple textures with different coordinates on the same object.
I think the lightmapping is important in a 3D game for a good rendering without asking the GPU too much (especially on mobile).

spacefractal

Snoopy, can you use the source code. its a easy fix with the total number objects really. Its can been happens more than 4096 is required throught if speed is not a issue.

Just change the define and rebuild it with the platforms _build.bat and then you can have more than 4096 objects.

Source Code is possible to download.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

SnooPI

No, but it's ok now, it was just a cloning problem with objects and I took the opportunity to ask for information on multitexturing.
But you're right, one day I will have to look at the source code.

nabz32

I would love to be able to raise that macimum obkect number for my game.
Where is that source code?  :enc:

I need many objects, because i want to be able to ghost individual parts of my map, whichbis made of polygons.
I even have mechanisms in place, that parse the entire map and looks which polygons are the same ( vertex and texture coordinate wise) so i dont need to store duplicates in memory.
But in the worst case, no polygon on the map is the same.

Would love to crank the tile count up to 60x60 tiles but it is not possible at a limit of 4200 objects.