示例#1
0
文件: server.cpp 项目: tinnfu/ftp
int server::dispatch()
{
    int res = 0;
    char pack_type = m_analyser.get_pack_type();

    // Delete the pack type.
    m_buff.pop_front();

    switch(pack_type)
    {
        case PT_UPREQ:
            break;
        
        case PT_DWREQ:
            break;

        case PT_LS:
            res = ls();
            break;

        case PT_CD:
            cd();
            break;

        case PT_RM:
            break;
        
        case PT_PWD:
            pwd();
            break;
        
        case PT_EXIT:
            over();
            break;
        
        default:
            break;
    }
    
    return res;
}
示例#2
0
static void
vmx128_combine_over_reverse_u_mask (uint32_t *      dest,
                                 const uint32_t *src,
                                 const uint32_t *mask,
                                 int             width)
{
    int i;
	__vector4 vdest, vsrc, vmask;
	__vector4 tmp1, tmp2, tmp3, tmp4, edges,
	dest_mask, src_mask, mask_mask, store_mask;

    COMPUTE_SHIFT_MASKC (dest, src, mask);

    /* printf ("%s\n",__PRETTY_FUNCTION__); */
    for (i = width / 4; i > 0; i--)
    {

	LOAD_VECTORSM (dest, src, mask);

	vdest = over (vdest, splat_alpha (vdest), vsrc);

	STORE_VECTOR (dest);

	src += 4;
	dest += 4;
	mask += 4;
    }

    for (i = width % 4; --i >= 0;)
    {
	uint32_t m = ALPHA_8 (mask[i]);
	uint32_t s = src[i];
	uint32_t d = dest[i];
	uint32_t ia = ALPHA_8 (~dest[i]);

	UN8x4_MUL_UN8 (s, m);

	UN8x4_MUL_UN8_ADD_UN8x4 (s, ia, d);
	dest[i] = s;
    }
}
示例#3
0
void GameScene::moveBlock(Touch *touch, Event *) {
	auto endPos = touch->getLocation();
	auto vec = endPos - m_startPos;

	//如果向量的两个方向均小于最小响应距离,就不响应
	if (fabs(vec.x) < MIN_STEP && fabs(vec.y) < MIN_STEP) return;
	//分出是水平响应还是垂直方向响应
	auto isH = fabs(vec.x) > fabs(vec.y);
	if (isH)
	{
		if (vec.x > 0)
		{
			right();
		}
		else {
			left();
		}
	}
	else {
		if (vec.y > 0)
		{
			up();
		}
		else {
			down();
		}
	}

	//产生新块
	if (m_isMoved)
	{
		createBlock();
		//重置滑屏移动变量
		m_isMoved = false;
	}
	else if (m_spaceBlockCount <= 0)
	{
		over();
	}
}
示例#4
0
void TRop::over(const TRasterP &out,
				const TRasterP &up,
				const TAffine &aff,
				ResampleFilterType filterType)
{
	out->lock();
	up->lock();

	if (filterType == ClosestPixel || filterType == Bilinear)
		::quickPut(out, up, aff, filterType);
	else {
		TRect rasterBounds = up->getBounds();
		TRectD dbounds(rasterBounds.x0, rasterBounds.y0, rasterBounds.x1 + 1, rasterBounds.y1 + 1);
		dbounds = aff * dbounds;
		TRect bounds(tfloor(dbounds.x0), tfloor(dbounds.y0), tceil(dbounds.x1) - 1, tceil(dbounds.y1) - 1);
		TRasterP tmp = up->create(bounds.getLx(), bounds.getLy());
		resample(tmp, up, TTranslation(-bounds.x0, -bounds.y0) * aff, filterType);
		over(out, tmp, bounds.getP00());
	}
	out->unlock();
	up->unlock();
}
示例#5
0
void CheckBox::createTexture(void) {
   Kernel *kernel = Kernel::getInstance();

   if ((_cTexture = kernel->getWidgetTexture(CHECKBOX)) != NULL) return;

   ColorRGBA  pColor1(183,191,213,255);
   ColorRGBA  pColor2( 71, 92,148,255);
   ColorRGBA  pColor3(100,118,165,255);
   ColorRGBA  pColor4(207,212,226,255);

   ColorRGBA colorClick(170,220,255,60);
   ColorRGBA colorOver(colorClick[0] - 100,colorClick[1] - 80,colorClick[2] - 40, colorClick[3]);

   ColorRGBA BackgroundColor(112,112,112,0);

   // create texture object
   _cTexture = new ComponentTexture(32, 16);
   kernel->setWidgetTexture(CHECKBOX, _cTexture);

   _cTexture->setTextureEnvMode(GL_MODULATE);

   // !selected
   _cTexture->addTexture(Point(0,0), 13, 13, data::CheckBox);

   // selected
   _cTexture->addTexture(Point(13,0), 13, 13, data::CheckBoxPressed);

   // over
   MatrixTemplate<ColorRGBA> over(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(over, Point(0,0), colorOver);
   _cTexture->addTexture(Point(0,13), over);

   // hold
   MatrixTemplate<ColorRGBA> hold(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(hold, Point(0,0), colorClick);
   _cTexture->addTexture(Point(1,13), hold);

   _cTexture->createTexture();
}
示例#6
0
//int main(int argc, char *argv[], char *env[])
void main(void)
{
 int i, j;
 mvtype movemade;
 mousex=100;
 mousey=100;
 iconmenu=0;
 set_default_options();
 options=doptions;
 read_options();
 initialise(startbrd);
 initial_displays(current);
 no_more_openings=FALSE;
 quit=game_over=0;
 g_path.move[0].f=0;
 randomize();
 FLAGnewstart=1;
 while(!quit)
 {
   while(game.movenum<maxmoves && !quit)
   {
	 whites=0;
	 blacks=0;
	 if (FLAGnewstart) { starttime=time(NULL); FLAGnewstart=0; }
	 newtime=0;
	 if (!game_over && ((current.mvr=='w' && options.whiteplayer==PROGRAM) || (current.mvr=='b' && options.blackplayer==PROGRAM)))
	      movemade=get_computer_move(current); else
		 movemade=get_player_move(current, game_over);
	 if (kbhit()) { if (getch()==27) { options.whiteplayer=USER; options.blackplayer=USER; } }
	 if (current.mvr=='w') (whites=time(NULL)-starttime); else (blacks=time(NULL)-starttime);
	 if (movemade.t!=0) if (movemade.t<100) makemv(movemade); else {menu_option(movemade.t); game_over=0;}
	 regular_displays(current, movemade);
	 if (!game_over) game_over=over();
	 assert(game.lastmove<maxmoves);
   }
   options.whiteplayer=USER;
   options.blackplayer=USER;
 }
}
示例#7
0
bool_ CTransaction::onMessage(const Message::TMsg *msg) {
	if (Message::MT_ACCOUNT == msg->type
			&& Message::MC_HAND_SHAKE == msg->cmd) {
		return __onStart((Message::TPDUHandShake *) msg);
	} else if ((Message::MT_CONTROL | Message::MT_SIGN_ACK) == msg->type
			&& Message::MC_HEART_BEAT == msg->cmd) {
		return __onHeartBeat((Message::TPDUHeartBeatAck *) msg);
	} else if (Message::MT_SERVICE == msg->type
			&& Message::MC_SEND_MSG == msg->cmd) {
		return __onSendMsg((Message::TPDUSendMsg *) msg);
	} else if ((Message::MT_SERVICE | Message::MT_SIGN_ACK) == msg->type
			&& Message::MC_PUSH_MSG == msg->cmd) {
		return __onPushMsg((Message::TPDUPushMsgAck *) msg);
	} else if (Message::MC_ON_TIMER == msg->cmd) {
		return __onTimer((Message::TPDUOnTimer *) msg);
	} else if (Message::MC_ON_OVER == msg->cmd) {
		return __onStop((Message::TPDUOnOver *) msg);
	} else {
		log_info("[%p]CTransaction::onMessage: unknown message-%x-%x, current "
				"status-%d", this, msg->type, msg->cmd, _status);
		return over(ETransactionExitReason::UNKNOWN_MESSAGE);
	}
}
示例#8
0
static void
vmx128_combine_over_u_no_mask (uint32_t *      dest,
                            const uint32_t *src,
                            int             width)
{
    int i;
	__vector4 vdest, vsrc;
	__vector4 tmp1, tmp2, tmp3, tmp4, edges,
	dest_mask, src_mask, store_mask;

    COMPUTE_SHIFT_MASKS (dest, src);

    /* printf ("%s\n",__PRETTY_FUNCTION__); */
    for (i = width / 4; i > 0; i--)
    {

	LOAD_VECTORS (dest, src);

	vdest = over (vsrc, splat_alpha (vsrc), vdest);

	STORE_VECTOR (dest);

	src += 4;
	dest += 4;
    }

    for (i = width % 4; --i >= 0;)
    {
	uint32_t s = src[i];
	uint32_t d = dest[i];
	uint32_t ia = ALPHA_8 (~s);

	UN8x4_MUL_UN8_ADD_UN8x4 (d, ia, s);

	dest[i] = d;
    }
}
示例#9
0
int run(Grid grid, char ch, int* score, bool ai = false)
{
	if(!over(grid))
	{
		if (ai)
		{
			ch = aI(grid);
		}
		if (shift(grid, ch, score))
		{
			randPut(grid);
            if(win(grid))
            {
                return WIN;
            }
	    }
        else
        {
            return NONE;
        }
    }
    else
        return FAIL;
}
示例#10
0
文件: Match.hpp 项目: gnramos/CIC-IIA
	/** Realiza o confronto, alternando os participantes, e retorna o estado 
	 * final da partida.
	 *
	 * @return state_t o estado resultante do confronto.
	 * @see bool allowed(const Move *, const state_t &) const
	 * @see IIA::Action<state_t>* Player::decide_action(const state_t &)
	 * @see void Move::execute(state_t &) const
	 * @see bool over(const state_t &)
	 * @see void setup(const typename std::deque<player_t *> &) */
	state_t play() {
		moves.clear();

		std::deque<player_t *> match_players(players);
		
		state_t state;

		setup(match_players);

		do {
			Move *move = choose_move(match_players.front(), state);
			moves.push_back(move);

			if(!allowed(move, state)) break;

			move->execute(state);
			
			next(match_players);
		} while(!over(state));

		// cleanup(match_players);

		return state;
	}
示例#11
0
// Called by CNodeGroup thread
bool_ CTransaction::__onPushMsg(const Message::TPDUPushMsgAck *msg) {
	log_debug("[%p]CTransaction::onPushMsg: current status-%d", this, _status);

	if (ETransactionStatus::READY != _status) {
		return over(ETransactionExitReason::WRONG_STATUS);
	}

	assert(msg->header.seq);
	if (0 != msg->header.seq) {
		MapSeq2Timer::iterator pos = _mapSeq2Timer.find(msg->header.seq);

		if (_mapSeq2Timer.end() != pos) {
			CTransactionManager::instance()->killTimer(pos->second);
			_mapSeq2Timer.erase(pos);
		}

		return true_v;
	}

	log_error("[%p]CTransaction::onPushMsg: no sequence found in push msg ack",
			this);

	return false_v;
}
示例#12
0
bool_ CTransaction::__onStart(const Message::TPDUHandShake* msg) {
	log_debug("[%p]CTransaction::onStart: current status-%d", this, _status);

	if (ETransactionStatus::CONNECTED != _status) {
		return over(ETransactionExitReason::WRONG_STATUS);
	}

	assert(_keepLiveTimerId);
	CTransactionManager::instance()->killTimer(_keepLiveTimerId);
	_keepLiveTimerId = 0;

	Message::TPDUHandShakeAck msgAck;

	memcpy(&msgAck, msg, sizeof(Message::THeader));
	msgAck.header.size = sizeof(Message::TPDUHandShakeAck);
	msgAck.header.type |= Message::MT_SIGN_ACK;
	msgAck.ack.code = 0;

	if (Config::App::BASE_BUILD > msg->build) {
		log_notice("[%p]CTransaction::onStart: client version with %u or above"
				" is necessary, now it's %u", this, Config::App::BASE_BUILD,
				msg->build);
		msgAck.ack.code = (ub2_)ETransactionExitReason::CLIENT_TOO_OLD;
		__send((Message::TMsg *) &msgAck, false_v);

		return over(ETransactionExitReason::CLIENT_TOO_OLD);
	}

	memcpy(_sessionId, msg->sessionId, Size::SESSION_ID);
	_id = _node->getGroup()->ro().verifyHandshake(_sessionId);

	if (0 == _id) {
		log_notice("[%p]CTransaction::onStart: cannot find corresponding "
				"sessionId-%s", this, _sessionId);
		memset(_sessionId, 0, Size::SESSION_ID);
		_id = 0;
		msgAck.ack.code = (ub2_)ETransactionExitReason::NO_THE_SESSION_FOUND;
		__send((Message::TMsg *) &msgAck, false_v);

		return over(ETransactionExitReason::NO_THE_SESSION_FOUND);
	}

	if (false_v == CTransactionManager::instance()->registerTransaction(this)) {
		log_notice("[%p]CTransaction::onStart: there is an transaction with "
				"the same sessionId-%s and id-%lu", this, _sessionId, _id);
		memset(_sessionId, 0, Size::SESSION_ID);
		_id = 0;
		msgAck.ack.code = (ub2_)ETransactionExitReason::SAME_SESSION_ID;
		__send((Message::TMsg *) &msgAck, false_v);

		return over(ETransactionExitReason::SAME_SESSION_ID);
	}

	_status = ETransactionStatus::READY;
	msgAck.ack.code = 0;
	_lastUpdate = msg->lastUpdate;

	if (true_v == __send((Message::TMsg *) &msgAck, false_v)) {
		_heartbeat = true_v;
		_keepLiveTimerId = CTransactionManager::instance()->setTimer(
				Config::App::HEARTBEAT_INTERVAL, this, (obj_) _status, 0);

		if (0 == _keepLiveTimerId) {
			return over(ETransactionExitReason::NO_MORE_TIMER);
		}
	}

	return true_v;
}
示例#13
0
void IntCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all)
{
  if (DrawThisCell(parser, point))
  {
    wxDC& dc = parser.GetDC();
    double scale = parser.GetScale();

    wxPoint base(point), under(point), over(point), var(point), sign(point);

    if (parser.CheckTeXFonts())
    {
      SetForeground(parser);
      int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5));
      dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN,
                        false, false, false,
                        parser.GetTeXCMEX()));
      dc.DrawText(wxT("\x5A"),
                  sign.x,
                  sign.y - m_signTop);
    }
    else
    {
#if defined __WXMSW__
      SetForeground(parser);
      int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5));
      int m_signWCenter = m_signWidth / 2;

      dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN,
                        false, false, false,
                        parser.GetSymbolFontName()));
      dc.DrawText(wxT(INTEGRAL_TOP),
                  sign.x + m_signWCenter - m_charWidth / 2,
                  sign.y - (m_signSize + 1) / 2);
      dc.DrawText(wxT(INTEGRAL_BOTTOM),
                  sign.x + m_signWCenter - m_charWidth / 2,
                  sign.y + (m_signSize + 1) / 2 - m_charHeight);

      int top, bottom;
      top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2;
      bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2;
      if (top <= bottom)
      {
        while (top < bottom)
        {
          dc.DrawText(wxT(INTEGRAL_EXTEND),
                        point.x + m_signWCenter - m_charWidth / 2,
                        top);
          top += (2*m_charHeight)/3;
        }
        dc.DrawText(wxT(INTEGRAL_EXTEND),
                        point.x + m_signWCenter - m_charWidth / 2,
                        sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2);
      }
