Exemplo n.º 1
0
void main(void)
{
	unsigned char light=0;
	unsigned char lastkey=0;			// Mark key to be off

	P0=~0x00;			// Light off

	for (;;)
	{
		if (getSwitch() == 1)
		{
			if (lastkey == 0)			// Switch is from Off to On
			{
				lastkey = 1;			// Mark switch is on now
				if (light == 0)			// Light is Off
				{
					setLight(1);		// Turn on the light now
					light = 1; 			// Mark light to On
				}
				else					// Light is on
				{
					setLight(0);  		// Turn off the light now
					light = 0;			// Mark light to Off
				}
			}	
		}
		else
		{
			lastkey = 0;				// Switch is off
		}
//		delay(30000);   				// for debug use
	}
} /* main */ 
Exemplo n.º 2
0
void KisColorSelector::loadSettings()
{
    KisConfig cfg;
    setColorSpace(KisColor::Type(cfg.readEntry<qint32>("ArtColorSel.ColorSpace" , KisColor::HSY)));
    
    setNumLightPieces(cfg.readEntry("ArtColorSel.LightPieces", 19));
    
    m_selectedColor.setH(cfg.readEntry<float>("ArtColorSel.SelColorH", 0.0f));
    m_selectedColor.setS(cfg.readEntry<float>("ArtColorSel.SelColorS", 0.0f));
    m_selectedColor.setX(cfg.readEntry<float>("ArtColorSel.SelColorX", 0.0f));
    m_selectedColor.setA(1.0f);
    
    setInverseSaturation(cfg.readEntry<bool>("ArtColorSel.InversedSaturation", false));
    setLight(cfg.readEntry<float>("ArtColorSel.Light", 0.5f), cfg.readEntry<bool>("ArtColorSel.RelativeLight", false));
    
    recalculateRings(
                cfg.readEntry("ArtColorSel.NumRings"  , 11),
                cfg.readEntry("ArtColorSel.RingPieces", 12)
                );
    
    QList<float> angles = cfg.readList<float>("ArtColorSel.RingAngles");

    for (int i = 0; i < m_colorRings.size(); ++i) {
        if (i < angles.size() && i < m_colorRings.size()) {
            m_colorRings[i].angle = angles[i];
        }
    }
    
    selectColor(m_selectedColor);
    update();
}
Exemplo n.º 3
0
void init(void)
{
 //背景色
  glClearColor(0.2, 0.2, 0.3, 1.0);

  setCamera();//視点を求める
  setLight(); //光源設定 
	glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  printf("マウス/キー操作の説明には'h'キーをプッシュ \n");

  glGenTextures(2, texName);//テクスチャオブジェクトの名前付け
  //Terrainデータの作成
	makeTerrainData();
  Bitmap* bm0 = new Bitmap();
  loadBitmap(bm0, "../../bmp/altgrad4.bmp");
  makeTerrainImage(bm0);
  setTerrainTexture(0);

	//particle用テクスチャ
  Bitmap* bm1 = new Bitmap();
  loadBitmap(bm1, "../../bmp/snow1.bmp");
  makeParticleImage(bm1);
  setParticleTexture(1);
	//時間計測
  lastTime = timeGetTime();
  elapseTime1 = 0.0;
  elapseTime2 = 0.0;
	countP = 0.0;

}
Exemplo n.º 4
0
void KisColorSelector::mousePressEvent(QMouseEvent* event)
{
    m_clickPos       = mapCoord(event->posF(), m_renderArea);
    m_mouseMoved     = false;
    m_pressedButtons = event->buttons();
    m_clickedRing    = getSaturationIndex(m_clickPos);
    
    qint8 clickedLightPiece = getLightIndex(event->posF());
    
    if (clickedLightPiece >= 0) {
        setLight(getLight(event->posF()), m_relativeLight);
        m_selectedLightPiece = clickedLightPiece;
        setSelectedColor(m_selectedColor, !(m_pressedButtons & Qt::RightButton), true);
        m_mouseMoved   = true;
    }
    else if (m_clickedRing >= 0) {
        if (getNumPieces() > 1) {
            for(int i=0; i<getNumRings(); ++i)
                m_colorRings[i].setTemporaries(m_selectedColor);
        }
        else {
            Radian angle = std::atan2(m_clickPos.x(), m_clickPos.y()) - RAD_90;
            m_selectedColor.setH(angle.scaled(0.0f, 1.0f));
            m_selectedColor.setS(getSaturation(m_clickedRing));
            m_selectedColor.setX(getLight(m_light, m_selectedColor.getH(), m_relativeLight));
            setSelectedColor(m_selectedColor, !(m_pressedButtons & Qt::RightButton), true);
            m_selectedRing = m_clickedRing;
            m_mouseMoved   = true;
            update();
        }
    }
}
Exemplo n.º 5
0
void SceneView::inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask)
{
    if (_camera.valid() && _camera->getView()) 
    {
        if (inheritanceMask & osg::CullSettings::LIGHTING_MODE)
        {
            LightingMode newLightingMode = _lightingMode;
        
            switch(_camera->getView()->getLightingMode())
            {
                case(osg::View::NO_LIGHT): newLightingMode = NO_SCENEVIEW_LIGHT; break;
                case(osg::View::HEADLIGHT): newLightingMode = HEADLIGHT; break;
                case(osg::View::SKY_LIGHT): newLightingMode = SKY_LIGHT; break;
            }
            
            if (newLightingMode != _lightingMode)
            {
                setLightingMode(newLightingMode);
            }
        }
                
        if (inheritanceMask & osg::CullSettings::LIGHT)
        {
            setLight(_camera->getView()->getLight());
        }
    }
    
    osg::CullSettings::inheritCullSettings(settings, inheritanceMask);
}
Exemplo n.º 6
0
void init(void)
{
 //背景色
  glClearColor(0.2, 0.2, 0.3, 1.0);

  setCamera();//視点を求める
  setLight(); //光源設定 
	glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  printf("マウス/キー操作の説明には'h'キーをプッシュ \n");

  //テクスチャの設定
  setCubeMap();
  //pet robot アニメーション
  pet.unitTime = 0.05;//1フレーム当たりの時間(最初は仮の値)
  //フレームデータを作成
  pet.numFrame0 = 0;
	pet.vPos.x =  1.0;
	pet.vPos.z = -1.0;
	pet.vAng.y = -90.0;
  pet.numFrame0 = 0;
  frameCount = 0;

	pet.walk(2.0, 0.2, 1.0);
	pet.turn(180.0, 2.0);
	pet.walk(2.0, 0.2, 1.0);
	pet.turn(-180.0, 2.0);
	pet.walk(2.0, 0.2, 1.0);
	pet.turn(180, 2.0);
	pet.walk(2.0, 0.2, 1.0);
	pet.turn(-180.0, 2.0);
	printf("numFrame0=%d \n", pet.numFrame0);
}
Exemplo n.º 7
0
void Intervalometer::init()
{
	Serial.begin(9600);
    while(!Serial){}
	
	pinMode       (shuterPin,OUTPUT);
	pinMode       (displayPin,OUTPUT);
	pinMode		  (brightnessPin, OUTPUT);
	digitalWrite  (shuterPin,LOW);
	digitalWrite  (displayPin,HIGH);
  
  
	p_lcd-> 					init();
	p_buttonLightUp->  			init();
	p_buttonLightDown->			init();
	p_buttonUp->            	init();
	p_buttonDown->          	init();
	p_buttonOk->            	init();
	p_buttonBack->			 	init();
	p_led->				     	init();
	p_lcd->     createChar(2, kamera);
	p_lcd -> 	createChar(1,PfeilDown);
	p_lcd -> 	createChar(0,PfeilUp);
	
	setLight();
	intro();
	p_lcd->clear();
	
	Serial.println("SETUP DONE");	
}
Exemplo n.º 8
0
void init(void)
{
 //背景色
  glClearColor(0.2, 0.2, 0.3, 1.0);

  setCamera();//視点を求める
  setLight(); //光源設定 
	glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  printf("マウス/キー操作の説明には'h'キーをプッシュ \n");

  //Terrainデータの作成
	makeTerrainData();
  Bitmap* bm0 = new Bitmap();
  loadBitmap(bm0, "../../bmp/altgrad4.bmp");
  makeTerrainImage(bm0);
  setTerrainTexture();
	//particle
  countP = 0;
  fps = 0;
  elapseTime1 = 0.0;//1sec間以内の経過時間
  elapseTime2 = 0.0; //init()後の総経過時間
  for(int i = 0; i < NUM_PARTICLE; i++) p[i] = CParticle();
  for(int i = 0; i < NUM_PARTICLE2; i++) q[i] = CParticle2();
	frameCount = 0;
}
Exemplo n.º 9
0
Spawn::Spawn(Spawn* s, uint16_t id) : Item(tSpawn, id)
{
    setName(s->name());
    setLastName(s->lastName());
    Item::setPoint(s->x(), s->y(), s->z());
    setPetOwnerID(s->petOwnerID());
    setLight(s->light());
    setGender(s->gender());
    setDeity(s->deity());
    setRace(s->race());
    setClassVal(s->classVal());
    setHP(s->HP());
    setMaxHP(s->maxHP());
    setGuildID(s->guildID());
    setLevel(s->level());
    for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment(i));
    setEquipment(tUnknown1, SlotEmpty);
    setTypeflag(s->typeflag());
    setGM(s->gm());
    setNPC(s->NPC());
    setAnimation(s->animation());
    setDeltas(s->deltaX(), s->deltaY(), s->deltaZ());
    setHeading(s->heading(), s->deltaHeading());
    setConsidered(s->considered());

    // the new copy will own the spawn track list
    m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList = s->m_spawnTrackList;
    s->m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList.setAutoDelete(true);
}
Exemplo n.º 10
0
Spawn::Spawn(uint16_t id, 
	     int16_t x, int16_t y, int16_t z,
	     int16_t deltaX, int16_t deltaY, int16_t deltaZ,
	     int8_t heading, int8_t deltaHeading,
	     uint8_t animation) 
  : Item(tSpawn, id)
{
  // apply the unknown mob values
  m_name = "unknown";
  setNPC(SPAWN_NPC_UNKNOWN);

  // set what is known
  setPos(x, y, z);
  setDeltas(deltaX, deltaY, deltaZ);
  setHeading(heading, deltaHeading);
  setAnimation(animation);
  
  // initialize what isn't to 0
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setLevel(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);
  setTypeflag(0);
  setConsidered(false);

  // turn on auto delete for the track list
  m_spawnTrackList.setAutoDelete(true);
}
Exemplo n.º 11
0
bool ClydeDev::init() {

	// -- pins
  pinMode(eye_r_pin, OUTPUT);
  pinMode(eye_g_pin, OUTPUT);
  pinMode(eye_b_pin, OUTPUT);
   
  pinMode(eye_ir_pin, INPUT);
   
  pinMode(white_pin, OUTPUT);
  setLight(0);


  


	if(LOG_LEVEL <= DEBUG) *debug_stream << "Beginning initialisation of Clyde" << endl; 


	current_colour[0] = 0;
	current_colour[1] = 0;
	current_colour[2] = 0;

	current_hue = 0;


  // -- eye / ir sample related
  last_calibrated = 0;
  last_sampled = 0;
  sample_count = 0;
  ir_total = 0;
  ir_range_avg = 0;
  done_calibration = false;


  // the raw, un-averaged, ir vals from analog in
  current_ir_raw = 0;
  previous_ir_raw = 0;
  ir_min_raw = 0;
  ir_max_raw = 0;


  // the averaged reading ir vals over time
  current_ir_val = 0;
  previous_ir_val = 0;


  // eye button press related
  press_thresh = 0;
  press_start = 0;
  is_pressed = false;
  press_sample_count = 0;
  last_press = 0;


	initEye();

  return true;

}
Exemplo n.º 12
0
Spawn::Spawn(Spawn& s, uint16_t id)
  : Item(tSpawn, id)
{
  setName(s.name());
  setLastName(s.lastName());
  Item::setPoint(s.x(), s.y(), s.z());
  setPetOwnerID(s.petOwnerID());
  setLight(s.light());
  setGender(s.gender());
  setDeity(s.deity());
  setRace(s.race());
  setClassVal(s.classVal());
  setHP(s.HP());
  setMaxHP(s.maxHP());
  setGuildID(s.GuildID());
  setLevel(s.level());
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s.equipment(i));
  setEquipment(tUnknown1, 0);
  setTypeflag(s.typeflag());
  setNPC(s.NPC());
  setAnimation(s.animation());
  setDeltas(s.deltaX(), s.deltaY(), s.deltaZ());
  setHeading(s.heading(), s.deltaHeading());
  setConsidered(s.considered());

  // the new copy will own the spawn track list
  m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList = s.m_spawnTrackList;
  s.m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList.setAutoDelete(true);
}
Exemplo n.º 13
0
/* Start a new level */
void startLevel(int newlev) {
   int i,j,x;
   light *p = board;
   
   /* Set up variables */
   moves = 0;
   level = newlev;
   memset(board,0,boardsize);
   memset(solution,0,boardsize);

   /* Make random moves */
   for (x=level;x;x--) {
      i = random() % boardwidth;
      j = random() % boardheight;
      invertLightNoupdate(i,j);
      invertLightNoupdate(i-1,j);
      invertLightNoupdate(i+1,j);
      invertLightNoupdate(i,j-1);
      invertLightNoupdate(i,j+1);
      SOLUTION(i,j) ^= 1;
   }
      
   /* Set the gropnode states */
   for (j=0;j<boardheight;j++)
     for (i=0;i<boardwidth;i++)
      setLight(i,j,*(p++));
   pgWriteCmd(wCanvas,PGCANVAS_INCREMENTAL,0);
   
   /* Update the status message and run pgUpdate() */
   updateStatus();
}
Exemplo n.º 14
0
void init(){
	//codes for initialization
	drawgrid=1;
	drawaxes=1;
//	cameraHeight=144.0;
//	cameraAngle=1.0;
	angle=0;

	zRotation = 0.0;

	//clear the screen
	glClearColor(0,0,0,0);

	setLight();

	/************************
	/ set-up projection here
	************************/
	//load the PROJECTION matrix
	glMatrixMode(GL_PROJECTION);

	//initialize the matrix
	glLoadIdentity();

	//give PERSPECTIVE parameters
	gluPerspective(80,	1,	1,	10000.0);
	//field of view in the Y (vertically)
	//aspect ratio that determines the field of view in the X direction (horizontally)
	//near distance
	//far distance
}
Exemplo n.º 15
0
void GameManager::setOpenGLStates() {
	//Set clear color
	glClearColor(0.0f,0.0f,0.0f,0.0f);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	//Enable culling
	glEnable(GL_CULL_FACE);
	//glEnable(GL_NORMALIZE);
	glShadeModel(GL_SMOOTH);

	//AA
	glEnable(GL_POINT_SMOOTH);
	glEnable(GL_LINE_SMOOTH);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

	// Enable texturing
	glEnable(GL_TEXTURE_2D);
	
	//Fog
	glEnable(GL_FOG);
	glFogi(GL_FOG_MODE, GL_EXP2);
	glFogf(GL_FOG_DENSITY, 0.01f);
	glHint(GL_FOG_HINT, GL_NICEST);

	//Apply light
	setLight();

	ResizeWindow(window_width, window_height);
}
Exemplo n.º 16
0
void Intervalometer::displayOn()
{
	displayStat = true;
	digitalWrite(displayPin, HIGH);
	p_lcd->init();
	setLight();
}
Exemplo n.º 17
0
/******************************************************************************
 * Mouse move event handler
 *
 * @param e the event
 ******************************************************************************/
