Category Archives: Feldman Project

Phil 3.8.12

7:30 – 11:00 VISIBILITY

  • Demo prep. See Mike’s notes for more detail

11:00 – 4:00 FP

  • Now that I have the pick matrix worked out, I’m going to see how to ask the pipeline if any pixels have been drawn. Also need to see how to prevent the test drawing from going to the render buffer
  • Generating query indices and deleting them in cleanup()
  • Added a pickRender()  and pickResult() method to DrawableObject
  • Picking works, but seems to slow down the display. Also, GL_QUERY_RESULT_AVAILABLE always returns zero, even if there is a result. And just to make things a little weirder, the call glGetQueryObjectiv(drawQuery, GL_QUERY_RESULT_AVAILABLE, &result) does not slow down the display, but the following almost identical call glGetQueryObjectiv(drawQuery, GL_QUERY_RESULT, &result) does. No ideas about this right now.

 

Here’s the code in question

static enum TRANSFORM_MODE{UNAVAILABLE, HIT, MISS};
TRANSFORM_MODE pickResult(){
	GLint result;

	glGetQueryObjectiv(drawQuery, GL_QUERY_RESULT_AVAILABLE, &result);
	if(result == 0)
		return UNAVAILABLE; // always returns this

	glGetQueryObjectiv(drawQuery, GL_QUERY_RESULT, &result); // slows down rendering once called.
	if(result)
		return HIT;
	else
		return MISS;
};

Tom DeVito 3.7.2012

Start: 10:00

  • Added voltage regulator circuit to the schematic.
  • I couldn’t do the amps circuit one sided so I had to add the bottom layer.
  • The I2C rheostats have two jumpers to select addresses.
  • Realized that the circuits are going to be bigger then their footprint because of the mounting board.  Added space so this should be okay.
  • I still have to work out a couple things with the amps but I am almost done.  Once I am done I will test the circuit using the power adapter as a power supply to make sure it works and double check everything before ordering.

End: 6:00

Tom DeVito 3.6.2012

Start: 10:00

  • Took me a while to figure out where the power jack footprint was in the pad2pad software.  I ended up having to drag it in from the folder as I couldn’t find where it was in the UI.
  • Apparently there are two types of power jacks.  I have to make sure we get the one where the center pin is positive.  Some have negative pins
  • Did an experiment with testing currents of both the power supply and our AC adapters.  i = V/R and the resistance formulas seems like a simple enough equations but somehow I missed the concept behind it.  Basically current is more like a pull caused by the lack of resistance.  The load resistor is what pulls current into the loop.  This could technically be anywhere in the circuit but the placement can have a great affect on what you are trying to do.  In the case of my test circuit, this resistor is right before the LED in order to protect it from getting too much current.  If I branch off from the node where the positive terminal of this resistor starts and add another circuit in parallel, this does not change the properties of the loop with the LED in it but makes the current pulled by the entire circuit with the new branch increase.
  • A key concept I keep forgetting is that current flows from negative to positive.  This means that a load resistor on the positive side of a circuit is  not really preventing power from going in, but pulling it from the negative side in.
  • Started drawing the circuit for the reheostats and the pre-amps.

End: 6:00

Phil 3.6.12

