vertices

Polygon Cube w/o cross beam

scalf's picture

Hello,

I am wondering how to render a cube without the diagonal cross section?

Did this somehow change recently? I have been able to do it before but it seems now that it comes standard with the diagonal cross section. I need to get rid of this for aesthetic reasons. How can I do this like as in the 1024 camera perspective example?

http://1024d.wordpress.com/2012/01/03/_1024_cameracorrection-qcplugin/#c...

How to output a vertices structure from a custom plugin (with code)

LukeNeo's picture

Hi to all, I'm trying to extend my iniTree plugin with a custom plugin that outputs a structure with vertices position every frame, as suggested by gToledo. To try this kind of output I tried to modify my drawTest plugin so instead of render vertices it outputs vertices position.. but I cannot make it work properly. This is my approach:

  • vertices positions are stored in a float vector
float   v[VSIZE][3];
  • vertices positions are copied every frame in a NSArray (output_struct) made of NSArrays (currVertex) in this way:
   for(int x=0;x<numV;x++){
      [currVertex removeAllObjects];
      [currVertex addObject:[NSNumber numberWithFloat:v[x][0]]];
      [currVertex addObject:[NSNumber numberWithFloat:v[x][1]]];
      [currVertex addObject:[NSNumber numberWithFloat:v[x][2]]];
      [currVertex addObject:[NSNumber numberWithFloat:1.0]];
      [outputVertices addObject:currVertex];
   }
 
      //create output structure
   self.output_struct = [NSArray arrayWithArray:outputVertices];

It seems to output the same kind of result of a mesh importer (you can see it in outputs img), but for some reason my plugin output doesn't work. In the zip you can find xcode project, a composition example and a dae mesh to test it.

I think I don't build the structure in the correct way. For example, in the Apple developer guide I read that we must use NSDictionary to output a structure, but I can't use it in the correct way. Anyone knows the correct way to output a structure from a custom plugin?

Rendering huge amount of vertices (VBO)

LukeNeo's picture

Hi to all, I'm developing a plugin that allows you to render a set of vertices randomly distributed in space. I’d like to draw a huge amount of vertices at the same time: to do this I tried to use OpenGL Vertex Buffer Object (VBO), because I read that it allows vertex array data to be stored in high-performance graphics memory on the server side and promotes efficient data transfer.

This is my approach:
* Generate a new buffer object with glGenBuffersARB().
* Bind the buffer object with glBindBufferARB().
* Copy vertex data to the buffer object with glBufferDataARB().

so in my startExecution plugin function I wrote:

  1. - (BOOL) startExecution:(id<QCPlugInContext>)context
  2. {
  3. CGLContextObj cgl_ctx = [context CGLContextObj];
  4.  
  5. glGenBuffersARB(1, &VBUFFERNAME);
  6. glBindBufferARB(GL_ARRAY_BUFFER, VBUFFERNAME);
  7. //vcArray is defined as float vcArray[numV*3]
  8. glBufferDataARB(GL_ARRAY_BUFFER, sizeof(vcArray), vcArray, GL_DYNAMIC_DRAW_ARB);
  9. glVertexPointer(3, GL_FLOAT, 0, 0);
  10.  
  11. return YES;
  12. }

and in my execute plugin function I do this:
* Update vertices in vcArray using glBufferSubDataARB()
* Draw them using glDrawArrays()

  1. - (BOOL) execute:(id<QCPlugInContext>)context atTime:(NSTimeInterval)time withArguments:(NSDictionary*)arguments
  2. {
  3. CGLContextObj cgl_ctx = [context CGLContextObj];
  4.  
  5. //update vcArray vertices
  6. updateVertices();
  7.  
  8. glEnableClientState(GL_VERTEX_ARRAY);
  9. glBindBufferARB(GL_ARRAY_BUFFER, VBUFFERNAME);
  10. {
  11. glDrawArrays(GL_LINE_STRIP, 0, numV*3);
  12. [self calcVertices];
  13. glBufferSubDataARB(GL_ARRAY_BUFFER, 0, sizeof(vcArray), vcArray);
  14. }
  15. glDisableClientState(GL_VERTEX_ARRAY);
  16. glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
  17.  
  18. return YES;
  19. }

..the problem is that I can’t get noticeably performance improvements than the immediate mode rendering: they are the same! For example, using VBO I got 60 FPS with 2.500 vetices, 40 FPS with 5000 verices, and 10 FPS with 20.000 vertices.. and that are the same performance I got in immediate mode, using simple code like these:

  1. glBegin(GL_LINE_STRIP);
  2. for(x = 0; x<numV; x++){
  3. glVertex3f(v[x][0], v[x][1], v[x][2]);
  4. }
  5. glEnd();

..am I missing something in the VBO approach? Why I can’t get performance improvements?

Thank you, Luke

Draw QCMesh (Composition by gtoledo3)

Author: gtoledo3
License: (unknown)
Date: 2010.10.04
Compatibility: 10.6
Categories:
Required plugins:
(none)

This composition allows for drawing of QCMesh with normals that work with the lighting environment, mesh that works with shadows, and also that doesn't cause any weird evaluation side effects (eg., other stuff in the composition ceasing to evaluate).

It features non contiguous drawing, all stock patches, ability to change color at any time (eg., typical "paint" feature), and line and point sprite modes (stock).

Notes:

-Point Sprites have an aberration rendering with shadows where the shadow engine seems to think they are "larger" than they really are. This is an Apple bug, I believe, can't do anything about it.

-I've "deprecated" the Mesh filters (this composition is somewhat related to the "wiggle draw" I posted). When you "draw" while a filter is engaged, normals can break. This makes no sense given the patch ordering, and again, I believe this is an Apple/ QC mesh bug that I can't particularly do anything about.

-"Double clicking" to clear reduces queue count to 1 instead of 0, but this isn't really perceivable in visual result. This is to suppress a QCMesh log error when mesh creator is connected to a QCMesh render and while input ports are attached, but no structure is being fed (which I believe shouldn't happen to begin with, but log errors annoy me, so I did this to suppress it even though I believe it to be questionable. I would rather leave this value at 0 in a perfect world).