void SampleViewer::mouseMoveEvent( QMouseEvent* e )
{
	//if (_light1->grabsMouse())
	if ( _moveLight )
	{
		int mx = e->x();
		int my = e->y();

		_light[ 4 ] += ( _light[ 5 ] - e->x() ) / 100.0f;
		_light[ 5 ] = e->x();
		_light[ 3 ] += -( _light[ 6 ] - e->y() ) / 100.0f;
		_light[ 6 ] = e->y();

		if ( _light[ 3 ] < 0.0f )
		{
			_light[ 3 ] = 0.0f;
		}

		if ( _light[ 3 ] > (float)M_PI )
		{
			_light[3] = (float)M_PI;
		}

		setLight( _light[ 3 ], _light[ 4 ] );
	}
	else
	{
		QGLViewer::mouseMoveEvent( e );
	}
}
Exemplo n.º 18
0
char processLightCommand(char commandCode, void* commandData, void* responseDate) {
   switch(commandCode) {
      case SET_LIGHT:
	 setLight(*((char*)commandData));
         break;
   }
}
Exemplo n.º 19
0
void displayNavigateSubwindow()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glLoadIdentity();

	setNavigateSubwindowCamera(&estado.camera, modelo.objecto);
    setLight();

	glCallList(modelo.labirinto[JANELA_NAVIGATE]);
	glCallList(modelo.chao[JANELA_NAVIGATE]);

	if(!estado.vista[JANELA_NAVIGATE])
      {
        glPushMatrix();
            glTranslatef(modelo.objecto.pos.x,modelo.objecto.pos.y,modelo.objecto.pos.z);
            glRotatef(GRAUS(modelo.objecto.dir),0,1,0);
            glRotatef(-90,1,0,0);
            glScalef(SCALE_HOMER,SCALE_HOMER,SCALE_HOMER);
            mdlviewer_display(modelo.homer[JANELA_NAVIGATE]);
        glPopMatrix();
      }

	desenhaBussola(glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));

	glutSwapBuffers();
}
Exemplo n.º 20
0
//----------------------------------------------------------------------
// Spawn
Spawn::Spawn()
  : Item(tSpawn, 0)
{
  m_name = "fake";
  setNPC(SPAWN_NPC_UNKNOWN);

  Item::setPos(0, 0, 0);
  setDeltas(0, 0, 0);
  setHeading(0, 0);
  setAnimation(0);
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setGuildID(0xffff);
  setGuildTag(NULL);
  setLevel(0);
  setTypeflag(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);

  // just clear the considred flag since data would be outdated
  setConsidered(false);

  // finally, note when this update occurred.
  updateLast();
}
void LightingHandler::setMode(uint8_t which, uint8_t value) {
  lightModes[which] = value;
  switch(value) {
  case 0:
    setLight(which,(lightValues[which]--)+1);
    break;
  }
}
Exemplo n.º 22
0
void cmd_light( BaseChannel *chp, int argc, char * argv [] )
{
	(void)chp;
    if ( argc > 0 )
    {
        if ( argv[0][0] != '0' )
        {
            setLight( 1 );
            chprintf( chp, "ok:ledon" );
        }
        else
        {
            setLight( 0 );
            chprintf( chp, "ok:ledoff" );
        }
    }
}
Exemplo n.º 23
0
char processLightCommand(char commandCode, void* commandData, Response* responseData) {
	responseData->size = 0;
   switch(commandCode) {
   case SET_LIGHT:
	 	setLight(*((char*)commandData));
      break;
   }
   return 1;
}
Exemplo n.º 24
0
/* Toggle the light at the specified coordinates and update the groplist */
void invertLight(int lx,int ly) {
   light l;

   if (lx < 0 || lx >= boardwidth ||
       ly < 0 || ly >= boardheight)
     return;
   l = LIGHT(lx,ly) = !LIGHT(lx,ly);
   setLight(lx,ly,l);
}
Exemplo n.º 25
0
void init(void)
{
 //背景色
  glClearColor(0.2, 0.2, 0.3, 1.0);
  setCamera(); //視点を求める
  setLight();  //光源設定 
	glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  printf("マウス/キー操作の説明には'h'キーをプッシュ \n");
}
Exemplo n.º 26
0
// Default constructor
Scene::Scene() {
    defaultColor = Color::WHITE;
    defaultTransformation = mat4(1.0f);
    defaultShaderID = 1;
    defaultTextureID0 = 999;
    defaultTextureID1 = 999;
    GLfloat lightPosition[] = { 0.0, 5.0, 0.0, 1.0 };
    GLfloat lightPower = 1.0;
    setLight(lightPosition, lightPower);
}
Exemplo n.º 27
0
void Intervalometer::stopRunning()
{
  digitalWrite(displayPin, HIGH);
  p_lcd->init();
  setLight();
  
  p_lcd->    setCursor   (0, 0);
  p_lcd->    print       ("Gestopt     ");
  delay(1000);
  p_lcd->    clear();
}
Exemplo n.º 28
0
/**
 * Attached a named light to this display item
 * @param pName Used as a system/user name to lookup the light object
 */
 /*public*/ void LightIcon::setLight(QString pName)
{
 if (InstanceManager::getNullableDefault("LightManager") != nullptr)
 {
  light = ((ProxyLightManager*)InstanceManager::lightManagerInstance())->provideLight(pName);
  setLight(light);
 }
 else {
     log->error("No LightManager for this protocol, icon won't see changes");
 }
}
Exemplo n.º 29
0
Arquivo: sea.cpp Projeto: bradens/uvc
void foreground(void) {

  /* postion camera */
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glMultMatrixf(curview);

  setLight();	     /* position lights after camera transformation */

  /* draw objects after this line */
}
Exemplo n.º 30
0
//! [7]
void GLWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    //set light
    setLight();




    glTranslatef(0.0, 0.0, -10.0f);
    glScalef(1/scale, 1/scale, 1/scale);
    glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);
    //logo->draw(static_cast<QOpenGLFunctions_1_1 *>(this));
    //glPushMatrix();

    glBegin(GL_LINES);
    glColor3f(1, 0, 0);
    glVertex3f(-50, -2, -20);
    glVertex3f(50, -2, -20);

    glColor3f(0, 1, 0);
    glVertex3f(0, -50, -20);
    glVertex3f(0, 50, -20);

    glColor3f(0, 0, 1);
    glVertex3f(0, -2, -100);
    glVertex3f(0, -2, 10);
    glEnd();


    if(select)
    {
        int viewport[4];
        glGetIntegerv(GL_VIEWPORT, viewport);
        float modelview_data[16];
        float project_data[16];
        glGetFloatv(GL_MODELVIEW_MATRIX, modelview_data);
        glGetFloatv(GL_PROJECTION_MATRIX, project_data);
        //qDebug() << "select!";
        if(selectMode)
            obj.select(QMatrix4x4(modelview_data), QMatrix4x4(project_data), viewport, viewHeight);
        else
            obj.fix(QMatrix4x4(modelview_data), QMatrix4x4(project_data), viewport, viewHeight);
        pd.setObj(this->obj);
        select = false;
    }
    obj.draw(static_cast<QOpenGLFunctions_1_1 *>(this));

    //glPopMatrix();
}