// As usual, the routine to display the current state of the system is // bracketed with a clearing of the window and a glFlush call. Immediately // within those calls the drawing code itself is bracketed by pushing and // popping the current transformation. And also as usual, we are assuming the // current matrix mode is GL_MODELVIEW. We finish with a SwapBuffers call // because we'll animate. void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glPushMatrix(); // Draw sun: a yellow sphere of radius 1 centered at the origin. glColor3f(1.0, 1.0, 0.0); myCube(2); //glColor3f(1,1,1); // glPushMatrix(); //glRotatef(-90.0, 1.0, 0.0, 0.0); // glutSolidCube(5); // glPopMatrix(); // glutSolidCube(5); // Draw planet: a blue sphere of radius 0.2, 2 units away from sun, with // a white "pole" for its axis. glRotatef((GLfloat)year, 0.0, 1.0, 0.0); glTranslatef (3.0, 0.0, 0.0); glRotatef((GLfloat)day, 0.0, 1.0, 0.0); glColor3f(0.0, 0.0, 1.0); //myWireSphere(0.2, 15, 15); myCube(1.0); glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex3f(0, -0.3, 0); glVertex3f(0, 0.3, 0); glEnd(); glPopMatrix(); glFlush(); glutSwapBuffers(); }
bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const { if (_billboardTexture) { float maxSize = glm::max(_fromImage.width(), _fromImage.height()); float x = _fromImage.width() / (2.0f * maxSize); float y = -_fromImage.height() / (2.0f * maxSize); float maxDimension = glm::max(x,y); float scaledDimension = maxDimension * _scale; glm::vec3 corner = getCenter() - glm::vec3(scaledDimension, scaledDimension, scaledDimension) ; AACube myCube(corner, scaledDimension * 2.0f); return myCube.findRayIntersection(origin, direction, distance, face); } return false; }
//This function is the display function that calls draw functions. void display() { glClearColor(1.0, 1.0, 1.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(0.0, 0.0, 0.0); //Draw cube away from origin initMat(curMatrix); myScale(20, 40, 20); myTranslate(50, -30, -40); myRotate(45, 0, 1, 0); myCube(); glFlush(); }
int main(int argc, char **argv) { QApplication application(argc,argv); DGtal::Viewer3D viewer; DGtal::Z3i::Point center(0,0,0); DGtal::ImplicitRoundedHyperCube<Z3i::Space> myCube( center, 20, 2.8); DGtal::Z3i::Domain domain(myCube.getLowerBound(), myCube.getUpperBound()); DGtal::Z3i::DigitalSet mySet(domain); DGtal::Shapes<DGtal::Z3i::Domain>::euclideanShaper( mySet, myCube); viewer.show(); // viewer << mySet << DGtal::Display3D::updateDisplay; //! [ImageSetDT-DT] typedef DGtal::SetPredicate<DGtal::Z3i::DigitalSet> Predicate; Predicate aPredicate(mySet); typedef DGtal::DistanceTransformation<Z3i::Space, Predicate, 2> DTL2; typedef DTL2::OutputImage OutputImage; DTL2 dt(domain,aPredicate); OutputImage result = dt.compute(); //! [ImageSetDT-DT] OutputImage::Value maxDT = (*std::max_element(result.begin(), result.end())); GradientColorMap<OutputImage::Value> gradient( 0, maxDT); gradient.addColor(DGtal::Color::Blue); gradient.addColor(DGtal::Color::Green); gradient.addColor(DGtal::Color::Yellow); gradient.addColor(DGtal::Color::Red); for(Z3i::Domain::ConstIterator it = domain.begin(), itend = domain.end(); it != itend; ++it) if (result(*it) != 0) { OutputImage::Value val= result( *it ); DGtal::Color c= gradient(val); viewer << DGtal::CustomColors3D(c,c) << *it ; } viewer << DGtal::ClippingPlane(1,0,0,0); //@todo updateDisplay is in Display3D or Viewer3D (cf doc)? viewer << DGtal::Display3D::updateDisplay; return application.exec(); }