8:00 – 3:30 FP

  • Uniform Buffer Objects! Whee!
    • Urk: “Any type consuming N bytes in a buffer begins on an N byte boundary within that buffer. That means that standard GLSL types such as int, float, and bool (which are all defined to be 32-bit or four-byte quantities) begin on multiples of four bytes. A vector of these types of length two always begins on a 2N byte boundary. For example, that means a vec2, which is eight bytes long in memory, always starts on an eight-byte boundary. Three- and four-element vectors always start on a 4N byte boundary; so vec3 and vec4 types start on 16-byte boundaries. Each member of an array of scalar or vector types (ints or vec3s, for example) always start boundaries defined by these same rules, but rounded up to the alignment of a vec4. In particular, this means that arrays of anything but vec4 (and Nx4 matrices) won’t be tightly packed, but instead there will be a gap between each of the elements. Matrices are essentially treated like short arrays of vectors, and arrays of matrices are treated like very long arrays of vectors. Finally, structures and arrays of structures have additional packing requirements; the whole structure starts on the boundary required by its largest member, rounded up to the size of a vec4.
    • Need to write up a class that handles shared objects. Should be a variant on the dictionary pattern
      • DataElement class includes name, type, size, etc
      • UniformBlock class
        • Defines the name of the Uniform Block
        • Makes sure that there is room for this block, and the binding
          glGetIntegerv(GL_MAX_UNIFORM_BUFFERS)
          glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS)
        • allocates the memory
        • gets the block index
          glGetUniformBlockIndex(GLuint program, const GLchar * uniformBlockName);
        •  returns pointers to data
        • handles the writes into memory
        • bind to the shader program (I think)
          void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
  • Advanced Geometry Management (Chapter 12)
    • Queries (picking, hopefully)
      • Questions in OpenGL are represented by query objects, and much like any other object in OpenGL, query objects must be reserved, or generated. To do this, call glGenQueries, passing it the number of queries you want to reserve and the address of a variable (or array) where you would like the names of the query objects to be placed:
        void glGenQueries(GLsizei n, GLuint *ids)
        Gluint myQueries[10];
        glGenQueries(10, myQueries);
        for(int i = 0; i < 10; ++i){
            if(myQueries[i] == 0)
                // throw an error
        }
        // run queries
        glBeginQuery(GL_ANY_SAMPLES_PASSED, myQueries);
        glEndQuery(GL_ANY_SAMPLES_PASSED);
        
        // usually this should be available immediately, but be careful to handle the case if it isn't
        glGetQueryObjectuiv(myQueries[0], GL_QUERY_RESULT_AVAILABLE, &result);
        if(result == GL_TRUE)
            glGetQueryObjectuiv(myQueries[0], GL_QUERY_RESULT, &result);
        // do something based on the result
        // then when done...
        glDeleteQueries(10, myQueries); // free up space for more queries
      • So the way picking would seem to work would be to set the viewport so that it’s slightly larger than the cursor, then render bounding boxes (using glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)) inside a loop of questions, then read back (and wait for) the results of the question. If the object is visible in the small FOV, then we can regard it as picked.
        • Setting up picking:
          	GLint viewport[4];
          	float ratio;
          
          	glSelectBuffer(BUFSIZE,selectBuf);
          
          	glGetIntegerv(GL_VIEWPORT,viewport);
          
          	glRenderMode(GL_SELECT);
          
          	glInitNames();
          
          	glMatrixMode(GL_PROJECTION);
          	glPushMatrix();
          	glLoadIdentity();
          
          	gluPickMatrix(cursorX,viewport[3]-cursorY,5,5,viewport);
          	ratio = (viewport[2]+0.0) / viewport[3];
          	gluPerspective(45,ratio,0.1,1000);
          	glMatrixMode(GL_MODELVIEW);
        • The source for gluPerspective() is here
      • Another way of doing picking – http://www.gpucomputing.net/sites/default/files/110606_picking_1.pdf

Tom DeVito 3.5.2012

Start: 10:15

  • Continued working on drawing out the circuit board.  I think I can do this one sided but if not I can definitely do it with two sides.  The cost doesn’t go up much unless you use the 2 internal layers.
  • Finished drawing the sensor circuits and added ports for the varios wire groups coming in and out of the board.
  • Just a reminder because I think I forgot to mention this in earlier entries.  Each board supports 2 fingers, so one board will only have half the components on it.  The reason for this is the rheostat is I2c.  I2c protocol only allows 4 addresses for slave devices.  Another reason this works out is our high powered amplifiers are stereo.
  • Phil suggested using barrel plugs for the power.  I figure if we are going to do this, we might as well have one power input and regulate the power on the circuits that require 5v.
  • I tested a circuit for a LM7905 Voltage Regulator.  The surface mounted ones use a metal plate to increase heat conductivity with the pcb board allowing for much smaller packaging.
  • The 5V circuit will be running parallel to the 12V amplifier.  There are two things that need to be considered to make this work in a robust manner.  First a load resistor will have to be added to the 5 volt side to bring the current going in down to 1 Amp which is the operating capacity of the voltage regulator.  Second, I have to worry about what will happen if the amp suddenly stops working causing a surge of power to the regulator.  I believe a RC circuit to ground resolves this problem.

