Esempio n. 1
0
int main(void)
{
	int done = 0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n = 0;

	//declare a box shape
	//game.box.width = 100;
	//game.box.height = 10;
	//game.box.center.x = 120 + 5*65;
	//game.box.center.y = 500 - 5*60;

	//start animation
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e);
		}
		movement(&game);
		render(&game);
		bubbles(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
  FILE *fp;
  int i, j;
  int n[N];

  if(argc < 2){  
    fprintf(stderr, "Arguments\n"); 
    return -1;
  }
  
  fp = fopen(argv[1], "r"); 
  
  if(fp == NULL){  
    fprintf(stderr, "CAN NOT OPEN\n");    
    return -1; 
  } 
   
  for(j = 0; j < N && (fscanf(fp, "%d", &i) != EOF); j++)
    n[j] = i;
  
  fclose(fp);
  
  i = 0; 
  bubbles(n, j);
  
  return 0;
}
Esempio n. 3
0
PassRefPtr<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
{
    ASSERT(iframe);
    RefPtr<MouseEvent> clonedMouseEvent = MouseEvent::create();
    Frame* frame = iframe->document().frame();
    FrameView* frameView = frame ? frame->view() : 0;
    clonedMouseEvent->initMouseEvent(type(), bubbles(), cancelable(),
        iframe->document().defaultView(),
        detail(), screenX(), screenY(),
        frameView ? adjustedClientX(clientX(), iframe, frameView) : 0,
        frameView ? adjustedClientY(clientY(), iframe, frameView) : 0,
        ctrlKey(), altKey(), shiftKey(), metaKey(),
        button(),
        // Nullifies relatedTarget.
        0);
    return clonedMouseEvent.release();
}
Esempio n. 4
0
void BubbleConfig::read(std::istream& stream) {
  int nFrameBuckets;
  stream.read(reinterpret_cast<char*>(&nFrameBuckets), sizeof(nFrameBuckets));
  this->clear();
  for (int i = 0; i < nFrameBuckets; i++) {
    int frame, nBubbles;

    stream.read(reinterpret_cast<char*>(&frame), sizeof(frame));
    stream.read(reinterpret_cast<char*>(&nBubbles), sizeof(nBubbles));
    std::vector<Bubble> bubbles(nBubbles);

    stream.read(reinterpret_cast<char*>(bubbles.data()), sizeof(Bubble)*nBubbles);

    this->addBubbles(frame, bubbles);

  }
}
Esempio n. 5
0
Ref<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
{
    ASSERT(iframe);
    Frame* frame = iframe->document().frame();
    FrameView* frameView = frame ? frame->view() : nullptr;
    Ref<MouseEvent> clonedMouseEvent = MouseEvent::create(type(), bubbles(), cancelable(),
        iframe->document().defaultView(),
        detail(), screenX(), screenY(),
        frameView ? adjustedClientX(clientX(), iframe, frameView) : 0,
        frameView ? adjustedClientY(clientY(), iframe, frameView) : 0,
        ctrlKey(), altKey(), shiftKey(), metaKey(),
        button(),
        syntheticClickType(),
        // Nullifies relatedTarget.
        0);
    clonedMouseEvent->setForce(force());
    return WTFMove(clonedMouseEvent);
}
Esempio n. 6
0
void simulateGeometry(size_t frameRate,
                      double minRadius, // in mm
                      double maxRadius, // in mm
                      double simDuration, // in seconds
                      size_t numBubbles, // over lifetime of simulation
                      const std::string &outputDir) {
 
  std::vector<FakeBubbleStats> bubbleStats(numBubbles);
  std::vector<Bubble *> bubbles(numBubbles);
  
  size_t numFrames = ceil(frameRate * simDuration);
  double dt = 1.0 / double(frameRate);
  
  // initialize random bubble stats
  for (size_t i = 0; i < numBubbles; i++) {
    bubbleStats[i].bubbleBirthtime = random_double(0.02, simDuration * 0.95);
    bubbleStats[i].bubbleRadius = random_double(minRadius, maxRadius);
    std::cout << "bubbleRadius: " << bubbleStats[i].bubbleRadius << std::endl;
    
    bubbleStats[i].isBubbleBorn = false;
    bubbleStats[i].isBubbleDead = false;
  }
  
  // initialize bubble objects
  for (size_t i = 0; i < numBubbles; i++) {
    bubbles[i] = new Bubble();
    TriangleMesh *currBubble = new TriangleMesh;
    
    // yep, for now a different copy of each
    currBubble->read(baseDir + "bubble_lr.obj", MFF_OBJ);
    
    // constant is here because starting size of bubbles is 5mm radius
    double ds = bubbleStats[i].bubbleRadius / 5.0;
    
    currBubble->scale(Vector3d(ds, ds, ds));
    
    double dx = random_double(-0.05, +0.05);
    double dz = random_double(-0.05, +0.05);
    Vector3d dpos(dx,0,dz);
    //currBubble->translate(dpos);  // TODO: uncomment this line to randomizing starting position
    
    bubbles[i]->setBubbleMesh(currBubble);
    
  }
  
  std::string solidPrefix = "solid_";
  std::string airPrefix = "air_";
  std::string bubblePrefix = "bubble_";
  
  for (size_t f = 0; f < numFrames; f++) {
    
    double currTime = f * dt;
    
    std::string zeropadFrameNum = ZeroPadNumber(f, 6);

    // add a bit of random vertical motion to the fluid surface
    //airMesh->jitter(Vector3d(0,0.0005,0));
    
    solidMesh->write(outputDir + solidPrefix + zeropadFrameNum + ".obj", MFF_OBJ);
    airMesh->write(outputDir + airPrefix + zeropadFrameNum + ".obj", MFF_OBJ);
    
    // advect all the bubbles for each timestep
    for (size_t b = 0; b < numBubbles; b++) {
      
      if (bubbleStats[b].bubbleBirthtime <= currTime) {
        bubbleStats[b].isBubbleBorn = true;
      }
      
      
      // check whether bubble has peeked above the surface
      if (bubbleStats[b].isBubbleBorn && !bubbleStats[b].isBubbleDead) {
        BoundingBox airbbox, bubbbox;
        airMesh->getBoundingBox(airbbox);
        bubbles[b]->getBubbleMesh()->getBoundingBox(bubbbox);
        
        // rough crappy rule of thumb
        if (bubbbox.GetBoxmax().y() > airbbox.GetBoxmax().y()) {
          // KILL THE BUBBLE!
          bubbleStats[b].isBubbleDead = true;
        }
      }
      
      
      if (bubbleStats[b].isBubbleBorn && !bubbleStats[b].isBubbleDead) {
        
        std::string zeropadBubbleNum = ZeroPadNumber(b, 6);
        bubbles[b]->getBubbleMesh()->write(outputDir + bubblePrefix + zeropadBubbleNum + "_" + zeropadFrameNum + ".obj", MFF_OBJ);
        bubbles[b]->timestep(dt);
      }
      
      
    }
    
    
    
  }
}
Esempio n. 7
0
PassRefPtr<Event> Event::cloneFor(HTMLIFrameElement*) const
{
    return Event::create(type(), bubbles(), cancelable());
}