void KisColorSelector::paintEvent(QPaintEvent* /*event*/) { // 0 red -> (1,0,0) // 1 yellow -> (1,1,0) // 2 green -> (0,1,0) // 3 cyan -> (0,1,1) // 4 blue -> (0,0,1) // 5 maenta -> (1,0,1) // 6 red -> (1,0,0) m_renderBuffer.fill(0); QPainter imgPainter(&m_renderBuffer); QPainter wdgPainter(this); QRect fgRect(0, 0 , QWidget::width(), QWidget::height()/2); QRect bgRect(0, QWidget::height()/2, QWidget::width(), QWidget::height()/2); wdgPainter.fillRect(fgRect, m_fgColor.getQColor()); wdgPainter.fillRect(bgRect, m_bgColor.getQColor()); for(int i=0; i<m_colorRings.size(); ++i) drawRing(imgPainter, m_colorRings[i], m_renderArea); wdgPainter.drawImage(m_renderArea, m_renderBuffer); drawOutline (wdgPainter, m_renderArea); drawLightStrip(wdgPainter, m_lightStripArea); }
/* * Draw the stool * Stool's base height is 0 (on the floor) * Dimensions: * Seat diameter: 11 3/4 " * Width: 14 5/8 " * Depth: 19 5/8 " * Min. seat height: 24 3/4 " * Max. seat height: 29 1/8 " */ void Stool::draw(MatrixStack &mViewStack) { mViewStack.push(); // position stool with feet on the floor mViewStack.active = glm::translate(mViewStack.active, glm::vec3(0.0f, STOOL_HEIGHT, 0.0f)); // seat and stem rendering mViewStack.push(); // used in height adjustment controls mViewStack.active = glm::translate(mViewStack.active, glm::vec3(0.0f, heightAdjust, 0.0f)); drawSeatAndStem(mViewStack); mViewStack.pop(); // leg rendering drawLeg(mViewStack, 0); drawLeg(mViewStack, 90); drawLeg(mViewStack, 180); drawLeg(mViewStack, 270); // draw lower ring drawRing(mViewStack); // draw upper disks drawDisk(mViewStack, TOP_DISK_RAD, 23.75f); drawDisk(mViewStack, BOT_DISK_RAD, 21.25f); mViewStack.pop(); }
/*Draw the rings and sun applying transformations.*/ void drawSceneWorld() { /*Draw the sun.*/ setSunMaterial(); drawSphereFilled(); /*Draw the rings.*/ glPushMatrix(); glRotatef(global.animateRing, 0.0, 0.0, 1.0); setRingWorldMaterial(); drawRing(RING_SIZE, blue); setOpenSailMaterial(); drawInnerRing(SAIL_SIZE, light_grey); glPopMatrix(); }
void mySemiSphere::draw(bool bothSides){ drawTop(); for (int i=0; i<stacks-1; i++) { drawRing(i); } if(bothSides){ drawTop_inverted(); for (int i=0; i<stacks-1; i++) { drawRing_inverted(i); } } }
void LLNetMap::draw() { // Ansariel: Synchronize netmap scale throughout instances if (mScale != sScale) { setScale(sScale); } static LLFrameTimer map_timer; static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white); static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white); static LLUIColor map_avatar_linden_color = LLUIColorTable::instance().getColor("MapAvatarLindenColor", LLColor4::blue); static LLUIColor map_avatar_muted_color = LLUIColorTable::instance().getColor("MapAvatarMutedColor", LLColor4::grey3); static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white); static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white); static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white); static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white); static LLUIColor map_chat_ring_color = LLUIColorTable::instance().getColor("MapChatRingColor", LLColor4::yellow); static LLUIColor map_shout_ring_color = LLUIColorTable::instance().getColor("MapShoutRingColor", LLColor4::red); if (mObjectImagep.isNull()) { createObjectImage(); } static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); if (auto_center) { mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f)); } // Prepare a scissor region F32 rotation = 0; gGL.pushMatrix(); gGL.pushUIMatrix(); LLVector3 offset = gGL.getUITranslation(); LLVector3 scale = gGL.getUIScale(); gGL.loadIdentity(); gGL.loadUIIdentity(); gGL.scalef(scale.mV[0], scale.mV[1], scale.mV[2]); gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); { LLLocalClipRect clip(getLocalRect()); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.matrixMode(LLRender::MM_MODELVIEW); // Draw background rectangle LLColor4 background_color = mBackgroundColor.get(); gGL.color4fv( background_color.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPan.mV[VX]); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPan.mV[VY]); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); gGL.rotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; if (regionp == gAgent.getRegion()) { gGL.color4f(1.f, 1.f, 1.f, 1.f); } else { gGL.color4f(0.8f, 0.8f, 0.8f, 1.f); } if (!regionp->isAlive()) { gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } // Redraw object layer periodically if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = false; // Locate the centre of the object layer, accounting for panning LLVector3 new_center = globalPosToView(gAgentCamera.getCameraPositionGlobal()); new_center.mV[VX] -= mCurPan.mV[VX]; new_center.mV[VY] -= mCurPan.mV[VY]; new_center.mV[VZ] = 0.f; mObjectImageCenterGlobal = viewPosToGlobal(llfloor(new_center.mV[VX]), llfloor(new_center.mV[VY])); // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw objects gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); LLVector3 camera_position = gAgentCamera.getCameraPositionAgent(); map_center_agent -= camera_position; map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; //localMouse(&local_mouse_x, &local_mouse_y); LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist_squared = F32_MAX; // value will be overridden in the loop F32 min_pick_dist_squared = (mDotRadius * MIN_PICK_SCALE) * (mDotRadius * MIN_PICK_SCALE); LLVector3 pos_map; uuid_vec_t avatar_ids; std::vector<LLVector3d> positions; bool unknown_relative_z; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgentCamera.getCameraPositionGlobal()); // Draw avatars for (U32 i = 0; i < avatar_ids.size(); i++) { pos_map = globalPosToView(positions[i]); LLUUID uuid = avatar_ids[i]; bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL); LLColor4 color = show_as_friend ? map_avatar_friend_color : map_avatar_color; // <FS:Ansariel> Check for unknown Z-offset => AVATAR_UNKNOWN_Z_OFFSET //unknown_relative_z = positions[i].mdV[VZ] == COARSEUPDATE_MAX_Z && // camera_position.mV[VZ] >= COARSEUPDATE_MAX_Z; unknown_relative_z = false; if (positions[i].mdV[VZ] == AVATAR_UNKNOWN_Z_OFFSET) { if (camera_position.mV[VZ] >= COARSEUPDATE_MAX_Z) { // No exact data and cam >=1020 => we don't know if // other avatar is above or below us => unknown unknown_relative_z = true; } else { // No exact data but cam is below 1020 => other avatar // is definitely above us => bump Z-offset to F32_MAX // so we get the up chevron pos_map.mV[VZ] = F32_MAX; } } // </FS:Ansariel> // Colorize muted avatars and Lindens std::string fullName; LLMuteList* muteListInstance = LLMuteList::getInstance(); if (muteListInstance->isMuted(uuid)) color = map_avatar_muted_color; else if (gCacheName->getFullName(uuid, fullName) && muteListInstance->isLinden(fullName)) color = map_avatar_linden_color; // Mark Avatars with special colors - Ansariel if (LLNetMap::sAvatarMarksMap.find(uuid) != LLNetMap::sAvatarMarksMap.end()) { color = LLNetMap::sAvatarMarksMap[uuid]; } //color based on contact sets prefs if(LGGContactSets::getInstance()->hasFriendColorThatShouldShow(uuid,FALSE,FALSE,FALSE,TRUE)) { color = LGGContactSets::getInstance()->getFriendColor(uuid); } // [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f | FS-Specific LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? color : map_avatar_color.get()), pos_map.mV[VZ], mDotRadius, unknown_relative_z); // [/RLVa:KB] // LLWorldMapView::drawAvatar( // pos_map.mV[VX], pos_map.mV[VY], // color, // pos_map.mV[VZ], mDotRadius, // unknown_relative_z); if(uuid.notNull()) { bool selected = false; uuid_vec_t::iterator sel_iter = gmSelected.begin(); for (; sel_iter != gmSelected.end(); sel_iter++) { if(*sel_iter == uuid) { selected = true; break; } } if(selected) { if( (pos_map.mV[VX] < 0) || (pos_map.mV[VY] < 0) || (pos_map.mV[VX] >= getRect().getWidth()) || (pos_map.mV[VY] >= getRect().getHeight()) ) { S32 x = llround( pos_map.mV[VX] ); S32 y = llround( pos_map.mV[VY] ); LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10); } else { LLWorldMapView::drawTrackingDot(pos_map.mV[VX],pos_map.mV[VY],color,0.f); } } } F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { closest_dist_squared = dist_to_cursor_squared; mClosestAgentToCursor = uuid; mClosestAgentPosition = positions[i]; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), map_track_color ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), map_track_color ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), map_track_color ); } } // Draw dot for self avatar position LLVector3d pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global); S32 dot_width = llround(mDotRadius * 2.f); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; if (you) { you->draw(llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { mClosestAgentToCursor = gAgent.getID(); mClosestAgentPosition = pos_global; } // Draw chat range ring(s) static LLUICachedControl<bool> chat_ring("MiniMapChatRing", true); if(chat_ring) { drawRing(LLWorld::getInstance()->getSayDistance(), pos_map, map_chat_ring_color); drawRing(LLWorld::getInstance()->getShoutDistance(), pos_map, map_shout_ring_color); } } // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv((map_frustum_color()).mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv((map_frustum_rotating_color()).mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); gGL.rotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } gGL.popMatrix(); gGL.popUIMatrix(); LLUICtrl::draw(); }
void RingChart::drawContent(QPainter &p) { int w = width() - m_margin*2; int h = height() - m_margin*2; int wh = qMin(w,h); int wh2 = wh / 2; int dx2 = (w - wh) / 2; int dy2 = (h - wh) / 2; QRect pieRect = QRect(dx2+m_margin, dy2+m_margin, wh, wh); //p.drawEllipse(pieRect); if (!m_model) return; int row_count = m_model->rowCount(); if (!row_count) return; int count = m_model->columnCount(); if (!count) return; // check if need to draw highlight bool checkHighlight = false; double mouseAngle = 0, mouseRadius = 0; // check if we're inside piechart at all if (!m_mousePos.isNull() && pieRect.contains(m_mousePos)) { // Determine the distance from the center point of the pie chart. double cx = m_mousePos.x() - dx2 - wh2; double cy = dy2 + wh2 - m_mousePos.y(); mouseRadius = pow(pow(cx, 2) + pow(cy, 2), 0.5); if (!(mouseRadius == 0 || mouseRadius > wh2)){ // Determine the angle of the point. mouseAngle = (180 / M_PI) * acos(cx / mouseRadius); if (cy < 0) mouseAngle = 360 - mouseAngle; checkHighlight = true; } } // TODO: ^^^ same as by Piechart - merge ^^^ // draw rings p.setFont(m_font); for (int ring = count-1; ring >= 0; ring--) { // inner radius of the ring int r1 = wh2 * ring / count; // outer radius of the ring int r2 = wh2 * (ring + 1) / count; // check if we are NOT between rings bool ringHighlight = checkHighlight; if (ringHighlight && (mouseRadius <= r1 || mouseRadius >= r2)) ringHighlight = false; drawRing(p, pieRect.center(), ring, r1, r2, ringHighlight, mouseAngle); } }
void GLExtras::drawRegion(const SkRegion& region, bool fill, bool drawBorder, const TransformationMatrix* drawMat, Color color) { if (region.isEmpty()) return; if (fill) { SkRegion::Iterator rgnIter(region); while (!rgnIter.done()) { const SkIRect& ir = rgnIter.rect(); SkRect r; r.set(ir.fLeft, ir.fTop, ir.fRight, ir.fBottom); drawRing(r, color, drawMat); rgnIter.next(); } } if (fill && !drawBorder) return; SkPath path; if (!region.getBoundaryPath(&path)) return; SkPath::Iter iter(path, true); SkPath::Verb verb; SkPoint pts[4]; SkRegion clip; SkIRect startRect; while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { if (verb == SkPath::kLine_Verb) { SkRect r; r.set(pts, 2); SkIRect line; int borderWidth = RING_BORDER_WIDTH; if (!fill) borderWidth *= 2; line.fLeft = r.fLeft - borderWidth; line.fRight = r.fRight + borderWidth; line.fTop = r.fTop - borderWidth; line.fBottom = r.fBottom + borderWidth; if (clip.intersects(line)) { clip.op(line, SkRegion::kReverseDifference_Op); if (clip.isEmpty()) continue; // Nothing to draw, continue line = clip.getBounds(); if (SkIRect::Intersects(startRect, line)) { clip.op(startRect, SkRegion::kDifference_Op); if (clip.isEmpty()) continue; // Nothing to draw, continue line = clip.getBounds(); } } else { clip.setRect(line); } r.set(line.fLeft, line.fTop, line.fRight, line.fBottom); drawRing(r, color, drawMat); if (startRect.isEmpty()) { startRect.set(line.fLeft, line.fTop, line.fRight, line.fBottom); } } if (verb == SkPath::kMove_Verb) { startRect.setEmpty(); } } }
void updateScene() { static bool changeColor = true; static double rotation1 = 0; static double rotation2 = 0; static double rotationSpeed = 30; // Grados por segundo static float rotS = 0; static float lastSecond = 0; // Esfera 1 rotation1 += timer.getDeltaTime() * rotationSpeed; rotation1 = std::fmod(rotation1, 360); if (fabs(rotation1 - 90) < 1e-1) { rotation1 += 180; } glPushMatrix(); { glRotated(rotation1, 0, 1, 0); glColor3f(0, fabs(sin(timer.getElapsedTime() / 10.0)), fabs(cos(timer.getElapsedTime() / 10.0))); drawRing(0.98, 0.97, 40); drawRing(0.73, 0.72, 40); if (changeColor) { glColor3f(0.5, 0.5, 0.5); } else { glColor3f(0, 0, 0); } glCallList(clockList); } glPopMatrix(); // Esfera 2 rotation2 += timer.getDeltaTime() * rotationSpeed; rotation2 = std::fmod(rotation2, 360); if (fabs(rotation2 - 180) < 1e-1) { rotation2 += 180; } glPushMatrix(); { glRotated(rotation2, 0, 1, 0); glRotatef(-90, 0, 1, 0); glColor3f(0, fabs(cos(timer.getElapsedTime() / 10.0)), fabs(sin(timer.getElapsedTime() / 10.0))); drawRing(0.98, 0.97, 40); drawRing(0.73, 0.72, 40); if (changeColor) { glColor3f(0.5, 0.5, 0.5); } else { glColor3f(0, 0, 0); } glCallList(clockList); } glPopMatrix(); // Leer hora actual std::time_t now = std::time(nullptr); struct tm t; time(&now); localtime_s(&t, &now); // Actualizar rotacion del segundero if (t.tm_sec == lastSecond) { rotS += 360 / 60 * timer.getDeltaTime(); } else { rotS = rotationSeconds(t); lastSecond = t.tm_sec; } // Dibujar segundero glPushMatrix(); glColor3f(1, 0, 0); glRotatef(rotS, 0, 0, -1); glTranslatef(0, 0.35, 0); glScalef(0.1, 0.7, 0); drawI(); glPopMatrix(); // Dibujar minutero glColor3f(0.0f, 0.0f, 0.0f); glPushMatrix(); glRotatef(rotationMinutes(t), 0, 0, -1); glTranslatef(0, 0.35, 0); glScalef(0.8, 0.7, 0); drawI(); glPopMatrix(); // Controlar cuando se cambia de hora para actualizar un objeto cada hora static int lastHour = 0; if (t.tm_hour != lastHour) { lastHour = t.tm_hour; changeColor = !changeColor; } // Dibujar saeta de las horas glPushMatrix(); glRotatef(rotationHours(t), 0, 0, -1); glTranslatef(0, 0.175, 0); glScalef(0.8, 0.35, 0); drawI(); glPopMatrix(); }
void initClockList() { int xiiList = glGenLists(1); glNewList(xiiList, GL_COMPILE); { drawXII(); } glEndList(); int iiiList = glGenLists(1); glNewList(iiiList, GL_COMPILE); { drawIII(); } glEndList(); int viList = glGenLists(1); glNewList(viList, GL_COMPILE); { drawVI(); } glEndList(); int ixList = glGenLists(1); glNewList(ixList, GL_COMPILE); { drawIX(); } glEndList(); clockList = glGenLists(1); glNewList(clockList, GL_COMPILE); { // Dibujar Anillo exterior drawRing(1, 0.98, 40); drawRing(0.97, 0.95, 40); // Dibujar Anillo interior drawRing(0.75, 0.73, 40); drawRing(0.72, 0.7, 40); // Dibujar Numeros (12, 3, 6, 9) glPushMatrix(); glTranslatef(0, 0.845, 0); glScalef(0.24, 0.24, 0); glCallList(xiiList); glPopMatrix(); glPushMatrix(); glTranslatef(0.845, 0, 0); glRotatef(90, 0, 0, 1); glScalef(0.24, 0.24, 0); glCallList(iiiList); glPopMatrix(); glPushMatrix(); glTranslatef(0, -0.845, 0); glRotatef(180, 0, 0, 1); glScalef(0.24, 0.24, 0); glCallList(viList); glPopMatrix(); glPushMatrix(); glTranslatef(-0.845, 0, 0); glRotatef(90, 0, 0, 1); glScalef(0.24, 0.24, 0); glCallList(ixList); glPopMatrix(); // Dibujar marcadores de horas adicionales glPushMatrix(); glRotatef(30, 0, 0, 1); glTranslatef(0, 0.845, 0); glScalef(0.24, 0.24, 0); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(60, 0, 0, 1); glTranslatef(0, 0.845, 0); glScalef(0.24, 0.24, 0); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(30, 0, 0, 1); glTranslatef(-0.845, 0, 0); glScalef(0.24, 0.24, 0); glRotatef(90, 0, 0, 1); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(60, 0, 0, 1); glTranslatef(-0.845, 0, 0); glScalef(0.24, 0.24, 0); glRotatef(90, 0, 0, 1); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(30, 0, 0, 1); glTranslatef(0, -0.845, 0); glScalef(0.24, 0.24, 0); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(60, 0, 0, 1); glTranslatef(0, -0.845, 0); glScalef(0.24, 0.24, 0); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(30, 0, 0, 1); glTranslatef(0.845, 0, 0); glScalef(0.24, 0.24, 0); glRotatef(90, 0, 0, 1); drawI(); glPopMatrix(); glPushMatrix(); glRotatef(60, 0, 0, 1); glTranslatef(0.845, 0, 0); glScalef(0.24, 0.24, 0); glRotatef(90, 0, 0, 1); drawI(); glPopMatrix(); } glEndList(); }
// RENDERING DEL SISTEMA SOLARE void solarScene(void){ // ogni volta che disegno incremento il numero dei frame g_frames++; // Do all your OpenGL rendering here // cancelliamo il buffer video e lo z buffer glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* ------------------------------------------------------------------------- */ // attiva il viewport principale glViewport( 0, 0, width, height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); g_camera.look(); // chiama la gluLookAt con i parametri opportuni // posizionando la luce dopo la telecamera la luce risulta fissa nel mondo glLightfv(GL_LIGHT0, GL_POSITION, g_light0_pos); glLightfv(GL_LIGHT1, GL_POSITION, g_light1_pos); glLightfv(GL_LIGHT2, GL_POSITION, g_light2_pos); glDisable(GL_CULL_FACE); // texture dello sfondo { GLUquadric* a = gluNewQuadric(); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_TEXTURE_2D); Point3 poscam = g_camera.getPos(); glPushMatrix(); glTranslatef(poscam.x, poscam.y, poscam.z); gluQuadricOrientation(a, GLU_INSIDE); glBindTexture(GL_TEXTURE_2D, g_textureSfondo[0]); gluQuadricTexture(a, GL_TRUE); gluSphere(a, 900, 24, 24); glPopMatrix(); glDisable(GL_TEXTURE_2D); glPopAttrib(); } glEnable(GL_CULL_FACE); /* PIANETI */ drawPlanet(posPlanet[0], radius[0], g_texturePlanet[0]); // mercury drawPlanet(posPlanet[1], radius[1], g_texturePlanet[1]); // venus drawPlanet(posPlanet[2], radius[2], g_texturePlanet[2]); // earth drawPlanet(posPlanet[3], radius[3], g_texturePlanet[3]); // mars drawPlanet(posPlanet[4], radius[4], g_texturePlanet[4]); // jupiter drawPlanet(posPlanet[5], radius[5], g_texturePlanet[5]); // saturn drawPlanet(posPlanet[6], radius[6], g_texturePlanet[6]); // uranus drawPlanet(posPlanet[7], radius[7], g_texturePlanet[7]); // neptune drawPlanet(posPlanet[8], radius[8], g_texturePlanet[8]); // pluto /* SATELLITI */ drawSatellite(&satellite[0], 'y', 0.00012, g_textureSatellite[0]); // moon //drawShield(satellite[0].pos, satellite[0].rad+1); drawSatellite(&satellite[1], 'z', 0.00024, g_textureSatellite[1]); // io drawSatellite(&satellite[2], 'y', 0.00012, g_textureSatellite[2]); // europa /* ANELLI DI SATURNO */ drawRing(posPlanet[5], 85, 120); // anello saturno // HENRY // gestione dei nemici: posizione, movimenti, inseguimenti // FILE: enemy_police.c insertEnemy(); insertPolice(); //ALBERTO // disegno di tutte le collisioni se attivate // FILE explosion.c insertExplosion(); //ALBERTO LASER // disegno di tutti i laser e controllo collisioni // FILE shooting.c hitEnemy=laserHitEnemy(); hitPolice=laserHitPolice(); insertRemoveLaser(); // se siamo stati colpiti dal laser nemico si decrementa la vita shooted(); // inseriamo il super-sparo insertSuperShoot(); glPopMatrix(); }