Beispiel #1
0
void planet::draw(vector<vector<double> > positions) {
    // Hollow circle to represent planets
    ofNoFill();
    
    // Draw the tail
    drawTail(positions);
    
    // Draw the planet at this point in time
    ofEllipse(SCALE_FACTOR*position[0] + ofGetWindowWidth()/2.0, SCALE_FACTOR*position[1] + ofGetWindowHeight()/2.0, DIAMETER,DIAMETER);
}
Beispiel #2
0
/*	void drawHelicopter()
	This function holds all the creation of 
	the parts of the helicopter
*/
void Model::drawHelicopter() {
	glPushMatrix();
		setPosition();
			drawEngine();
			drawTailConnect();
			drawTail();
			drawBody();

		glPopMatrix();		// Last pop containing the helicopter
	glPopMatrix();
}
Beispiel #3
0
int main() {
	Surface* surface = new Surface(70, 60, ' ');

	drawBody(surface);
	drawCockpit(surface);

	drawWing(surface, true);
	drawWing(surface, false);

	drawSeats(surface);

	drawTail(surface);

	std::cout << surface->str() << std::endl;
}
Beispiel #4
0
void Trogdor::drawTrogdor()
{
	glPushMatrix();
		glTranslated(this->position.getX(), this->position.getY(), this->position.getZ());
		glScalef(8, 8, 8);
		glRotatef(facing, 0, 1, 0);
		glPushMatrix();
		drawBody();
		drawTail();
		drawNeckHead();
		drawLegs();
		drawWings();
		glPopMatrix();
	glPopMatrix();
}
void drawBee() {
    mvstack.push(model_view);
    //rotate bee
    model_view *= RotateY(-10*TIME);
    model_view *= Translate(0, 5, 0);
    model_view *= Translate(5, .5*sin(100+TIME), 0);
    model_view *= RotateY(90);

    //draw bee parts
    drawBody();    
    drawHead();
    drawTail();
    drawWings();
    drawLegz();

    model_view = mvstack.pop();
}
// Draw the Comet and all the related infos : name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended
void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont)
{
	if (hidden)
		return;
	if (getEnglishName() == core->getCurrentLocation().planetName)
	{ // GZ moved this up. Maybe even don't do that? E.g., draw tail while riding the comet? Decide later.
		return;
	}

	// The CometOrbit is in fact available in userDataPtr!
	CometOrbit* orbit=(CometOrbit*)userDataPtr;
	Q_ASSERT(orbit);
	if (!orbit->objectDateValid(core->getJDay())) return; // out of useful date range. This allows having hundreds of comet elements.

	if (orbit->getUpdateTails()){
		// Compute lengths and orientations from orbit object, but only if required.
		// TODO: This part should possibly be moved to another thread to keep draw() free from too much computation.

		Vec2f tailFactors=getComaDiameterAndTailLengthAU();
		float gasTailEndRadius=qMax(tailFactors[0], 0.025f*tailFactors[1]) ; // This avoids too slim gas tails for bright comets like Hale-Bopp.
		float gasparameter=gasTailEndRadius*gasTailEndRadius/(2.0f*tailFactors[1]); // parabola formula: z=r²/2p, so p=r²/2z
		// The dust tail is thicker and usually shorter. The factors can be configured in the elements.
		float dustparameter=gasTailEndRadius*gasTailEndRadius*dustTailWidthFactor*dustTailWidthFactor/(2.0f*dustTailLengthFactor*tailFactors[1]);

		// Find valid parameters to create paraboloid vertex arrays: dustTail, gasTail.
		computeParabola(gasparameter, gasTailEndRadius, -0.5f*gasparameter, gastailVertexArr,  gastailTexCoordArr, gastailIndices);
		// This was for a rotated straight parabola:
		//computeParabola(dustparameter, 2.0f*tailFactors[0], -0.5f*dustparameter, dusttailVertexArr, dusttailTexCoordArr, dusttailIndices);
		// Now we make a skewed parabola. Skew factor 15 (last arg) ad-hoc/empirical. TBD later: Find physically correct solution.
		computeParabola(dustparameter, dustTailWidthFactor*gasTailEndRadius, -0.5f*dustparameter, dusttailVertexArr, gastailTexCoordArr, gastailIndices, 25.0f*orbit->getVelocity().length());

		// Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may look better.
		computeComa(1.0f*tailFactors[0]);
		orbit->setUpdateTails(false); // don't update until position has been recalculated elsewhere
	}

	Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent;
/*  // We can remove that - a Comet has no parent except for the sun...
	PlanetP p = parent;
	while (p && p->parent)
	{
		mat = Mat4d::translation(p->eclipticPos) * mat * p->rotLocalToParent;
		p = p->parent;
	}
*/
	// This removed totally the Planet shaking bug!!!
	StelProjector::ModelViewTranformP transfo = core->getHeliocentricEclipticModelViewTransform();
	transfo->combine(mat);

	// Compute the 2D position and check if in the screen
	const StelProjectorP prj = core->getProjection(transfo);
	float screenSz = getAngularSize(core)*M_PI/180.*prj->getPixelPerRadAtCenter();
	float viewport_left = prj->getViewportPosX();
	float viewport_bottom = prj->getViewportPosY();
	if (prj->project(Vec3d(0), screenPos)
		&& screenPos[1]>viewport_bottom - screenSz && screenPos[1] < viewport_bottom + prj->getViewportHeight()+screenSz
		&& screenPos[0]>viewport_left - screenSz && screenPos[0] < viewport_left + prj->getViewportWidth() + screenSz)
	{
		// Draw the name, and the circle if it's not too close from the body it's turning around
		// this prevents name overlapping (ie for jupiter satellites)
		float ang_dist = 300.f*atan(getEclipticPos().length()/getEquinoxEquatorialPos(core).length())/core->getMovementMgr()->getCurrentFov();
		// if (ang_dist==0.f) ang_dist = 1.f; // if ang_dist == 0, the Planet is sun.. --> GZ: we can remove it.

		// by putting here, only draw orbit if Comet is visible for clarity
		drawOrbit(core);  // TODO - fade in here also...

		if (flagLabels && ang_dist>0.25 && maxMagLabels>getVMagnitude(core))
		{
			labelsFader=true;
		}
		else
		{
			labelsFader=false;
		}
		drawHints(core, planetNameFont);

		draw3dModel(core,transfo,screenSz);
	}
	// tails should also be drawn if core is off-screen...
	drawTail(core,transfo,true);  // gas tail
	drawTail(core,transfo,false); // dust tail

	//Coma: this is just a fan disk tilted towards the observer;-)
	drawComa(core, transfo);
	return;
}
Beispiel #7
0
// We are going to override (is that the right word?) the draw()
// method of ModelerView to draw out SampleModel
void SampleModel::draw()
{
	// This call takes care of a lot of the nasty projection 
	// matrix stuff.  Unless you want to fudge directly with the 
	// projection matrix, don't bother with this ...
	ModelerView::draw();

	/*************************************************
	**
	**	NOW SAVE THE CURRENT MODELVIEW MATRIX
	**
	**	At this point in execution, the MODELVIEW matrix contains
	**  ONLY the camera transformation.  We need to save this camera
	**  transformation so that we can use it later (for reasons
	**  explained below).
	**
	*****************************************************/
	cameraMatrix = getModelViewMatrix();

	// draw the sample model
	setAmbientColor(.1f, .1f, .1f);

	//glPushMatrix();

	//glPopMatrix();

	glPushMatrix(); // push identity
	glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); // values set by the sliders

	if (VAL(NINJATURTLE))
		setDiffuseColor(COLOR_GREEN);
	else
		setDiffuseColor(.940f, .816f, .811f);

	if (animate)
		glRotated(animHeadAngle, 0.0, 1.0, 0.0);
	if (VAL(EYEBANDANA))
		drawEyeBandana();

	if (!VAL(NINJATURTLE))
		setDiffuseColor(.940f, .816f, .811f);
	drawHead();
	
	if (!VAL(NINJATURTLE)) {
		setDiffuseColor(0, 0, 0);
		drawFace();
		setDiffuseColor(.940f, .816f, .811f);
		drawNeck();
	}

	drawUpperTorso();
	drawLowerTorso();

	if (!VAL(NINJATURTLE))
		setDiffuseColor(.940f, .816f, .811f);
	drawRightHandJoint();
	glPushMatrix();
	if (animate)
		glRotated(animUpperArmAngle, 1.0, 0, 0);
	drawUpperRightHand();
	drawLowerRightHand();
	drawRightHand();
	glPopMatrix();


	drawLeftHandJoint();
	glPushMatrix();
	if (animate)
		glRotated(-animUpperArmAngle, 1.0, 0, 0);
	drawUpperLeftHand();
	drawLowerLeftHand();
	drawLeftHand();
	glPopMatrix();

	drawRightLegJoint();
	drawLeftLegJoint();

	drawUpperRightLeg();
	drawLowerRightLeg();
	drawRightFoot();

	drawUpperLeftLeg();
	drawLowerLeftLeg();
	drawLeftFoot();

	if (VAL(NINJATURTLE))
		drawShell();
	else
		drawTail(); // handle the positioning and hierachical modeling of the tail

	if (VAL(METABALLSKIN)) {
		MetaBalls mb;
		mb.setUpGrid();
		mb.setUpMetaballs();
		mb.evalScalarField();
		mb.draw();
	}

	glPopMatrix();

	/***********************************************
	**
	**	NOW WE WILL ACTUALLY BEGIN DRAWING THE MODEL
	**
	**	Draw your model up to the node where you would like
	**	particles to spawn from.
	**
	**  FYI:  As you call glRotate, glScale, or glTranslate,
	**  OpenGL is multiplying new transformations into the
	**  MODELVIEW matrix.
	**
	********************************************/
	// If particle system exists, draw it
	ParticleSystem *ps = ModelerApplication::Instance()->GetParticleSystem();
	if (ps != NULL) {
		ps->computeForcesAndUpdateParticles(t);
		ps->drawParticles(t, m_camera);
	}
	
	/*************************************************
	**
	**	NOW DO ANY CLOSING CODE
	**
	**	Don't forget that animator requires you to call
	**  endDraw().
	**	
	**************************************************/
	endDraw();
}
void glutDisplay() {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  loadGlobalCoord();

  glShadeModel(GL_SMOOTH);
  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
                      
  glEnable(GL_LIGHT0);
  glLightfv(GL_LIGHT0, GL_AMBIENT, AMBIENT_LIGHT);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, DIFFUSE_LIGHT);
  glLightfv(GL_LIGHT0, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT0, GL_POSITION, LIGHT_POSITION);
                                    
  glEnable(GL_LIGHT1);
  glLightfv(GL_LIGHT1, GL_AMBIENT, AMBIENT_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, DIFFUSE_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT1, GL_POSITION, SUB_LIGHT_POSITION);

  glEnable(GL_COLOR_MATERIAL); 
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, MATERIAL_AMBIENT); 
  glMaterialfv(GL_FRONT, GL_SPECULAR, MATERIAL_SPECULAR);
  glMateriali(GL_FRONT, GL_SHININESS, 48);

  glTranslatef(0, 0, baseTrans);
  glRotatef(bodyRot, 0, 0, 1);
  glRotatef(90.0f, 1, 0, 0);
  glColor3f(1.0, 1.0, 0); // Yellow color
  
  GLUquadricObj* body = gluNewQuadric();
  gluCylinder(body, 5.5, 7.0, 17, 100, 10);
  gluDeleteQuadric(body);

  glPushMatrix();
    drawLeftArm();
  glPopMatrix();

  glPushMatrix();
    drawRightArm();
  glPopMatrix();

  glPushMatrix();
    drawLeftLeg();
  glPopMatrix();

  glPushMatrix();
    drawRightLeg();
  glPopMatrix();
  
  glPushMatrix();
    drawTail();      
    
    glPushMatrix();
      drawBall();
    glPopMatrix();
  glPopMatrix();

  glPushMatrix();
    drawHead();  
 
    glPushMatrix();
      drawLeftEye();
    glPopMatrix();

    glPushMatrix();
      drawRightEye();
    glPopMatrix();

    glPushMatrix();
      drawLeftCheek();
    glPopMatrix();

    glPushMatrix();
      drawRightCheek();
    glPopMatrix();

    glPushMatrix();
      drawMouse();  
    glPopMatrix();

    glPushMatrix();
      drawLeftEar();
    glPopMatrix();

    glPushMatrix();
      drawRightEar();
    glPopMatrix();
  glPopMatrix();
  
  glutSwapBuffers();
}