#else
      SetPen(parser);
      // top decoration
      int m_signWCenter = m_signWidth / 2;
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1,
                  sign.x + m_signWCenter + SCALE_PX(3, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale));
      dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale),
                  sign.x + m_signWCenter + SCALE_PX(6, scale),
                  sign.y - (m_signSize + 1) / 2);
      dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale),
                  sign.y - (m_signSize + 1) / 2,
                  sign.x + m_signWCenter + SCALE_PX(9, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale));
      // bottom decoration
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1,
                  sign.x + m_signWCenter - SCALE_PX(3, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale));
      dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale),
                  sign.x + m_signWCenter - SCALE_PX(6, scale),
                  sign.y + (m_signSize + 1) / 2);
      dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale),
                  sign.y + (m_signSize + 1) / 2,
                  sign.x + m_signWCenter - SCALE_PX(9, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale));
      // line
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1,
                  sign.x + m_signWCenter,
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1);
      UnsetPen(parser);
#endif
    }

    if (m_intStyle == INT_DEF)
    {
      under.x += m_signWidth;
      under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) -
                m_signSize / 3;
      m_under->Draw(parser, under, MAX(MC_MIN_SIZE, fontsize - 5), true);

      if (parser.CheckTeXFonts())
        over.x += 2*m_signWidth;
      else
        over.x += m_signWidth;

      over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) +
               m_signSize / 3;
      m_over->Draw(parser, over, MAX(MC_MIN_SIZE, fontsize - 5), true);

      if (parser.CheckTeXFonts())
      {
        base.x += m_signWidth +
                  MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale));
      }
      else
        base.x += m_signWidth +
                  MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale));
    }

    else if (parser.CheckTeXFonts())
      base.x += 2*m_signWidth;
    else
      base.x += m_signWidth;

    m_base->Draw(parser, base, fontsize, true);

    var.x = base.x + m_base->GetFullWidth(scale);
    m_var->Draw(parser, var, fontsize, true);
  }

  MathCell::Draw(parser, point, fontsize, all);
}
示例#14
0
 void pop_last(ConstLine &a) {
     while (dq.size() > 1 and over(*(dq.rbegin() + 1), dq.back(), a))
         dq.pop_back();
 }
