Пример #1
0
void Bluetooth() 
{ 


    if(Serial.available()>0) 
    { 
      uint8_t readbuf=Serial.read(); 
      r_buffer[num]=readbuf; 
      num++; 
      delay(2); 
      Serial.println(num); 
      if(readbuf==0X3B) 
      { 
        if(num==3) 
        { 


          recivevalue=(r_buffer[0]<<8)|(r_buffer[1]); 


        } 


        num=0; 
        mark0=1; 
      }  
    }     






    if(mark0==1) 
    { 
      mark0=0; 


      switch(recivevalue) 
      { 
      case up    : //Serial.println(up,HEX); 
        _up(); 
        break; 
      case down  : //Serial.println(down,HEX); 
        _down(); 
        break; 
      case left  :  
        _left(); 
        break; 
      case right :  
        _right(); 
        break; 
      } 
     
  } 
} 
Пример #2
0
CameraManager::CameraManager() : Singleton<CameraManager>(),
								 m_AllCameras(),
								 m_AllWinCameras()
{
	m_AllCameras[DEFAULT_PERSPECRIVE_CAMERA_KEY]	 = new PerspectiveCamera(DEFAULT_PERSPECRIVE_CAMERA_KEY);
	m_AllCameras[DEFAULT_ORTHOGRAPHIC_CAMERA_KEY]	 = new OrthoCamera(DEFAULT_ORTHOGRAPHIC_CAMERA_KEY);
	m_AllWinCameras[DEFAULT_PERSPECRIVE_CAMERA_KEY]  = m_AllCameras[DEFAULT_PERSPECRIVE_CAMERA_KEY];
	m_AllWinCameras[DEFAULT_ORTHOGRAPHIC_CAMERA_KEY] = m_AllCameras[DEFAULT_ORTHOGRAPHIC_CAMERA_KEY];

	vec4 _eye(0.0f, 0.0f, 5.0f, 1.0f);
	vec4 _center(0.0f, 0.0f, 0.0f, 1.0f);
	vec3 _up(0.0f, 1.0f, 0.0f);

	m_AllCameras[DEFAULT_PERSPECRIVE_CAMERA_KEY]->LookAt(_eye, _center, _up);
	m_AllCameras[DEFAULT_ORTHOGRAPHIC_CAMERA_KEY]->LookAt(_eye, _center, _up);
}
Пример #3
0
gboolean
set_rawx_full_info_in_attr(const char *p, int filedes, GError **error,
		struct content_textinfo_s * content, struct chunk_textinfo_s * chunk,
		const char* compression_info, const char* compressed_size)
{
	struct attr_handle_s *attr_handle;
	GError *e = NULL;

	if (!_lazy_load_attr_from_file(p, &attr_handle, &e)) {
		SETERROR(error, "Failed to init the attribute management context : %s", e->message);
		g_clear_error(&e);
		return FALSE;
	}

	if (chunk) {
		_up(chunk->hash);

		SET(ATTR_NAME_CHUNK_ID, chunk->id);
		SET(ATTR_NAME_CHUNK_SIZE, chunk->size);
		SET(ATTR_NAME_CHUNK_HASH, chunk->hash);
		SET(ATTR_NAME_CHUNK_POS, chunk->position);
		SET(ATTR_NAME_CHUNK_METADATA, chunk->metadata);
	}

	if (content) {
		_up(content->container_id);
		_up(content->content_id);

		SET(ATTR_NAME_CONTENT_CONTAINER, content->container_id);
		SET(ATTR_NAME_CONTENT_ID, content->content_id);
		SET(ATTR_NAME_CONTENT_PATH, content->path);
		SET(ATTR_NAME_CONTENT_VERSION, content->version);
		SET(ATTR_NAME_CONTENT_SIZE, content->size);
		SET(ATTR_NAME_CONTENT_NBCHUNK, content->chunk_nb);

		SET(ATTR_NAME_CONTENT_STGPOL, content->storage_policy);
		SET(ATTR_NAME_CONTENT_MIMETYPE, content->mime_type);
		SET(ATTR_NAME_CONTENT_CHUNKMETHOD, content->chunk_method);
	}

	SET(ATTR_NAME_CHUNK_COMPRESSED_SIZE, compressed_size);
	SET(ATTR_NAME_CHUNK_METADATA_COMPRESS, compression_info);

	gboolean rc;
	if (filedes < 0)
		rc = _commit_attr_handle(attr_handle, &e);
	else
		rc = _commit_v2_attr_handle(filedes, attr_handle, &e);

	if (!rc) {
		SETERROR(error, "Could not write all the attributes on disk : %s", e->message);
		g_clear_error(&e);
		_clean_attr_handle(attr_handle, FALSE);
		return FALSE;
	}

	_clean_attr_handle(attr_handle, FALSE);
	return TRUE;

error_set_attr:
	SETERROR(error, "Failed to set attr in handle : %s", e->message);
	g_clear_error(&e);
	_clean_attr_handle(attr_handle, FALSE);
	return FALSE;
}
Пример #4
0
void ParticleLayer3D::Draw(Camera * camera)
{
    if(!sprite)
        return;

    Matrix4 rotationMatrix = Matrix4::IDENTITY;
    switch(RenderManager::Instance()->GetRenderOrientation())
    {
    case Core::SCREEN_ORIENTATION_LANDSCAPE_LEFT:
        //glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(90.0f));
        break;
    case Core::SCREEN_ORIENTATION_LANDSCAPE_RIGHT:
        //glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(-90.0f));
        break;
    }

    Matrix4 mv = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW)*rotationMatrix;

    Vector3 _up(mv._01, mv._11, mv._21);
    Vector3 _left(mv._00, mv._10, mv._20);

    verts.clear();
    textures.clear();
    colors.clear();
    int32 totalCount = 0;

    Particle * current = head;
    if(current)
    {
        renderBatch->GetMaterial()->GetRenderState()->SetTexture(sprite->GetTexture(current->frame));
    }

    while(current != 0)
    {
        Vector3 dx(_left);
        Vector3 dy(_up);

        //dx *= sqrt(2.f);
        //dy *= sqrt(2.f);

        float32 sine;
        float32 cosine;
        SinCosFast(current->angle, sine, cosine);

        float32 pivotRight = ((sprite->GetWidth()-pivotPoint.x)*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotLeft = (pivotPoint.x*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotUp = (pivotPoint.y*current->size.y*current->sizeOverLife)/2.f;
        float32 pivotDown = ((sprite->GetHeight()-pivotPoint.y)*current->size.y*current->sizeOverLife)/2.f;

        Vector3 dxc = dx*cosine;
        Vector3 dxs = dx*sine;
        Vector3 dyc = dy*cosine;
        Vector3 dys = dy*sine;

        Vector3 topLeft = current->position+(-dxc+dys)*pivotUp + (dxs+dyc)*pivotLeft;
        Vector3 topRight = current->position+(-dxs-dyc)*pivotRight + (-dxc+dys)*pivotUp;
        Vector3 botLeft = current->position+(dxs+dyc)*pivotLeft + (dxc-dys)*pivotDown;
        Vector3 botRight = current->position+(dxc-dys)*pivotDown + (-dxs-dyc)*pivotRight;

        verts.push_back(topLeft.x);//0
        verts.push_back(topLeft.y);
        verts.push_back(topLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botRight.x);//3
        verts.push_back(botRight.y);
        verts.push_back(botRight.z);

        float32 *pT = sprite->GetTextureVerts(current->frame);

        textures.push_back(pT[0]);
        textures.push_back(pT[1]);

        textures.push_back(pT[2]);
        textures.push_back(pT[3]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[2]);
        textures.push_back(pT[3]);

        textures.push_back(pT[6]);
        textures.push_back(pT[7]);

        // Yuri Coder, 2013/04/03. Need to use drawColor here instead of just colot
        // to take colorOverlife property into account.
        uint32 color = (((uint32)(current->drawColor.a*255.f))<<24) |  (((uint32)(current->drawColor.b*255.f))<<16) | (((uint32)(current->drawColor.g*255.f))<<8) | ((uint32)(current->drawColor.r*255.f));
        for(int32 i = 0; i < 6; ++i)
        {
            colors.push_back(color);
        }

        totalCount++;
        current = TYPE_PARTICLES == type ? current->next : 0;
    }

    renderBatch->SetTotalCount(totalCount);
    if(totalCount > 0)
    {
        renderData->SetStream(EVF_VERTEX, TYPE_FLOAT, 3, 0, &verts.front());
        renderData->SetStream(EVF_TEXCOORD0, TYPE_FLOAT, 2, 0, &textures.front());
        renderData->SetStream(EVF_COLOR, TYPE_UNSIGNED_BYTE, 4, 0, &colors.front());

        renderBatch->SetRenderDataObject(renderData);
    }
}
Пример #5
0
void up(KEY k) {
	if(_up != nullptr) {
		_up(k);
	}
}