Пример #1
0
void iqrcommon::moduleEPuck::update(){
//    cout << "moduleEPuck::update()" << endl;

    iCounter++;

#ifdef IQRMODULE  
    qmutexThread->lock(); //new
    StateArray &clsStateArrayProxialOutput = clsStateVariableProxialOutput->getStateArray();
    StateArray &clsStateArrayAmbientOutput = clsStateVariableAmbientOutput->getStateArray();
    StateArray &clsStateArrayMotorInput = stateVariableMotorIn->getTarget()->getStateArray();
#else
    StateArray clsStateArrayMotorInput(16);

    clsStateArrayMotorInput[0][2] = rand()/RAND_MAX;
    clsStateArrayMotorInput[0][3] = rand()/RAND_MAX;;
    clsStateArrayMotorInput[0][14] = rand()/RAND_MAX;
    clsStateArrayMotorInput[0][15] = rand()/RAND_MAX;
    
    StateArray clsStateArrayProxialOutput(8);
    StateArray clsStateArrayAmbientOutput(8);
#endif


    if(bShowOutput){
	clsEPuckDisp->setAmbient(clsStateArrayAmbientOutput[0]);
	clsEPuckDisp->setProximity(clsStateArrayProxialOutput[0]);
    }
    
    
    readProximity(clsStateArrayProxialOutput);
    readAmbient(clsStateArrayAmbientOutput);
    setSpeed(clsStateArrayMotorInput);


//    cout << "Proximity: ";
//    printStateArray(clsStateArrayProxialOutput);
//    cout << "Ambient: ";
//    printStateArray(clsStateArrayAmbientOutput);
  
  
//    cout << "Motor: ";
//    printStateArray(clsStateArrayMotorInasput);

    qmutexThread->unlock(); //new


#ifndef IQRMODULE      
    //     usleep(300000);
    sleep(1);
#endif

    usleep(100000);


};
Пример #2
0
void ObjParser::readMtlFile(const char* filename) {
	sprintf(mBuffer, "Lecture du fichier %s...", filename);
	m->message(MM_INFO, className, mBuffer);
	
	FILE* fichier;
	char ligne[255];
	
	/* Exemple de declaration dans un fichier mtl
	# Blender MTL File: 'None'
	# Material Count: 2

	newmtl Bois
	Ns 96.078431
	Ka 0.000000 0.000000 0.000000
	Kd 0.640000 0.640000 0.640000
	Ks 0.500000 0.500000 0.500000
	Ni 1.000000
	d 1.000000
	illum 2
	*/	
	
	fichier = fopen(filename, "r");
	
	while(!feof(fichier)) {
		ligne[0] = '\0';
		fscanf(fichier, "%s", ligne);

		if(strcmp((const char*)ligne, (char*)"newmtl") == 0)
			readNewMaterial(fichier);

		if(strcmp((const char*)ligne, (char*)"Ns") == 0)
			readSpecularExponent(fichier);
	
		if(strcmp((const char*)ligne, (char*)"Ka") == 0)
			readAmbient(fichier);
			
		if(strcmp((const char*)ligne, (char*)"Kd") == 0)
			readDiffuse(fichier);
			
		if(strcmp((const char*)ligne, (char*)"Ks") == 0)
			readSpecular(fichier);
	
/*
		if(strcmp((const char*)ligne, (char*)"Ni") == 0)
			
		if(strcmp((const char*)ligne, (char*)"d") == 0)
			
		if(strcmp((const char*)ligne, (char*)"illum") == 0)
*/

	}
}