示例#15
0
// The MAIN function, from here we start the application and run the 
// game loop
int main()
{
    std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
    // Init GLFW
    glfwInit();
    // Set all the required options for GLFW
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    // OS X requests 3.3 differently.
#ifdef __APPLEOS__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    // Create a GLFWwindow object that we can use for GLFW's functions
    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", 
                                          nullptr, nullptr);    
    if (window == nullptr)
    {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    // Set the required callback functions
    glfwSetKeyCallback(window, key_callback);

    // Set this to true so GLEW knows to use a modern approach to retrieving
    // function pointers and extensions
    // More hacking for my autocomplete.
#ifndef CLANG_COMPLETE_ONLY
    glewExperimental = GL_TRUE;
    // Initialize GLEW to setup the OpenGL Function pointers
    if (glewInit() != GLEW_OK)
    {
        std::cout << "Failed to initialize GLEW" << std::endl;
        return -1;
    }    
#endif

    // Define the viewport dimensions
    // Corrected from the tutorial, should request framebuffer size instead.
    // Technically should also write a callback when the window is resized
    // with framebuffer_size_callback. See GLFW docs. This will do for now.
    int fbwidth, fbheight;
    glfwGetFramebufferSize(window, &fbwidth, &fbheight);

    // Options
    glViewport(0, 0, WIDTH, HEIGHT);
    glEnable(GL_DEPTH_TEST);

    // ---------- BEGIN OPENGL ----------- //
    
    // Shader creation
    Shader edgeShader("vertex_shader_unsliced.glsl", "fragment_shader_unsliced.glsl");

    // Data
    GLfloat vertices[] = {
        // Positions           
         0.6f,   0.6f,   0.6f,   0.6f,
         0.6f,  -0.6f,   0.6f,   0.6f,  
        -0.6f,  -0.6f,   0.6f,   0.6f,
        -0.6f,   0.6f,   0.6f,   0.6f,

         0.6f,   0.6f,  -0.6f,   0.6f,
         0.6f,  -0.6f,  -0.6f,   0.6f,
        -0.6f,  -0.6f,  -0.6f,   0.6f,
        -0.6f,   0.6f,  -0.6f,   0.6f,

         0.8f,   0.8f,   0.8f,  -0.8f,
         0.8f,  -0.8f,   0.8f,  -0.8f,  
        -0.8f,  -0.8f,   0.8f,  -0.8f,
        -0.8f,   0.8f,   0.8f,  -0.8f,

         0.8f,   0.8f,  -0.8f,  -0.8f,
         0.8f,  -0.8f,  -0.8f,  -0.8f,
        -0.8f,  -0.8f,  -0.8f,  -0.8f,
        -0.8f,   0.8f,  -0.8f,  -0.8f,
    };

    GLuint indices[] = {
        // Near Cube
         0,  2,  1,
         0,  3,  2,
         7,  5,  6,
         7,  4,  5,
         3,  4,  7,
         3,  0,  4,
         6,  1,  2,
         6,  5,  1,
         6,  3,  7,
         6,  2,  3,
         1,  4,  0,
         1,  5,  4,
        // Far Cube
         8, 10,  9,
         8, 11, 10,
        15, 13, 14,
        15, 12, 13,
        11, 12, 15,
        11,  8, 12,
        14,  9, 10,
        14, 13,  9,
        14, 11, 15,
        14, 10, 11,
         9, 12,  8,
         9, 13, 12,
        // Front Cube
         0,  2,  1,
         0,  3,  2,
        11,  9, 10,
        11,  8,  9,
         3,  0,  8,
         3,  8, 11,
        10,  1,  2,
        10,  9,  1,
        10,  3, 11,
        10,  2,  3,
         1,  8,  0,
         1,  9,  8,
        // Back Cube
         5,  7,  4,
         5,  6,  7,
        14, 12, 15,
        14, 13, 12,
         6,  5, 13,
         6, 13, 14,
        15,  4,  7,
        15, 12,  4,
        15,  6, 14,
        15,  7,  6,
         4, 13,  5,
         4, 12, 13,
        // Top Cube
         4,  7,  3,
         4,  3,  0,
        15,  8, 11,
        15, 12,  8,
         7, 12, 15,
         7,  4, 12,
         0, 11,  8,
         0,  3, 11,
         3,  7, 15,
         3, 15, 11,
         4,  0,  8,
         4,  8, 12,
        // Bottom Cube
         1,  2,  6,
         1,  6,  5,
        10, 13, 14,
        10,  9, 13,
         2,  9, 10,
         2,  1,  9,
         5, 14, 13,
         5,  6, 14,
         6,  2, 10,
         6, 10, 14,
         1,  5, 13,
         1, 13,  9,
        // Left Cube
         3,  7,  6,
         3,  6,  2,
        15, 11, 10,
        15, 10, 14,
        11, 15,  7,
        11,  7,  3,
        14,  2,  6,
        14, 10,  2,
         7, 15, 14,
         7, 14,  6,
        11,  3,  2,
        11,  2, 10,
        // Right Cube
         1,  5,  4,
         1,  4,  0,
        13,  9,  8,
        13,  8, 12,
         9, 13,  5,
         9,  5,  1,
        12,  0,  4,
        12,  8,  0,
         5, 13, 12,
         5, 12,  4,
         9,  1,  0,
         9,  0,  8,
    };

    // Textures

    // Set up buffer stuff
    GLuint VAO, VBO, EBO;
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    glGenBuffers(1, &EBO);
    
    // Game loop
    while (!glfwWindowShouldClose(window))
    {
        // Check if any events have been activated (key pressed, mouse moved
        // etc.) and call corresponding response functions
        glfwPollEvents();

        // Setup stuff
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        glLineWidth(3);

        // 4D-3D Transformations
        glm::mat4 model4D(1.0f), view4D;
        GLfloat theta = glm::radians((GLfloat)glfwGetTime() * 50.0f);
        GLfloat cs = cos(theta), sn = sin(theta);
        model4D[0][0] = cs;
        model4D[0][3] = -sn;
        model4D[3][0] = sn;
        model4D[3][3] = cs;
        glm::mat4x3 projection4D;
        glm::vec4 from(0.0f, 0.0f, 0.0f, 4.0f), to(0.0f, 0.0f, 0.0f, 0.0f); 
        glm::vec4 up(0.0f, 1.0f, 0.0f, 0.0f), over(0.0f, 0.0f, 1.0f, 0.0f);
        view4D = lookAt4D(from, to, up, over);

        std::cout << "View Mat: " << std::endl;
        printMat(view4D, 4, 4);

        projection4D = proj4D();

        GLfloat *projVert = new GLfloat[16*7];
        std::cout << "--------------------------------" << std::endl;
        for(int i = 0; i != 16; i++) {
            // Project each vertex to the 3D space
            glm::vec4 vert4(vertices[i*4], vertices[i*4+1],
                            vertices[i*4+2], vertices[i*4+3]);
            glm::vec4 viewVert = view4D * (model4D * vert4 - from); 
            glm::vec3 vert3 = projection4D * view4D * (model4D * vert4 - from);

            printVec(viewVert, 4);

            projVert[i*7] = vert3.x;
            projVert[i*7+1] = vert3.y;
            projVert[i*7+2] = vert3.z;
            if (i < 8) {
                projVert[i*7+3] = 1.0f;
                projVert[i*7+4] = 0.0f;
                projVert[i*7+5] = 0.0f;
            } else {
                projVert[i*7+3] = 0.0f;
                projVert[i*7+4] = 0.0f;
                projVert[i*7+5] = 1.0f;
            }
            projVert[i*7+6] = (viewVert.w + 5.0f)/2.0f;
        }

        // 3D-2D Transformations
        glm::mat4 view3D = glm::lookAt(glm::vec3(3.0f, 1.2f, 2.0f),
                                       glm::vec3(0.0f, 0.0f, 0.0f),
                                       glm::vec3(0.0f, 1.0f, 0.0f));
        glm::mat4 proj3D = glm::perspective(glm::radians(45.0f),
                                            (float)WIDTH/(float)HEIGHT,
                                            0.1f, 100.0f);
        // Shader Uniforms
        edgeShader.Use();

        GLint viewLoc = glGetUniformLocation(edgeShader.Program,
                                             "view3D");
        GLint projectionLoc = glGetUniformLocation(edgeShader.Program,
                                                   "projection3D");
        glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view3D));
        glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(proj3D));

        // Load Vertices
        glBindVertexArray(VAO);
        glBindBuffer(GL_ARRAY_BUFFER, VBO);
        glBufferData(GL_ARRAY_BUFFER, 16*7*sizeof(GL_FLOAT), projVert, GL_DYNAMIC_DRAW);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, 
                     GL_DYNAMIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 7*sizeof(GL_FLOAT), 
                              (GLvoid*)0);
        glEnableVertexAttribArray(0);
        glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 7*sizeof(GL_FLOAT), 
                              (GLvoid*)(3*sizeof(GL_FLOAT)));
        glEnableVertexAttribArray(1);

        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        glDrawElements(GL_TRIANGLES, 8*12*3, GL_UNSIGNED_INT, 0);
        glBindVertexArray(0);

        // Swap the screen buffers
        glfwSwapBuffers(window);

        delete[] projVert;
    }

    // Terminate GLFW, clearing any resources allocated by GLFW.
    glfwTerminate();
    glDeleteVertexArrays(1, &VAO);
    glDeleteBuffers(1, &VBO);
    glDeleteBuffers(1, &EBO);
    return 0;
}
示例#16
0
QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
{
    if (from.isNull() && to.isNull()) {
        return from;
    }

    if (qFuzzyCompare(amount + 1, qreal(1.0))) {
        return from;
    }

    QRect startRect(from.rect());
    QRect targetRect(to.rect());
    QSize pixmapSize = startRect.size().expandedTo(targetRect.size());
    QRect toRect = QRect(QPoint(0,0), pixmapSize);
    targetRect.moveCenter(toRect.center());
    startRect.moveCenter(toRect.center());

    //paint to in the center of from
    QColor color;
    color.setAlphaF(amount);

    // If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus
    QPaintEngine *paintEngine = from.paintEngine();
    if (paintEngine && 
        paintEngine->hasFeature(QPaintEngine::PorterDuff) &&
        paintEngine->hasFeature(QPaintEngine::BlendModes)) {
        QPixmap startPixmap(pixmapSize);
        startPixmap.fill(Qt::transparent);

        QPixmap targetPixmap(pixmapSize);
        targetPixmap.fill(Qt::transparent);

        QPainter p;
        p.begin(&targetPixmap);
        p.drawPixmap(targetRect, to);
        p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        p.fillRect(targetRect, color);
        p.end();

        p.begin(&startPixmap);
        p.drawPixmap(startRect, from);
        p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
        p.fillRect(startRect, color);
        p.setCompositionMode(QPainter::CompositionMode_Plus);
        p.drawPixmap(targetRect, targetPixmap);
        p.end();

        return startPixmap;
    }
#if defined(Q_WS_X11) && defined(HAVE_XRENDER)
    // We have Xrender support
    else if (paintEngine && paintEngine->hasFeature(QPaintEngine::PorterDuff)) {
        // QX11PaintEngine doesn't implement CompositionMode_Plus in Qt 4.3,
        // which we need to be able to do a transition from one pixmap to
        // another.
        //
        // In order to avoid the overhead of converting the pixmaps to images
        // and doing the operation entirely in software, this function has a
        // specialized path for X11 that uses Xrender directly to do the
        // transition. This operation can be fully accelerated in HW.
        //
        // This specialization can be removed when QX11PaintEngine supports
        // CompositionMode_Plus.
        QPixmap source(targetPixmap), destination(startPixmap);

        source.detach();
        destination.detach();

        Display *dpy = QX11Info::display();

        XRenderPictFormat *format = XRenderFindStandardFormat(dpy, PictStandardA8);
        XRenderPictureAttributes pa;
        pa.repeat = 1; // RepeatNormal

        // Create a 1x1 8 bit repeating alpha picture
        Pixmap pixmap = XCreatePixmap(dpy, destination.handle(), 1, 1, 8);
        Picture alpha = XRenderCreatePicture(dpy, pixmap, format, CPRepeat, &pa);
        XFreePixmap(dpy, pixmap);

        // Fill the alpha picture with the opacity value
        XRenderColor xcolor;
        xcolor.alpha = quint16(0xffff * amount);
        XRenderFillRectangle(dpy, PictOpSrc, alpha, &xcolor, 0, 0, 1, 1);

        // Reduce the alpha of the destination with 1 - opacity
        XRenderComposite(dpy, PictOpOutReverse, alpha, None, destination.x11PictureHandle(),
                         0, 0, 0, 0, 0, 0, destination.width(), destination.height());

        // Add source * opacity to the destination
        XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha,
                         destination.x11PictureHandle(),
                         toRect.x(), toRect.y(), 0, 0, 0, 0, destination.width(), destination.height());

        XRenderFreePicture(dpy, alpha);
        return destination;
    }
