BOIDS + Kinect input

Hi

something i have been working on.

Kinect is OpenNi

http://www.deathbypixel.co.uk.php5-21.dfw1-2.websitetestlink.com/?p=1221

When kinect senses input within 2.5 metres ish, it turns off boids flack algorithm and turns on flee. This is from the origin, but could be changed to be from the actual sensed input vector point (one of the things i want to do).

https://github.com/gonzokawasaki/ofxkinectboids

shatner

Hi can someone advise please?

I am building on the above example and adding more functionality

http://www.youtube.com/watch?v=QAu6RzfOiTs&feature=youtube-gdata-player

I now have a version with vertex shaders for the boids and am now trying to create a version that uses the camera ribbon example to create 3D painting from each boid.

My problem is this can i create a 2D array of points? ie i have say 20 boids each of which needs an array of ever increasing points. Can i create a 2D array that will do this? Should i instead create an object? (not too familiar with working with objects).

I am guessing that the 2D array would effectively be of mixed types ie int and vectors. Can that be done?

I usually work in C# or js rather than C++ so i am not too sure how to go about this. Alternatively is there a better way to do this?

any advice or help appreciated.

shatner

OK i have done some research and from what i understand i cant create a mixed array.

So in that case I imagine that the sensible alternative is to turn each boid into an object with a vertex member variable and iterate through these objects?

Does that sound right??

I know i am talking to myself here:)

but i have solved it i think.

created an object (not done that before) with a vertex var.

i will cycle through the objects and access the vertex arrays in them.

You can’t mix objects in typed containers, however, you can have your objects inherit from the same interface (pure virtual class), and then cast them as you take them out of container into a desired concrete class. Or, you could right a wrapper around your mixed objects and keep those wrappers in the typed containers – it seems you figured the latter yourself.

–8

Thanks for that

yeah well i am looking at several solutions at the moment. I wanted to create an object array and then include a vertex array member in each object. Iterate through the objects and then create the meshes for each one.

I kept getting an error - so tried a really bad procedural hack instead and seem to get a similar error.

I am working on a macbook pro and i think i am getting some kind of error telling me that i cant draw more than 1024.

The console says
Maximum number of output vertices support is: 1024

i get the thread screen in xcode with the assembler code blah blah.

Does anyone know about this error?

Code extract as follows.

int a = points1.size();

points1.push_back(ofVec3f(boids[0].position.x,boids[0].position.y,boids[0].position.z));

for(int i = 1; i < a; i++){
ofSetColor(20.0,100.0,240.0);

ofVec3f thisPoint = points1[i-1];
ofVec3f nextPoint = points1[i];

ofVec3f direction = (nextPoint - thisPoint);

float distance = direction.length();

ofVec3f unitDirection = direction.normalized();

ofVec3f toTheLeft = unitDirection.getRotated(-90, ofVec3f(0,0,1));
ofVec3f toTheRight = unitDirection.getRotated(90, ofVec3f(0,0,1));

float thickness = ofMap(distance, 0, 4, 3, 2, true);

ofVec3f leftPoint = thisPoint+toTheLeft*thickness;
ofVec3f rightPoint = thisPoint+toTheRight*thickness;

//add these points to the triangle strip
mesh1.addVertex(ofVec3f(leftPoint.x, leftPoint.y, leftPoint.z));
mesh1.addVertex(ofVec3f(rightPoint.x, rightPoint.y, rightPoint.z));

mesh1.draw();

i really appreciate any help. i am creating this piece for an exhibition and the idea is that each boid paints a trail in 3D. I imagine if this is a harware limit then a shader would encounter the same problem.

Can i maybe use openGL and push the extra geometry instead of using mesh.draw? would that solve the problem??

I am not a GL expert and i would really appreciate it if someone know the answer to this.

thanks

gonzo

Sounds like a hardware limitation http://www.opengl.org/discussion-boards/showthread.php/175003-Geometry-Shader-Max-output-vertices, which is dependent on how large your output data for a single vertex is.

In the link above they discuss a geometry shader, which, I think, will generate new geometry (new vertices). However, if you are not generating new geometry (say, you are using pixel shader), it seems that you may avoid hitting this limitation.

–8

OK thanks

I have never heard of this kind of hardware restriction before. I am trying to find an a way around this problem.

Pixel shaders handle as many points as there are of those in the texture (millions) on commodity hardware.

-8

check out this video clip. I think this is a GL problem, to do with

http://www.youtube.com/watch?v=074yPp-SWV8

I am guessing that it is something to do with this
http://www.openframeworks.cc/documentation/3d/ofMesh.html

this is the offending code i think. i dont know how i can seperate out these mesh.draw commands.

//end the shape
ofSetColor(20.0,100.0,240.0);
mesh1.draw();

ofSetColor(100.0,250.0,250.0);
mesh2.draw();

I was making a stupid code error all solved now.

I intend to add more features such as maybe 8-12 boids but now the main code problems are fixed.

https://www.youtube.com/watch?v=wt5EAJGtEeM