Esempio n. 1
0
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage, bool useColors, bool useTextures, bool useNormals){
	if(mesh.getVertices().empty()){
		ofLogWarning("ofVbo") << "setMesh(): ignoring mesh with no vertices";
		return;
	}
	setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
	if(mesh.hasColors() && useColors){
		setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
		enableColors();
	}else{
		disableColors();
	}
	if(mesh.hasNormals() && useNormals){
		setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
		enableNormals();
	}else{
		disableNormals();
	}
	if(mesh.hasTexCoords() && useTextures){
		setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
		enableTexCoords();
	}else{
		disableTexCoords();
	}
	if(mesh.hasIndices()){
		setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
		enableIndices();
	}else{
		disableIndices();
	}
}
Esempio n. 2
0
void antPlane::generateColors( const antRGBA & color_1, const antRGBA & color_2 )
{
    m_colors = ( GLfloat * ) malloc( N_COLOR_ATTRIBS * m_nVertices * sizeof( GLfloat ) );
    
    // for each square ---------------------------------------------------------
    for ( int i = 0; i < m_nRows; i++ )
    {
        for ( int j = 0; j < m_nColumns; j++ )
        {
    //--------------------------------------------------------------------------
            
            int c = (i * m_nColumns + j) * 6 * N_COLOR_ATTRIBS;
            
            // for each
            for ( int n = 0; n < N_COLOR_ATTRIBS; n++ )
            {
                m_colors[ c + n ] = color_1.v[n];
                m_colors[ c + (1 * N_COLOR_ATTRIBS) + n ] = color_1.v[n];
                m_colors[ c + (2 * N_COLOR_ATTRIBS) + n ] = color_1.v[n];
                
                m_colors[ c + (3 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
                m_colors[ c + (4 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
                m_colors[ c + (5 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
            }
        }
    }
    
    m_hasColors = true;
    bindVao(0);
    bindVbo(1);
    setData( m_nVertices * N_COLOR_ATTRIBS * sizeof(GLfloat), m_colors );
    attrib( ATTR_COLOR_LOC, N_COLOR_ATTRIBS );
    enableColors();
}
Esempio n. 3
0
//--------------------------------------------------------------
void ofVbo::setColorData(const float * color0r, int total, int usage, int stride) {
	if(colorId==0) {
		glGenBuffers(1, &(colorId));
		retain(colorId);
		enableColors();
	}
	colorUsage = usage;
	colorStride = stride==0?4*sizeof(float):stride;
	
	glBindBuffer(GL_ARRAY_BUFFER, colorId);
	glBufferData(GL_ARRAY_BUFFER, total * stride, color0r, usage);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Esempio n. 4
0
int main(int argc, char **argv) {
	int flag;
	const char* filename = NULL;

	// retrieve the options
	while(1) {
		static struct option long_options[] = {
			{"help", no_argument, &flagHelp, 1},
			{"no-counter-examples", no_argument, &flagNoCounterExample, 1},
			{"no-generalization", no_argument, &flagNoGeneralization, 1},
			{"expand-relations", no_argument, &flagExpandRelation, 1},
			{"no-color", no_argument, &flagNoColor, 1},
			{0, 0, 0, 0}
		};
		/* getopt_long stores the option index here. */
		int option_index = 0;

		flag = getopt_long (argc, argv, "vh", long_options, &option_index);

		/* Detect the end of the options. */
		if (flag == -1) {
			break;
		}

		switch(flag) {
			case 0:
				// all long option set flags, they will be checked after
				break;
			case 'v':
				// each occurence of a v add a verbosity level
				++flagVerbose;
				break;
			case 'h':
				flagHelp = 1;
				break;
			case '?':
				/* getopt_long already printed an error message. */
				break;
			default:
				abort ();
		}
	}

	if (optind < argc) {
		filename = argv[optind];
	}
	else if(!flagHelp) {
		output(LERROR, "An example file must be passed as an argument. Re run with --help for more informations.\n");
		return 1;
	}
	else {
		output(L0, PROG_NAME " is a programs that aims to find similarities in objects of same type.\n");
		output(L0, "Usage: " PROG_NAME " --help\n");
		output(L0, "       " PROG_NAME " <example-file-path>\n\n");
		output(L0, "--help                  Print the options that can be given to the program\n");
		output(L0, "--expand-relations      On solution objects that contains relations, print the object linked instead of writing its name\n");
		output(L0, "--no-generalization     Skip the generalization step of the solutions generation.\n");
		output(L0, "--no-counter-examples   Prevent the use of counter-exemples to reduce the solutions.\n");
		output(L0, "--no-color              Disable the colored output.\n");
		output(L0, "-v                      Set the verbosity level. 4 levels are available (up to -vvvv)\n");

		return 0;
	}

	setOutputImportance(flagVerbose);

	// if the user ask for no color or the output streams (whether stdout or stderr) aren't terminals, remove colors
	if(flagNoColor || !isatty(fileno(stdout)) || !isatty(fileno(stderr))) {
		enableColors(0);
	}

	size_t includePosition;
	char* c = getIncludeFile(filename, &includePosition);

	if(c == NULL) {
		output(LERROR, "The loading of the configuration file failed. The configuration must be linked in the example file (example file loaded: %s).\n", filename);
	}
	else {
		output(L1, "%sLoading configuration file: %s%s\n", SBDEFAULT, c, SDEFAULT);
		Model* m = loadConfigFile(c);

		if(m == NULL) {
			output(LERROR, "Configuration file parsing: failed\n");
			free(c);
			return 1;
		}

		output(L1, "%sLoading examples file: %s%s\n", SBDEFAULT, filename, SDEFAULT);

		Examples* e = loadExampleFile(filename, m, includePosition);

		if(e == NULL) {
			output(LERROR, "Example file parsing: failed\n");
			free(c);
			freeModel(m);
			return 1;
		}

		output(L1, "%sGenerating all combinations...%s\n", SBDEFAULT, SDEFAULT);

		Solution* s = genAllCombi(m, e);

		output(L1, "%sAdding relations...%s\n", SBDEFAULT, SDEFAULT);

		genAllRelations(s, e, m);

		if(!flagNoGeneralization) {
			output(L1, "%sGeneralization...%s\n", SBDEFAULT, SDEFAULT);
			genGeneralization(m, s);
		}

		if(!flagNoCounterExample) {
			output(L1, "%sChecking counter-examples...%s\n", SBDEFAULT, SDEFAULT);
			genCounterExamples(m, e, s);
		}

		output(L1, "%sSolutions:%s\n", SBDEFAULT, SDEFAULT);
		
		genOutput(s, m, flagExpandRelation);

		free(c);
		freeModel(m);
		freeExamples(e);
		freeSolution(s);
	}

	return 0;
}
Esempio n. 5
0
//--------------------------------------------------------------
void ofVbo::setColorBuffer(ofBufferObject & buffer, int stride, int offset){
	colorAttribute.setBuffer(buffer, 4, stride, offset);
	enableColors();
}
Esempio n. 6
0
//--------------------------------------------------------------
void ofVbo::setColorData(const float * color0r, int total, int usage, int stride) {
	colorAttribute.setData(color0r, 4, total, usage, stride);
	enableColors();
}