#endif
    else {
        // Fall back to using QRasterPaintEngine to do the transition.
        QImage under(pixmapSize, QImage::Format_ARGB32_Premultiplied);
        under.fill(Qt::transparent);
        QImage over(pixmapSize, QImage::Format_ARGB32_Premultiplied);
        over.fill(Qt::transparent);

        QPainter p;
        p.begin(&over);
        p.drawPixmap(targetRect, to);
        p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        p.fillRect(over.rect(), color);
        p.end();

        p.begin(&under);
        p.drawPixmap(startRect, from);
        p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
        p.fillRect(startRect, color);
        p.setCompositionMode(QPainter::CompositionMode_Plus);
        p.drawImage(toRect.topLeft(), over);
        p.end();

        return QPixmap::fromImage(under);
    }
}
示例#17
0
 void pop_first(ConstLine &a) {
     while (dq.size() > 1 and over(dq[1], dq[0], a))
         dq.pop_front();
 }
示例#18
0
void CWplayView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default	
	
	/*	(人人对战模式,且棋子为resource中画出来的,原)
	CDC Dc;
	CDC* pDC;
	CWplayDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	m_bmwhite.LoadBitmap(IDB_BITMAP1);//调入位图资源~~~~~~~~~~~~~~~~~~~~~~~~~~~啦啦啦啦
	m_bmblack.LoadBitmap(IDB_BITMAP2);
	
	  
		if(point.x>30&&point.x<410&&point.y>30&&point.y<410)
		{
		int px=(point.x-30)/20;
		int py=(point.y-30)/20;
		//是否已经有棋子
		if(colorwhite&&qz[px][py]==0)
		{
		//	Dc.SelectObject(m_bmwhite);
		//	pDC->BitBlt(px*20+32,py*20+32,160,160,&Dc,0,0,SRCCOPY);
		//表示存在白棋
		qz[px][py]=1;
		//检查是否结束
		//			over(point);
		//换黑棋下
		colorwhite=false;
		}
		else if(qz[px][py]==0)
		{
		//	Dc.SelectObject(m_bmblack);
		//	pDC->BitBlt(px*20+32,py*20+32,160,160,&Dc,0,0,SRCCOPY);
		qz[px][py]=-1;
		//			over(point);
		colorwhite=true;
		}
}*/
	
	
	
	//更改后的--------------------------------------------------------
	if(startflag==1)
	{
		CDC *pDC=GetDC();
		CDC Dc;
		if(Dc.CreateCompatibleDC(pDC)==FALSE)
			AfxMessageBox("Can't create DC");
		//显示棋子
		
		//重画棋子!!!!!!!!!(每次视图的更新,使每一次第一个的特殊棋子实现自动更改)		
		for(int n=0;n<19;n++)
			for(int m=0;m<19;m++)
				if(qz[n][m]==1)
				{
					//显示白棋
					Dc.SelectObject(m_bmwhite);
					pDC->BitBlt(n*20+32,m*20+32,160,160,&Dc,0,0,SRCCOPY);	
				}
				else if(qz[n][m]==-1)
				{
					//显示黑棋
					Dc.SelectObject(m_bmblack);
					pDC->BitBlt(n*20+32,m*20+32,160,160,&Dc,0,0,SRCCOPY);	
				}
				
				//人人简单模式
				
				if(point.x>30&&point.x<410&&point.y>30&&point.y<410)
				{
					int px=(point.x-30)/20;
					int py=(point.y-30)/20;
					if(colorwhite&&qz[px][py]==0)
					{
						Dc.SelectObject(m_bmwhiteh);
						pDC->BitBlt(px*20+32,py*20+32,160,160,&Dc,0,0,SRCCOPY);
						qz[px][py]=1;
						over(point);
						colorwhite=false;
					}
					else if(qz[px][py]==0)
					{
						Dc.SelectObject(m_bmblackh);
						pDC->BitBlt(px*20+32,py*20+32,160,160,&Dc,0,0,SRCCOPY);
						qz[px][py]=-1;
						over(point);
						colorwhite=true;
					}
				}
				
	}			
	/*---------------实现类视图在内存中的暂时保存-------------
	ReleaseCapture();//取消鼠标捕获
	m_bLButtonDown=false;//标志复原
	
	  CClientDC dc(this);//建立DC
	  
		if(!m_dcCompatible.m_hDC)//若兼容DC未建立,则建立之  
		{  
		m_dcCompatible.CreateCompatibleDC(&dc);  
		}
		
		  //将视图区保存为位图
		  CRect rect; 
		  GetClientRect(&rect);  
		  CBitmap bitmap;  
		  bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());  
		  
			//兼容DC与位图产生关联
			m_dcCompatible.SelectObject(&bitmap); 
			
			  //将设备描述表复制到兼容DC中
			  m_dcCompatible.BitBlt(0,0,rect.Width(),rect.Height(),&dc,0,0,SRCCOPY);   
	*/
	CView::OnLButtonUp(nFlags, point);
}
示例#19
0
文件: client.cpp 项目: tinnfu/ftp
int client::dispatch()
{
    char cmd_type =
        m_command_checker.get_command_type(m_cmd[0]);

    if( is_command_type(CMD_ERR, cmd_type) )
    {
        return -1;
    }

    int res = 0;

    switch(cmd_type)
    {
        case CMD_CLEAR:
            clear();
            break;

        case CMD_LS:
            res = ls();
            break;

        case CMD_CD:
            cd();
            break;

        case CMD_CDLOCAL:
            cdlocal();
            break;

        case CMD_CDREMOTE:
            cdremote();
            break;

        case CMD_RM:
            res = rm();
            break;

        case CMD_MKDIR:
            res = mkdir();
            break;

        case CMD_PWD:
            pwd();
            break;

        case CMD_EXIT:
            over();
            break;

        case CMD_UPLD:
            res = upload();
            break;

        case CMD_DWLD:
            res = download();
            break;

        default:
            break;
    }


    return res;
}
示例#20
0
void IntCell::Draw(wxPoint point, int fontsize)
{
  MathCell::Draw(point, fontsize);
  CellParser *parser = CellParser::Get();

  if (DrawThisCell(point) && InUpdateRegion())
  {
    wxDC& dc = parser->GetDC();
    double scale = parser->GetScale();

    wxPoint base(point), under(point), over(point), var(point), sign(point);

    if (parser->CheckTeXFonts())
    {
      SetForeground();
      int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5));
      dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN,
			wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
                        parser->GetTeXCMEX()));
      dc.DrawText(wxT("\x5A"),
                  sign.x,
                  sign.y - m_signTop);
    }
    else
    {
#if defined __WXMSW__
      SetForeground();
      int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5));
      int m_signWCenter = m_signWidth / 2;

      dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN,
			wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
			false,
                        parser->GetSymbolFontName()));
      dc.DrawText(INTEGRAL_TOP,
                  sign.x + m_signWCenter - m_charWidth / 2,
                  sign.y - (m_signSize + 1) / 2);
      dc.DrawText(INTEGRAL_BOTTOM,
                  sign.x + m_signWCenter - m_charWidth / 2,
                  sign.y + (m_signSize + 1) / 2 - m_charHeight);

      int top, bottom;
      top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2;
      bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2;
      if (top <= bottom)
      {
        wxASSERT_MSG(m_charHeight>=2,_("Font issue: The char height is too small! Installing http://www.math.union.edu/~dpvc/jsmath/download/jsMath-fonts.html and checking \"Use JSmath fonts\" in the configuration dialogue should be a workaround."));
        if(m_charHeight <= 2)
          m_charHeight = 2;
        
        while (top < bottom)
        {
          dc.DrawText(INTEGRAL_EXTEND,
		      point.x + m_signWCenter - m_charWidth / 2,
		      top);
          top += (2*m_charHeight)/3;
        }
        dc.DrawText(INTEGRAL_EXTEND,
		    point.x + m_signWCenter - m_charWidth / 2,
		    sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2);
      }