End:6:15

Phil 3.5.12

8:00 – 9:30 VISIBILITY

  • Checking up on email, trying to get access to the presentation slides for the demo, etc. I won’t steal Mikes thunder about progress with getting VISIBILITY swfs running

9:30 – 4:30 FP

  • Advanced Shaders (Chapter 11)
    • Geometry shaders run once per primitive. This means that it’ll run once per point for GL_POINTS; once per line for GL_LINES, GL_LINE_STRIP, and GL_LINE_LOOP; and once per triangle for GL_TRIANGLES, GL_TRIANGLE_STRIP, and GL_TRIANGLE_FAN.
    • GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY, GL_TRIANGLES_ADJACENCY, and GL_TRIANGLE_STRIP_ADJACENCY allow the geometry shader to get at the vertices that are adjacent to the particular piece of geometry that we’re interested in. I’d assume  that we can also manipulate those pieces, though I’m not sure that’s a good idea.
    • Convolution filters can be generated as a texture (even an image), and then used to modify what’s being rendered. For example, the following should be usable as a blur filter, assuming that the weights add up to 1.0 (which could be done as a pre-processing pass on the data before the texture is made):
    • Got the demo that uses a fragment shader to draw a Julia Set kind of working.
    • Tried to start Uniform Buffer Objects, but discovered that my brain was full.

Tom DeVito 3.2.2012

Start: 10:00

  • After a lot of fiddling around, I finally figured out how to group and space things in the pad2pad software.
  • Printed out the locations of the standoffs to make sure that everything will fit properly.
  • Started planning out the traces.  I need a 12 volt power source for the large amplifiers.  All the rest run on 5 volts.

End 6:00

Phil 3.2.12

