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++) {

it comes down to this logic, plus some “magic”

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


(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)