#else
      SetPen();
      // top decoration
      int m_signWCenter = m_signWidth / 2;
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1,
                  sign.x + m_signWCenter + SCALE_PX(3, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale));
      dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale),
                  sign.x + m_signWCenter + SCALE_PX(6, scale),
                  sign.y - (m_signSize + 1) / 2);
      dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale),
                  sign.y - (m_signSize + 1) / 2,
                  sign.x + m_signWCenter + SCALE_PX(9, scale),
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale));
      // bottom decoration
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1,
                  sign.x + m_signWCenter - SCALE_PX(3, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale));
      dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale),
                  sign.x + m_signWCenter - SCALE_PX(6, scale),
                  sign.y + (m_signSize + 1) / 2);
      dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale),
                  sign.y + (m_signSize + 1) / 2,
                  sign.x + m_signWCenter - SCALE_PX(9, scale),
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale));
      // line
      dc.DrawLine(sign.x + m_signWCenter,
                  sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1,
                  sign.x + m_signWCenter,
                  sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1);
      UnsetPen();
#endif
    }

    if (m_intStyle == INT_DEF)
    {
      under.x += m_signWidth;
      under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) -
                m_signSize / 3;
      m_under->DrawList(under, MAX(MC_MIN_SIZE, fontsize - 5));

      if (parser->CheckTeXFonts())
        over.x += 2*m_signWidth;
      else
        over.x += m_signWidth;

      over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) +
               m_signSize / 3;
      m_over->DrawList(over, MAX(MC_MIN_SIZE, fontsize - 5));

      if (parser->CheckTeXFonts())
      {
        base.x += m_signWidth +
                  MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale));
      }
      else
        base.x += m_signWidth +
                  MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale));
    }

    else if (parser->CheckTeXFonts())
      base.x += 2*m_signWidth;
    else
      base.x += m_signWidth;

    m_base->DrawList(base, fontsize);

    var.x = base.x + m_base->GetFullWidth(scale);
    m_var->DrawList(var, fontsize);
  }
}
示例#21
0
bool_ CTransaction::__onTimer(const Message::TPDUOnTimer *msg) {
	if (_keepLiveTimerId == msg->timerId) {
		if (_status != (ETransactionStatus)msg->parameter) {
			log_debug("[%p]CTransaction::onTimer: timer status(%d) != "
					"current(%d) status", this, msg->parameter, _status);

			return true_v;
		}

		if (ETransactionStatus::CONNECTED == _status) {
			log_debug("[%p]CTransaction::onTimer: waiting handshake timeout, "
					"current status-%d", this, _status);

			return over(ETransactionExitReason::TIME_OUT);
		} else if (ETransactionStatus::READY == _status) {
			if (false_v == _heartbeat) {
				log_debug("[%p]CTransaction::onTimer: heartbeat timeout, "
						"current status-%d", this, _status);

				return over(ETransactionExitReason::TIME_OUT);
			} else {
				Message::TPDUHeartBeat message;

				message.header.size = sizeof(Message::TPDUHeartBeat);
				message.header.type = Message::MT_CONTROL;
				message.header.cmd = Message::MC_HEART_BEAT;
				message.header.ver = Config::App::PROTOCOL_VERSION;
				message.header.lang = 1;
				message.header.seq = 0;

				__send((Message::TMsg *) &message, false_v);
				_heartbeat = false_v;
			}
		} else {
			assert(false_v);
		}

	} else {
		if (ETransactionStatus::READY != _status) {
			log_debug("[%p]CTransaction::onTimer: seq(%u)'s status(%d) is "
					"expected, but now it's status(%d)", this, msg->parameter,
					ETransactionStatus::READY, _status);

			return true_v;
		}

		ub4_ seq = (ub4_) msg->parameter;
		MapSeq2Timer::iterator pos = _mapSeq2Timer.find(seq);

		if (_mapSeq2Timer.end() != pos) {
			log_debug("[%p]CTransaction::onTimer: waitting ack timeout, "
					"current status-%d, seq-%u", this, _status, seq);

			return over(ETransactionExitReason::TIME_OUT);
		} else {
			assert(false_v);
		}
	}

	return true_v;
}
示例#22
0
bool Button::releasedOutside() {
    return (!down() && downChanged() && !over());
}
示例#23
0
void main()
{
	/*Declarations*/
	dynamic_game_data q;
	q.createlist();
	int gd=DETECT;
	int gm;
	initgraph(&gd,&gm, "C:\\TC\\BGI");
	intro();
	start();
	int a;
	int i=-1;
	int b=1;
	int score=-1; //result increments the val
	char press;
  
  
	/*Time declarations*/
  
	time_t start;
	time_t end; //time_t variables can store values returned by time function
	time(&start); //stores the current time in start
	time(&end); //stores the current time in end
	int diff;
	diff=difftime(end,start); //stores the time elapsed
	srand(time(0)); //stdlib.h, time(0)
  
	while(b && diff<=30) //run while b is true and time elapsed is less than 30 secs
	{
	 
		 bar(diff); //shows the time bar
		 a=rnd(); //get the next box using randomize func
		 grid(); //draw the grid again else the old boxes wont go away
		 q.set(0,a); //store the value in our grid array
		
		
		 if(i<=3) //wait for array to get filled
		 {
			 i++;
		 }
		
		
		 for(int k=0; k<4; k++) //fill the colour
		 {
		  
			fill(q.get(k)); //color the boxes corresponding to our grid array
		 }
		
		
		 if(i>=3) //dont start game until array is filled
		 {
			  score++; //score keeper integer
			  press=getch(); //get the key-press
			 
			  switch(press)
			  {
				 case 27: //escape key ascii
				 exit(0);
				
				 /*
					If the key-press and the last number in our array is same
					then show green colour on the button else red.
				 */
				 case 'a': // Button 'a' from keyboard
				 if(q.get(3)==10)
				 {
					 setfillstyle(SOLID_FILL, GREEN);
				 }
				 else
				 {
					 b=0;
					 setfillstyle(SOLID_FILL, RED);
				 }

				 floodfill((getmaxx()*3/4)*1/4+1,getmaxy()*3/4+1,3);
				 break;



				 case 's': // Button 's' from keyboard
				 if(q.get(3)==11)
				 {
					 setfillstyle(SOLID_FILL, GREEN);
				 }
				 else
				 {
					 b=0;
					 setfillstyle(SOLID_FILL, RED);
				 }
				 floodfill((getmaxx()*3/4)*2/4+1,getmaxy()*3/4+1,3);
				 break;

				
				 case 'd': // Button 'd' from keyboard
				 if(q.get(3)==12)
				 {
					 setfillstyle(SOLID_FILL, GREEN);
				 }
				 else
				 {
					 b=0;
					 setfillstyle(SOLID_FILL, RED);
				 }
				 floodfill((getmaxx()*3/4)*3/4+1,getmaxy()*3/4+1,3);
				 break;

				
				 default: //if any other key is pressed
				 b=0; //set b to zero to end the game
			  }
		 }

		
		 for(int f=0; f<=i; f++) //move the box down
		 {
			 q.set(f,q.get(f)+3);
		 }



		 //q.arr[f]+=3 ;
		 for(int d=3; d>=1; d--)
		 {
			 q.set(d,q.get(d-1));
		 }



		 //q.arr[d]=q.arr[d-1]; //shifts the array to the right to accomodate new val
		 delay(100);
		 cleardevice();
		 time(&end); //get the time
		 diff=difftime(end,start); //update time elapsed
	}
  
  
  

	cleardevice();
	over();

	/*Displays the scores*/
	/*Uses file handling*/
	fstream scores("scores.txt",ios::ate | ios::in | ios::out); //Open the file in read,write,append-to-end mode
	gotoxy(28,10); 
	cout << "Your score was " << score;
	gotoxy(27,12);
	cout << "Enter your name: ";
	char name[20];
	cin >> name;



	if(scores)
	{
		scores<< endl << name << " " << score ; //write the name and score to the file
	}

	else
	{
		cout << "Unable to save score!";
	}
	
  
	cout << endl << endl<< "Scores: " << endl << endl;
	scores.seekg(ios::beg);  //move the pointer to the starting of file

	while(!scores.eof()) //display al the previous score
	{
	  scores.getline(name,20,' ');
	  cout << '\t' << name;
	  scores.getline(name,20);
	  cout << '\t' << name << endl;
	}
	getch();
}
示例#24
0
//this sets the parameters of the class DavidsonHarel, adds the energy functions and
//starts the optimization process
void DavidsonHarelLayout::call(GraphAttributes &AG)
{
	// all edges straight-line
	AG.clearAllBends();

	DavidsonHarel dh;
	Repulsion rep(AG);
	Attraction atr(AG);
	Overlap over(AG);
	Planarity plan(AG);
	//PlanarityGrid plan(AG);
	//PlanarityGrid2 plan(AG);
	//NodeIntersection ni(AG);

	// Either use a fixed value...
	if (DIsGreater(m_prefEdgeLength, 0.0))
	{
		atr.setPreferredEdgelength(m_prefEdgeLength);
	}
	// ...or set it depending on vertex sizes
	else atr.reinitializeEdgeLength(m_multiplier);
	 

	dh.addEnergyFunction(&rep,m_repulsionWeight);
	dh.addEnergyFunction(&atr,m_attractionWeight);
	dh.addEnergyFunction(&over,m_nodeOverlapWeight);
	if (m_crossings) dh.addEnergyFunction(&plan,m_planarityWeight);
	//dh.addEnergyFunction(&ni,2000.0);

	//dh.setNumberOfIterations(m_numberOfIterations);
	//dh.setStartTemperature(m_startTemperature);
	const Graph& G = AG.constGraph();
	//TODO: Immer Anzahl Iterationen abhängig von Größe
	if (m_numberOfIterations == 0)
	{
		switch (m_speed)  //todo: function setSpeedParameters
		{
		  case sppFast: {
				          m_numberOfIterations = max(75, 3*G.numberOfNodes()); 
						  m_startTemperature = 400;
						} break;
		  case sppMedium: {
				            m_numberOfIterations = 10*G.numberOfNodes(); 
							m_startTemperature = 1500;
						  } 
				          break;
		  case sppHQ: {
				        m_numberOfIterations = 2500*G.numberOfNodes(); //should be: isolate
						m_startTemperature = 2000;
					  } 
					  break;
		  default: OGDF_THROW_PARAM(AlgorithmFailureException, afcIllegalParameter); break;
		}//switch
	}//if
	else
	{
		if (m_itAsFactor)
			dh.setNumberOfIterations(200+m_numberOfIterations*G.numberOfNodes());
		else
			dh.setNumberOfIterations(m_numberOfIterations);
	}
	dh.setStartTemperature(m_startTemperature);
	dh.call(AG);
}
示例#25
0
文件: ct.c 项目: EdKeith/core
static F1(jttpoly){A z;
 RZ(w);
 RZ(z=atop(amp(ds(CLBRACE),over(AT(w)&CMPX?w:xco1(w),zero)),amp(tally(w),ds(CMIN))));
 VAV(z)->flag=VTAYFINITE;
 R z;
}
示例#26
0
int main(int argc, char* argv[])
{
	int i, j;
	FILE *fp;
	
	/* read the equitions in */
	if (argc == 2) {
		if ((fp = fopen(argv[1], "r"))) {
			/* get the dimension of the matrix */
        		fscanf(fp, "%d", &dimen);
			
			/* malloc the space */
			matrix = (double**)malloc(dimen * sizeof(double*));
			for (i = 0; i < dimen; i++) {
				matrix[i] = (double*)malloc((dimen + 1) * sizeof(double));
			}
			res = (double*)malloc(dimen * sizeof(double));
			res2 = (double*)malloc(dimen * sizeof(double));
			
			/* initialization */
			for (i = 0; i < dimen; i++) {
				res[i] = 1;	// (x' - x) > ERR 
				res2[i] = 0;
			}

			/* read data */
			for (i = 0; i < dimen; i++) {
				for (j = 0; j < dimen + 1; j++) {
					fscanf(fp, "%lf", &(matrix[i][j]));
				}
			}
			fclose(fp);
		} else {
			return -1;
		}
	} else {
		return -1;
	}
	//printf("Original: \n");
	//show();

	/* recurrence relation */
	while (!over()) {
		recJacobi();
		//recGuassSeidel();
	}

	/* print result */
	printf("x = [ ");
	for(i = 0; i < dimen; i++) {
		printf("%.6lf ", res2[i]);
	}
	printf("];\n");

	/* free the space */
	for (i = 0; i < dimen; i++) {
		free(matrix[i]);
	}
	free(matrix);
	free(res);
	free(res2);
}
示例#27
0
void test_over() {
  over(0);
  over(0.0f);
}
示例#28
0
文件: 源.cpp 项目: 3588/au-cs433
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
       
        
        
          PAINTSTRUCT ps;
       
          static     HPEN    hpen,hpen1,hpen2;
          static HBRUSH hbrush,hbrush1,hbrush2;
          int x,y;
       
      switch (message)                    /* handle the messages */
      {
          case WM_KEYDOWN:
               switch (wParam)
                {
                      case VK_F5:
                            Init(hwnd);
                     Rectangle(hdc,0,0,xw,yw);
                       for(x=0;x<MAX;x++)
                         for(y=0;y<MAX;y++)
                           {
                             Rectangle(hdc,x*xw/MAX,y*yw/MAX,(x+1)*xw/MAX,(y+1)*yw/MAX) ;
                              iGame[x][y]=Default;
                           }
                            SetTimer(hwnd,Time1,times,NULL);
                             leng=1;
                             plays=Play;
                           break;
                      case VK_F1:
                           break;
                      case VK_F2:
                         
                             SetTimer(hwnd,Time1,times,NULL);
                             leng=1;
                             plays=Play;
                             break; 
                      case VK_F3:
                           if(plays==Play)
                             {
                                 KillTimer(hwnd,Time1);
                                 plays=Paush;         
                             }
                             else
                             if(plays==Paush)
                               {
                                 SetTimer(hwnd,Time1,times,NULL);
                                 plays=Play;
                               }
                           
                           break;                
                }
               break;
          case WM_TIMER:
                  switch (wParam)
                    {
                      case Time1:
                       timechage(hwnd);
                              break;     
                    }      
               break;        
          case WM_CREATE:
                plays=Stop;
                play=Player1;
               break;
          case WM_SIZE:
               xw=LOWORD(lParam);
               yw=HIWORD(lParam);
               xw-=TextWidth;
               InvalidateRect(hwnd,NULL,TRUE);
            
               break;
          case WM_LBUTTONDOWN:
                //获取但前鼠标坐标 
                point.x=LOWORD(lParam);
                point.y=HIWORD(lParam);
                //初始化设备DC 
                 Init(hwnd);
                //鼠标坐标换为数组坐标 
                x=(point.x)/(xw/MAX);
                y=(point.y)/(yw/MAX);
             if(plays==Stop)break;
           
             if(x<MAX&&y<MAX)
             {
                          
                  if(iGame[x][y]==Default&&plays==Play)//判断但前位置是否有棋子覆盖 
                  { 
                       leng=1;
                      paint(play,x,y);
                      if(Look(x,y,play))
                        over(hwnd,play);

                      chagePlayer();  
                    
                  }      
             }


               break;        
          case WM_PAINT:
             
               hdc=BeginPaint(hwnd,&ps);
               Init(hwnd);


               Rectangle(hdc,0,0,xw,yw);
               for(x=0;x<MAX;x++)
                  for(y=0;y<MAX;y++)
                  {
                    Rectangle(hdc,x*xw/MAX,y*yw/MAX,(x+1)*xw/MAX,(y+1)*yw/MAX) ;
                    paint(iGame[x][y],x,y);
                  }
               EndPaint(hwnd,&ps);
               break;   
          case WM_DESTROY:
              PostQuitMessage (0);         /* send a WM_QUIT to the message queue */
              break;
          default:                        /* for messages that we don't deal with */
              return DefWindowProc (hwnd, message, wParam, lParam);
      }

      return 0;
}
示例#29
0
void testApp::draw(){
	
	/*************************************************************/
	/********************* setup scene rendering *****************/
	/*************************************************************/

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	ofEnableSmoothing();
	ofEnableAlphaBlending();
	cam.orbit(180, 0, distance, ofVec3f(0,0,distance));	
	cam.begin();
	
	/*************************************************************/
	/*********************** draw calibrate pose *****************/
	/*************************************************************/
	
	if (state=="TRACK_FLASH") 
	{
		flash();
	}
	
	/**************************************************************/
	/********** setup drawing particle system *********************/
	/**************************************************************/
	
	particleSystem.setTimeStep(timeStep);
	ofSetColor(255, 255, 255, lineOpacity);
	particleSystem.setupForces();
	glPushMatrix();
	glTranslatef(-ofGetWidth()/2, -ofGetHeight()/2, 600);
	
	// apply per-particle forces
	glBegin(GL_LINES);
	for(int i = 0; i < particleSystem.size(); i++) 
	{
		Particle& cur = particleSystem[i];
		
		// global force on other particles
		particleSystem.addRepulsionForce(cur, particleNeighborhood, particleRepulsion);
		
		// forces on this particle
		cur.bounceOffWalls(ofGetWidth()/3, 0, (ofGetWidth()*2)/3, ofGetHeight());
		cur.addDampingForce();
		
	}
	glEnd();
	
	/**************************************************************/
	/********************** draw silhouette ***********************/
	/**************************************************************/

	// kinect skeleton
	if (state=="TRACK_USER" || state=="ACTIVATE") {
		printf("kinect skeleton");
		particleSystem.addRepulsionForce((jointPosTorso.position.X+ofGetWidth())/2 , (jointPosTorso.position.Y/2.5)+(ofGetHeight()/2)+90, 90, 10);
		particleSystem.addRepulsionForce((jointPosHead.position.X+ofGetWidth())/2 , (jointPosHead.position.Y/2.5)+(ofGetHeight()/2)+90, 70, 10);		
		particleSystem.addRepulsionForce((jointPosNeck.position.X+ofGetWidth())/2 , (jointPosNeck.position.Y/2.5)+(ofGetHeight()/2)+90, 60, 10);		
		particleSystem.addRepulsionForce((half(jointPosTorso.position.X, jointPosNeck.position.X)+ofGetWidth())/2, (half(jointPosTorso.position.Y, jointPosNeck.position.Y)/2.5)+(ofGetHeight()/2)+90, 90, 10);
		particleSystem.addRepulsionForce((jointPosRShoulder.position.X+ofGetWidth())/2 , (jointPosRShoulder.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((jointPosRElbow.position.X+ofGetWidth())/2 , (jointPosRElbow.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++) 
			particleSystem.addRepulsionForce((over(jointPosRElbow.position.X,jointPosRShoulder.position.X, i)+ofGetWidth())/2, (over(jointPosRElbow.position.Y, jointPosRShoulder.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((jointPosLShoulder.position.X+ofGetWidth())/2 , (jointPosLShoulder.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((jointPosLElbow.position.X+ofGetWidth())/2 , (jointPosLElbow.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++) 
			particleSystem.addRepulsionForce((over(jointPosLElbow.position.X,jointPosLShoulder.position.X, i)+ofGetWidth())/2, (over(jointPosLElbow.position.Y, jointPosLShoulder.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((jointPosLHand.position.X+ofGetWidth())/2 , (jointPosLHand.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++) 
			particleSystem.addRepulsionForce((over(jointPosLElbow.position.X,jointPosLHand.position.X, i)+ofGetWidth())/2, (over(jointPosLElbow.position.Y, jointPosLHand.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosLFinger.position.X/2+ofGetWidth()/2 , (jointPosLFinger.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((jointPosRHand.position.X+ofGetWidth())/2 , (jointPosRHand.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++)		
			particleSystem.addRepulsionForce((over(jointPosRElbow.position.X, jointPosRHand.position.X, i)+ofGetWidth())/2, (over(jointPosRElbow.position.Y, jointPosRHand.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosRFinger.position.X/2+ofGetWidth()/2 , (jointPosRFinger.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce((half(jointPosLHip.position.X, jointPosRHip.position.X)+ofGetWidth())/2, (half(jointPosLHip.position.Y, jointPosRHip.position.Y)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosLHip.position.X/2+ofGetWidth()/2 , (jointPosLHip.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosLKnee.position.X/2+ofGetWidth()/2 , (jointPosLKnee.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++)
			particleSystem.addRepulsionForce((over(jointPosLHip.position.X,jointPosLKnee.position.X, i)+ofGetWidth())/2, (over(jointPosLHip.position.Y, jointPosLKnee.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosRHip.position.X/2+ofGetWidth()/2 , (jointPosRHip.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosRKnee.position.X/2+ofGetWidth()/2 , (jointPosRKnee.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++)
			particleSystem.addRepulsionForce((over(jointPosRHip.position.X,jointPosRKnee.position.X, i)+ofGetWidth())/2, (over(jointPosRHip.position.Y, jointPosRKnee.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosLAnkle.position.X/2+ofGetWidth()/2, (jointPosLAnkle.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++)
			particleSystem.addRepulsionForce((over(jointPosLAnkle.position.X, jointPosRKnee.position.X, i)+ofGetWidth())/2, (over(jointPosLAnkle.position.Y, jointPosRKnee.position.Y, i)/2.5)+(ofGetHeight()/2)+90, 50, 10);	
		particleSystem.addRepulsionForce(jointPosLFoot.position.X/2+ofGetWidth()/2 , (jointPosLFoot.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosRAnkle.position.X/2+ofGetWidth()/2, (jointPosRAnkle.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);
		for (int i=2; i<10; i++)
			particleSystem.addRepulsionForce((over(jointPosRAnkle.position.X,jointPosRKnee.position.X,i)+ofGetWidth())/2, (over(jointPosRAnkle.position.Y, jointPosRKnee.position.Y,i)/2.5)+(ofGetHeight()/2)+90, 50, 10);
		particleSystem.addRepulsionForce(jointPosRFoot.position.X/2+ofGetWidth()/2 , (jointPosRFoot.position.Y/2.5)+(ofGetHeight()/2)+90, 50, 10);

	}
	
	
	// piavca skeleton
	if (state=="PLAYING_MOTION") {
		printf("piavca skeleton \n");
		
		glPushMatrix();
		glTranslatef(0, 1000, 0);
		ofxPiavca::draw();
		glPopMatrix();
		
		printf("piavca meow \n");
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 Head")) ) 
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Head"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Head"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 70, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 Neck")) ) 
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Neck"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Neck"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 60, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 Pelvis")) ) 	
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Pelvis"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Pelvis"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 90, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 Spine")) ) 
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Spine"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 Spine"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 90, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Forearm")) ) {
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Forearm"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Forearm"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
			check=true;
		}
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Clavicle")) ) {
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Clavicle"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Clavicle"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		}
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Forearm")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Forearm"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Forearm"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Clavicle")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Clavicle"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Clavicle"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Upperarm")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Upperarm"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Upperarm"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Upperarm")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Upperarm"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Upperarm"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Hand")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Hand"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Hand"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Hand")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Hand"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Hand"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Thigh")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Thigh"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Thigh"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Thigh")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Thigh"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Thigh"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Calf")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Calf"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Calf"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Calf")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Calf"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Calf"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 R Foot")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Foot"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 R Foot"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
		
		if ( !av->isNull(Piavca::Core::getCore()->getJointId("Bip001 L Foot")) )
			particleSystem.addRepulsionForce((-av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Foot"), Piavca::WORLD_COORD)[0]*9)+ofGetWidth()/2, (av->getJointBasePosition(Piavca::Core::getCore()->getJointId("Bip001 L Foot"), Piavca::WORLD_COORD)[2]*9)+ofGetHeight()/2+40, 50, 10);
	
		printf("piavca meow \n");
	
	}
	
	
	particleSystem.addAttractionForce(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), centerAttraction);
	particleSystem.update();
	ofSetColor(255, 255, 255, pointOpacity);
	particleSystem.draw();
	ofDisableAlphaBlending();
	
	ofSetColor(255, 255, 255);
	ofDrawBitmapString(ofToString(kParticles) + "k particles", 32, 32);
	ofDrawBitmapString(ofToString((int) ofGetFrameRate()) + " fps", 32, 52);	
	glPopMatrix();

	cam.end();

	ofDisableLighting();
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_CULL_FACE);
	glDisable(GL_LIGHT0);
	glDisable(GL_LIGHTING);	


}
示例#30
0
bool Button::draggedOutside() {
    return (!down() && downChanged() && !over() && overChanged());
}