8:30 – 1:30 FP

  • Really good page: http://www.opengl.org/wiki/Common_Mistakes
  • Advanced buffers – done
  • Fragment operations (Chapter 10)
    • Order-independent transparency using multisample buffers. Looks pretty straightforward. Need to add that. Possibly to ScreenRepaint?
  • Advanced Shader Usage (Chapter 11)
    • Physical simulation, such as meshes. Should be nice for network visualization…
  • Found the reason for why screenwidth must be a multiple of 4 (from http://www.opengl.org/wiki/Common_Mistakes#Texture_upload_and_pixel_reads):
  • Texture upload and pixel reads

    You create a texture and upload the pixels with glTexImage2D (or glTexImage1D, glTexImage3D). However, the program crashes on upload, or there seems to be diagonal lines going through the resulting image. This is because the alignment of each horizontal line of your pixel array is not multiple of 4. That is, each line of your pixel data is not a multiple of 4. This typically happens to users loading an image that is of the RGB or BGR format (in other words, 24 bpp image).
    Example, your image width = 401 and height = 500. The height doesn’t matter. What matters is the width. If we do the math, 401 pixels x 3 bytes = 1203. Is 1203 divisible by 4? In this case, the image’s data alignment is not 4. The question now is, is 1203 divisible by 1? Yes, so the alignment is 1 so you should call glPixelStorei(GL_UNPACK_ALIGNMENT, 1). The default is glPixelStorei(GL_UNPACK_ALIGNMENT, 4). Unpacking means sending data from client side (the client is you) to OpenGL.
    And if you are interested, most GPUs like chunks of 4 bytes. In other words, RGBA or BGRA is prefered. RGB and BGR is considered bizarre since most GPUs, most CPUs and any other kind of chip don’t handle 24 bits. This means, the driver converts your RGB or BGR to what the GPU prefers, which typically is BGRA.
    Similarly, if you read a buffer with glReadPixels, you might get similar problems. There is a GL_PACK_ALIGNMENT just like the GL_UNPACK_ALIGNMENT. The default GL_PACK_ALIGNMENT is 4 which means each horizontal line must be a multiple of 4 in size. If you read the buffer with a format such as BGRA or RGBA you won’t have any problems since the line is already a multiple of 4. If you read it in a format such as BGR or RGB then you risk running into this problem.
    The GL_PACK_ALIGNMENT can only be 1, 2, 4, or 8. So an alignment of 3 is not allowed. You could just change the GL_PACK_ALIGNMENT to 1. Or you can pad your buffer out so that each line, even with only 3 values per pixel, is a multiple of 4.

     

 

Tom DeVito 3.01.2012

Start: 10:00

  • Played around with the Pad2Pad software.  The last one I did was realtively simple so I had to figure out some of the tricks before drawing this board
  • The logical connection tool will auto draw the traces after you set what needs to be connected to what.
  • I want to use jumpers for the I2C addressing.  I found the slot, I will have to see where I can find the hardware for that though.
  • Drew up the basic parts that need to be included.  Measurements were done so hopefully I can mount the midi and large amplifier boards on standoffs to the board.  I am not sure but I might be able to print it out and see if the holes match up.
  • R rotates the piece you are placing.
  • Started drawing out the pre-amp circuit on the pad2pad program.  I figured it was best to start with the hardest part so if I have to move anything it won’t be that.

End: 6:00

Phil 3.1.12

8:30 – 10:30 VISIBILITY

  • Set up the root index page to point at working versions of the VISIBILITY system until we get everything working on one server.
  • Asked for the slides to the meeting yesterday. I’m thinking about using it to set up the slideshow for the demo.
  • Pinged Laurie about getting date information so that I can finish submitting my forms.

10:30 – 12:30 FP

  • Back to reading through the screen buffers chapter.

12:30 – 2:30 interview

2:30 – 4:30 FP

  • Some reading, some walking through the circuit board design with Tom

Phil 2.29.12

8:30 – 11:00, 12:30 – 3:00 VISIBILITY

  • Worked on getting Data Visualization working
  • ISR/PMO meeting from 1:00 – 3:00

11:00 – 12:30, 3:00 – 5:00 FP

  • Working on multiple rendering surfaces. For the trivial case, I’m going to try to take the blurred image and invert the colors.
  • Added definition of the vertex and fragment shaders in the ScreenRepaint class, since it’s pretty generic.
  • Took screen rendering out of the Gl_ShaderWindow base class and added two instances to the GeoTestShaderWindow. Everything works just as it should.
  • Meeting at UMBC on surface displays, journals and other things. Looks like I’m on a team to build a “Surface-style” interface for the visually impaired. Meetings are every Wednesday at 4:30

Tom DeVito 2.28.2012

Start: 10:00

  • Took inventory of what slots I will need to make the circuit boards.

end 12:30

Dentist Appointment : 12:30 – 2:00

Start: 2:00

  • Finished all the methods for sound control in the controller class
  • Started working on the command execution method.

end: 6:00

 

Tom DeVito 2.24.2012

Start: 10:00

  • Working on the controllers for gathering sensor data and sound controls
  • Made some changes to the base classes for sound control so that they accepted value between 0-255
  • Made some more minor changes to the the Amp and Midi classes to make execution of commands easier.
  • Decided on a naming scheme for variables in the DataDiction.  The finger name underscore property(ex. thumb_vol is thumb volume)
  • My friend Chris came by to make a car which turns and travels north.  He was using a compass IC which communicated to the Arduino using I2c.
  • I found out that it is a good thing I have not updated the arduino IDE yet.  There were changes made which would break my code.  I will have to update this eventually but I want to get everything working first.
  • atan2(y, x) will find the angle in radians from the origin.  This method automatically fixes it to work past 90 degrees.
  • I used my com classes and console to print out the data to help him test the compass.  Simply dropped it in and set a toString on his class.
  • We were able to get his robot to work.  I’ll show you the video tomorrow.

End: 6:00