About the particle monkey code problem

I need help Can someone explain to me what this code is doing?

1 Like

From a quick look eighter something magic or something strange.
For sure nothing common.

Whats strange is, that the finVert buffer is sized one vec3 larger then the other vertex data buffers
In the last element the world position gets written.

At least inside that function the value is never accessed.

As far i know there is also no way the value could get accessed on the shader side, but i would have to check how the indices are calculated and take a look at the shaders.

Do you search for something specific?

I give it a look when i am at the pc.

1 Like

Thank you for your reply

So this wasnā€™t an area of code that I wrote and I havenā€™t experimented much with it. Taking a quick lookā€¦ iā€™d be surprised if that class works at all. It SHOULD emit meshes as particles, but it doesnā€™t look like it would do that correctly.

1 Like

It can actually do that by sending out grids in the form of particles.
Iā€™m currently using it but I think there are some problems with this class.

When I set emitterMesh. SetEmitFromWorldSpace (false);

ParticleDataTemplateMesh. Java has some problems

Itā€™s more the boundsā€¦ I think it would error out because itā€™s not sizing the buffers correctly. Iā€™ll have to look into the set emit from world space later. It probably just needs the code copied from the other Particle Mesh classes.

Having larger buffers then you need will not cause any issues. Even setting indices that are out of bounds will not cause opengl to crash.
i guess it is defined as ā€œundefined behaviourā€

The code actually creates a new mesh with numParticle times the base mesh in it.

The question is, whats wrong? Whats the error?

1 Like

Itā€™s a float buffer so it actually needs to be MeshVertCount * numParticles * 3.

no, the name is misleading. it accesses the position buffer directly, so .capacity() includes the * 3

        FloatBuffer sourceBuffer;
        FloatBuffer targetBuffer = BufferUtils.createFloatBuffer(sourceBuffer.capacity()*numParticles);
        for (int j = 0; j < numParticles; j++) {
            for (int i = 0; i <sourceBuffer.capacity(); i++) {
                targetBuffer.put(sourceBuffer.get(i));
            }
        }

it comes down to this logic, plus some ā€œmagicā€

//Add:
One hell of an example on when to use instancing instead of batching

1 Like

Thank you for your reply

Oooo you are right. Missed that. Yea, this is an area that really should use instancing.

I seem to understand some of the key information about this class.
But this class doesnā€™t seem to be what Iā€™m looking for.
To my surprise, this class seems to be unusable and yet I keep using it with no errors.

Here are the questions I want to ask

I want to know the SetEmitFromWorldSpace of Particle monkey Whether it corresponds to the function.

SetEmitFromWorldSpace =false; the position of the particles seems to be wrong.

Maybe itā€™s my misunderstanding, but I hope that when ā€œSetEmitFromWorldSpace =falseā€, set to false, the particles will emit in local space and when the emitter is moved,so are all the particles that were emitted previously

Which emitter shape are you using?

1 Like

EmitterMesh

ļ¼ˆThe vast majority of the conversation is done through translation software There may be communication differencesļ¼ŒPlease point out if you donā€™t understand anything about my questionsļ¼ŒThank you for your helpļ¼‰