void PretzelColorPicker::draw() { gl::pushMatrices(); { gl::translate(mOffset + vec2(0,2)); // TOP ------------------------------------------------------------ gl::color(1,1,1,1); if( mArrowTex ){ gl::pushMatrices();{ gl::translate( vec2(14, 8) ); gl::rotate( toRadians( mArrowRotation ) ); gl::translate( floor(mArrowTex->getWidth() * -0.5), floor(mArrowTex->getHeight() * -0.5) ); gl::draw( mArrowTex ); }gl::popMatrices(); } // checkered bg gl::draw(mCheckerPat, mColorPickRect.getUpperLeft() ); // color if( bUseAlpha ){ gl::color( *mColorA ); } else { gl::color(*mColor); } pretzel()->drawSolidRect(mColorPickRect); // outline gl::color( mGlobal->P_OUTLINE_COLOR ); // pretzel()->drawStrokedRect(mColorPickRect); mGlobal->renderText(mLabel, vec2(25, 1)); // BOTTOM ------------------------------------------------------------ if(bExpanded){ gl::color( ColorA(1, 1, 1, 1 ) ); gl::draw( mHueStrip, mHueStripRect ); gl::drawLine( vec2(mHueStripRect.x1 - 3, mHueStripRect.y1 + mHueStripRect.getHeight() * mHueNorm), vec2(mHueStripRect.x2 + 3, mHueStripRect.y1 + mHueStripRect.getHeight() * mHueNorm) ); gl::draw(mBoxFbo->getColorTexture(), mColorSwatchRect); gl::draw(mCrosshairTex, mColorSwatchRect.getUpperLeft() + (mCrosshairPos * mColorSwatchRect.getSize()) - ( vec2(mCrosshairTex->getSize()) * 0.5f ) ); //* 0.5f } }gl::popMatrices(); }
void MapTile::init() { image = gl::Texture(loadImage(loadResource(MAP_IMG))); std::cout << "Image size " << image.getSize() << std::endl; maporigin.x = cinder::app::getWindowWidth()/2; maporigin.y = cinder::app::getWindowHeight()/2; //my vars track_mode = MODE_IDLE; currW = 0; zoom = 0.5; offset_zoom = 0.0; color = ColorA(0.2,0.3,0.4,0.7); int pad = getWindowWidth()/5; sliders.push_back( Slider( Vec2f(getWindowWidth()*0.1, getWindowHeight()/2) , Vec2f(30, 500), ColorA(0.9,0.4,0.5,0.5), GEST_EL, Slider::VERTICAL ) ); hide_all_sliders(); timer.start(); //init pointers ref_pos = cv::Point3f(-1,-1,-1); empty_hand = new gestoos::nui::Hand(); empty_hand2 = new gestoos::nui::Hand(); empty_hand->clear(); empty_hand2->clear(); hand_g = empty_hand; hand_slider = empty_hand2; //std::cout<<" hand_g present "<<hand_g->is_present()<<std::endl; }
void PretzelColorPicker::redrawBox() { { gl::ScopedGlslProg scS( mBoxShader ); gl::ScopedViewport scVp( mBoxFbo->getSize() ); gl::setMatricesWindow( mBoxFbo->getSize() ); gl::ScopedFramebuffer scF( mBoxFbo ); mBoxShader->uniform( "uPickedCol", mHueCol ); gl::clear( ColorA(1,1,1,0) ); gl::drawSolidRect( mBoxFbo->getBounds() ); } updateColor(); gl::setMatricesWindow( getWindowSize() ); }
void ArmViewport::draw() { viewArea.set(x,getWindowHeight()- y, x+w,getWindowHeight()-y-h); gl::setViewport(viewArea); // gl::clear( Color( 0.3, 0.0, 0.3 ) ); gl::setMatricesWindow(w, h); gl::pushMatrices(); gl::color(0.1, 0.1, 0.1); gl::drawSolidRect(Rectf( 0,0,w,h)); gl::color(0.1, 0.1, 0.1); gl::drawSolidRect(Rectf( 0,0,w,35)); gl::popMatrices(); gl::pushMatrices(); gl::setMatrices(camera ); gl::drawCoordinateFrame (300,0,0); gl::color(ColorA(1,1,1,0.5)); gl::drawLine(Vec3f(130,0,0), Vec3f(130,0,1500)); gl::drawLine(Vec3f(-130,0,0), Vec3f(-130,0,1500)); root->drawCurrent(); root->drawTarget(); position->drawTarget(); position->drawCurrent(); gl::popMatrices(); glViewport (0 , 0 , getWindowWidth(), getWindowHeight()); gl::setMatricesWindow(getWindowWidth(), getWindowHeight()); gui->draw(); }
luabind::object getGeometryColor( Geometry * pGeom ) { luabind::object colorTable = luabind::newtable( GLOBAL_LUA_STATE ); if ( pGeom->m_colorBuffer && pGeom->m_colorBuffer->size() ) { for( unsigned int colorIndex = 0, tableIndex = 1; colorIndex < pGeom->m_colorBuffer->size(); colorIndex += 2 ) { colorTable[tableIndex] = ColorA( pGeom->m_texture1Buffer->at(colorIndex+0), pGeom->m_texture1Buffer->at(colorIndex+1), pGeom->m_texture1Buffer->at(colorIndex+2), pGeom->m_texture1Buffer->at(colorIndex+3) ); tableIndex++; } } return colorTable; }
void LSystem::updateList() { mPerlin = Perlin( 8, Rand::randInt( 0, 100000 ) ); mSteps = mProduction.length(); if( mSteps > mProduction.length() ) { mSteps = mProduction.length(); } gl::pushModelView(); gl::translate( mLoc ); gl::pushModelView(); int countFood = 0; for( int i = 0; i < mSteps; i++ ) { char step = mProduction.at(i); if( step == 'F' || step == '|' ) { Vec2f current_loc = (gl::getModelView() * Vec4f( 0.0f, 0.0f, 0.0f, 1.0f )).xy(); current_loc -= mStartLength; current_loc += mLoc; boost::shared_ptr<Food> add_food( new Food( current_loc, ColorA( ColorA::black() ) ) ); mFood.push_back( add_food ); if( countFood > 0 ) { boost::weak_ptr<Food> weakFood(add_food); mFood[countFood-1]->setNext( weakFood ); } countFood++; gl::translate( 0, -mDrawLength + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*20000.0f ); } else if( step == '+' ) { gl::rotate( mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f)); } else if( step == '-' ) { gl::rotate( -1*(mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f))); } else if( step == '[' ) { gl::pushModelView(); } else if( step == ']' ) { gl::popModelView(); } } gl::popModelView(); gl::popModelView(); }
void StageRing::draw() { gl::pushModelView(); gl::enableDepthRead(); gl::color(ColorA(red, 0.5f, green, 0.5f)); gl::rotate(m_rotate); gl::scale(m_scale); for (int i = 0; i < Ring_Max; ++i) { gl::pushModelView(); { gl::translate(m_pos[i]); gl::drawTorus(10, 1, 12, 40); } gl::popModelView(); } gl::disableDepthRead(); gl::popModelView(); }
void Cinderactor::draw() const { // Loading message if( !init_ok ) { gl::color( ColorA( 0.0,0.0,0.0,0.5)); Rectf rect(0, 0, 300, 100); rect.offsetCenterTo(ci::app::getWindowCenter()); gl::drawSolidRoundedRect(rect, 10); gl::drawStringCentered( "Loading models... please wait...", ci::app::getWindowCenter() ); gl::color(1.0,1.0, 1.0, 1.0); return; } draw_hand_representation( get_hands().first, Vec2f(200, 70 ) ); draw_hand_representation( get_hands().second, Vec2f(70, 70 ) ); std::stringstream ss; ss<<"Static : "<<get_gesture().id <<std::endl; gl::drawStringCentered( ss.str(), Vec2f( 330, 30), Color(0.7, 0.8, 0.9) ); }
void PretzelToggle::draw() { gl::pushMatrices(); { gl::translate(mOffset + vec2(0,2)); // draw box RectT<float> tmpRect = mCheckBoxRect; gl::color(mGlobal->P_SLIDER_COLOR); pretzel()->drawSolidRect(tmpRect); tmpRect.inflate(vec2(-2, -2)); gl::color(mGlobal->P_BG_COLOR); pretzel()->drawSolidRect(tmpRect); // draw check if(*mValue){ gl::color(ColorA(1, 1, 1, 1)); gl::draw(mGlobal->mSkinTex, mSkinTexRect, mSkinDestRect); } mGlobal->renderText(mLabel, vec2(27, 1)); }gl::popMatrices(); }
// // Draw some Text void ofxConfigPicker::drawText(int x, int y, const char *text) { if (!cfg->shoudDrawText()) return; // Draw picker // 1st pass = shadow, 2nd pass = color for (int n = 0 ; n < 2 ; n++) { int off = ( n==0 ? 1 : 0); // Set color ofColor color = ( n==0 ? PICKER_SHADOWCOLOR : this->getCurrentColor() ); this->setColor(color); #ifdef CINDER y -= 4; // No shadow for Cinder (bad performance) if (n == 1) gl::drawString(text, Vec2f(x+off, y+off), ColorA( color.r/255.0f, color.g/255.0f, color.b/255.0f, mAlpha ), mFont ); #else ofDrawBitmapString(text, x+off, y+off); #endif } }
Surface renderString( const std::string &str, const Font &font, const ColorA &color, float *baselineOffset ) { Line line; line.addRun( Run( str, font, color ) ); line.mJustification = Line::LEFT; line.mLeadingOffset = 0; line.calcExtents(); float totalWidth = line.mWidth; float totalHeight = line.mHeight; int pixelWidth = (int)math<float>::ceil( totalWidth ); int pixelHeight = (int)math<float>::ceil( totalHeight ); // Odd failure - return a NULL Surface if( ( pixelWidth < 0 ) || ( pixelHeight < 0 ) ) return Surface(); #if defined( CINDER_MAC ) Surface result( pixelWidth, pixelHeight, true, SurfaceChannelOrder::RGBA ); CGContextRef cgContext = cocoa::createCgBitmapContext( result ); ip::fill( &result, ColorA( 0, 0, 0, 0 ) ); float currentY = totalHeight + 1.0f; currentY -= line.mAscent + line.mLeadingOffset; line.render( cgContext, currentY, (float)0, pixelWidth ); // force all the rendering to finish and release the context ::CGContextFlush( cgContext ); ::CGContextRelease( cgContext ); ip::unpremultiply( &result ); #elif defined( CINDER_MSW ) // I don't have a great explanation for this other than it seems to be necessary pixelHeight += 1; // prep our GDI and GDI+ resources ::HDC dc = TextManager::instance()->getDc(); Surface result( pixelWidth, pixelHeight, true, SurfaceConstraintsGdiPlus() ); Gdiplus::Bitmap *offscreenBitmap = msw::createGdiplusBitmap( result, false ); //Gdiplus::Bitmap *offscreenBitmap = new Gdiplus::Bitmap( pixelWidth, pixelHeight, (premultiplied) ? PixelFormat32bppPARGB : PixelFormat32bppARGB ); Gdiplus::Graphics *offscreenGraphics = Gdiplus::Graphics::FromImage( offscreenBitmap ); // high quality text rendering offscreenGraphics->SetTextRenderingHint( Gdiplus::TextRenderingHintAntiAlias ); // fill the surface with the background color offscreenGraphics->Clear( Gdiplus::Color( (BYTE)(0), (BYTE)(0), (BYTE)(0), (BYTE)(0) ) ); // walk the lines and render them, advancing our Y offset along the way float currentY = 0; currentY += line.mLeadingOffset + line.mLeading; line.render( offscreenGraphics, currentY, (float)0, (float)pixelWidth ); ::GdiFlush(); delete offscreenBitmap; delete offscreenGraphics; #elif defined( CINDER_LINUX ) Surface result( pixelWidth, pixelHeight, true, SurfaceChannelOrder::RGBA ); #endif if( baselineOffset ) *baselineOffset = line.mDescent; return result; }
void DebugDrawer::draw( const BlobTrackerRef &blobTracker, const Area &bounds, const Options &options ) { if ( options.mDebugMode == Options::DebugMode::NONE ) { return; } gl::TextureRef tex; switch ( options.mDrawMode ) { case Options::DrawMode::ORIGINAL: { cv::Mat img = blobTracker->getImageInput(); if ( img.data ) { tex = gl::Texture::create( fromOcv( img ) ); } break; } case Options::DrawMode::BLURRED: { cv::Mat img = blobTracker->getImageBlurred(); if ( img.data ) { tex = gl::Texture::create( fromOcv( img ) ); } break; } case Options::DrawMode::THRESHOLDED: { cv::Mat img = blobTracker->getImageThresholded(); if ( img.data ) { tex = gl::Texture::create( fromOcv( img ) ); } break; } default: break; } if ( ! tex ) { return; } ci::gl::disableDepthRead(); ci::gl::disableDepthWrite(); bool blendingEnabled = options.mDebugMode == Options::DebugMode::BLENDED; auto ctx = gl::context(); ctx->pushBoolState( GL_BLEND, blendingEnabled ); ctx->pushBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); gl::ScopedColor color( ColorA::gray( 1.0f, 0.5f ) ); Area outputArea = bounds; if ( options.mDrawProportionalFit ) { outputArea = Area::proportionalFit( tex->getBounds(), bounds, true, true ); } gl::draw( tex, outputArea ); { const auto &trackerOptions = blobTracker->getOptions(); float s = trackerOptions.mNormalizationScale; RectMapping blobMapping( Rectf( 0.0f, 0.0f, s, s ), Rectf( outputArea ) ); Rectf roi = trackerOptions.mNormalizedRegionOfInterest * s; gl::color( ColorA( 0.0f, 1.0f, 0.0f, 0.8f ) ); gl::drawStrokedRect( blobMapping.map( roi ) ); vec2 offset = outputArea.getUL(); vec2 scale = vec2( outputArea.getSize() ) / vec2( s, s ); for ( const auto &blob : blobTracker->getBlobs() ) { gl::pushModelView(); gl::translate( offset ); gl::scale( scale ); if ( trackerOptions.mBoundsEnabled ) { gl::color( ColorA( 1.0f, 1.0f, 0.0f, 0.5f ) ); gl::drawStrokedRect( blob->mBounds ); } if ( trackerOptions.mConvexHullEnabled && blob->mConvexHull ) { gl::color( ColorA( 1.0f, 0.0f, 1.0f, 0.5f ) ); gl::draw( *blob->mConvexHull.get() ); } gl::popModelView(); vec2 pos = blobMapping.map( blob->mPos ); gl::drawSolidCircle( pos, 2.0f ); gl::drawString( toString< int32_t >( blob->mId ), pos + vec2( 3.0f, -3.0f ), ColorA( 1.0f, 0.0f, 0.0f, 0.9f ) ); } } ctx->popBoolState( GL_BLEND ); ctx->popBlendFuncSeparate(); }
RecipeView::RecipeView(UserAreaModel _area, RecipeModel _recipe){ lastTouched = getElapsedSeconds(); recipeModel = _recipe; areaModel = _area; timeOut = areaModel.timeout; // menu_img.load(_model.getMenuImage()); debugState = 2; curStep = 0; stepState = 0; prevStepState = -1; prevStep = -1; pos = Vec2f(_area.x,_area.y); rotation = _area.r; align=TOP_LEFT; if(_area.name.compare("bottom-left")==0) align=BOTTOM_LEFT; if(_area.name.compare("bottom-right")==0) align=BOTTOM_RIGHT; if(_area.name.compare("top-left")==0){ align=BOTTOM_RIGHT; console() << "aligning top left"; } if(_area.name.compare("top-right")==0){ align=BOTTOM_LEFT; console() << "aligning top right"; } console() << "this recipemodel has this many steps: " << recipeModel.getNumSteps() << "." << endl; for(int i=0;i<recipeModel.getNumSteps();i++){ console() << "wtf: " << recipeModel.getCookStep(i).img.at(0) << endl; gallerytools::Image anImage; anImage.load(recipeModel.getCookStep(i).img.at(recipeModel.curLanguage)); anImage.hide(); images.push_back(anImage); gallerytools::Video aVideo; console() << "loading video::: " << aVideo.load(recipeModel.getCookStep(i).video.at(recipeModel.curLanguage)) << endl; aVideo.hide(); videos.push_back(aVideo); } back_btn.load(areaModel.back_btn.path); back_btn.moveTo(areaModel.back_btn.x,areaModel.back_btn.y,false); fwd_btn.load(areaModel.fwd_btn.path); fwd_btn.moveTo(areaModel.fwd_btn.x,areaModel.fwd_btn.y,false); select_btn.load(areaModel.select_btn.path); select_btn.moveTo(areaModel.select_btn.x,areaModel.select_btn.y,false); string normalFont( "Arial" ); TextLayout layout; layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) ); layout.setFont( Font( normalFont, 24 ) ); layout.setColor( Color( 1, 1, 1 ) ); layout.addLine( "testing here"); Surface8u rendered = layout.render( true, false ); text_texture = gl::Texture( rendered ); select_btn.setHalfHidden(); back_btn.setHalfHidden(); fwd_btn.setHalfHidden(); }
void RecipeView::update(){ //console() << ":::TIMED OUT:::" << endl; if((curStep==0 && stepState==0) || stepState==1){ // it's already at the start, or if it's on a video... delayTimeOut(); } else { double curTime = getElapsedSeconds(); if((curTime-lastTouched)>timeOut){ console() << "going to start: " << recipeModel.name << endl; goStart(); } } for(int i=0;i<videos.size();i++){ if(i!=curStep){ // videos.at(i).stop(); } } if(stepState==1){ if(videos.size()>curStep){ videos.at(curStep).update(); if(videos.at(curStep).isDone()) forwardRelease(); } } char buffer [40]; sprintf (buffer, "curStep: %i \n stepState: %i", curStep, stepState); TextLayout layout; layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) ); layout.setFont( Font( "Arial", 18 ) ); layout.setColor( Color( 1, 1, 1 ) ); layout.addLine(recipeModel.name.c_str()); layout.addLine( buffer); Surface8u rendered = layout.render( true, false ); text_texture = gl::Texture( rendered ); // this needs work here.... // this is specifically to handle a goStart() situation... if(prevStepState==0 && stepState == 0 && prevStep!=curStep){ console() << "THIS SHOULD BE FIRING on TIMEOUT >>> " << recipeModel.name << endl; if(images.size()>prevStep) images.at(prevStep).hide(); if(images.size()>curStep) images.at(curStep).show(); prevStep = curStep; } else { if(prevStep!=curStep){ // moved from video to new start image // load both the image and the video for the new step if(prevStep>-1) videos.at(prevStep).stop(); prevStep = curStep; } if(prevStepState!=stepState){ // moved from start image to video if(stepState==1){ if(videos.size()>curStep) videos.at(curStep).show(); if(images.size()>curStep) images.at(curStep).hide(); if(videos.size()>curStep) videos.at(curStep).play(); } else { if(images.size()>curStep) images.at(curStep).show(); if(videos.size()>curStep) videos.at(curStep).hide(); if(videos.size()>curStep) videos.at(curStep).stop(); } prevStepState = stepState; } } }
Material::Material() : mAmbient( ColorA( 1.0f, 0.5f, 0.25f, 1.0f ) ), mDiffuse( ColorA( 0, 0, 0, 1 ) ), mSpecular( ColorA( 0, 0, 0, 1 ) ), mShininess( 1.0f ), mEmission( ColorA( 0, 0, 0, 1 ) ), mFace( GL_FRONT ) { }
locationMarker::locationMarker(Entry e, int windowWidth, int windowHeight){ center_ = Vec2f(e.x*(windowWidth*1.065), windowHeight - e.y*(windowHeight*.96)); color_ = ColorA(rand() / (RAND_MAX-0.0), rand() / (RAND_MAX-0.0), rand() / (RAND_MAX-0.0), .51); radius_ = 4; }
void Sandbox::debugDraw( bool drawBodies, bool drawContacts, bool drawJoints ) { // should utilize an extension of b2DebugDraw (will soon) // if( drawBodies ) { //draw all bodies, contact points, etc gl::color( ColorA(1.0f, 0.0f, 0.1f, 0.5f) ); //draw bodies b2Body* bodies = mWorld->GetBodyList(); while( bodies != NULL ) { b2Vec2 pos = bodies->GetPosition(); float32 angle = bodies->GetAngle(); gl::pushMatrices(); gl::translate( Conversions::toScreen(pos) ); gl::rotate( Conversions::radiansToDegrees( angle ) ); //draw the fixtures for this body b2Fixture* fixtures = bodies->GetFixtureList(); while( fixtures != NULL ) { //not sure why the base b2Shape doesn't contain the vertex methods... switch (fixtures->GetType()) { case b2Shape::e_polygon: { b2PolygonShape* shape = (b2PolygonShape*)fixtures->GetShape(); glBegin(GL_POLYGON); for( int i=0; i != shape->GetVertexCount(); ++i ) { gl::vertex( Conversions::toScreen( shape->GetVertex(i) ) ); } glEnd(); } break; case b2Shape::e_circle: { b2CircleShape* shape = (b2CircleShape*)fixtures->GetShape(); gl::drawSolidCircle( Conversions::toScreen( shape->m_p ), Conversions::toScreen( shape->m_radius ) ); } break; default: break; } fixtures = fixtures->GetNext(); } gl::popMatrices(); bodies = bodies->GetNext(); } } if( drawContacts ) { //draw contacts b2Contact* contacts = mWorld->GetContactList(); gl::color( ColorA( 0.0f, 0.0f, 1.0f, 0.8f ) ); glPointSize(3.0f); glBegin(GL_POINTS); while( contacts != NULL ) { b2WorldManifold m; contacts->GetWorldManifold(&m); //grab the for( int i=0; i != b2_maxManifoldPoints; ++i ) { Vec2f p = Conversions::toScreen( m.points[i] ); gl::vertex( p ); } contacts = contacts->GetNext(); } glEnd(); } if( drawJoints ) { b2Joint* joints = mWorld->GetJointList(); gl::color( ColorA( 0.0f, 1.0f, 0.0f, 0.8f ) ); glPointSize(6.0f); glBegin(GL_POINTS); while( joints != NULL ) { Vec2f p1 = Conversions::toScreen( joints->GetAnchorA() ); Vec2f p2 = Conversions::toScreen( joints->GetAnchorB() ); gl::vertex( p1 ); gl::vertex( p2 ); joints = joints->GetNext(); } glEnd(); } }
void MainTaskHandler::draw(){ glViewport (0 , 0 , getWindowWidth(), getWindowHeight()); gl::setMatricesWindow(getWindowWidth(), getWindowHeight()); gl::color(1.f,1.f,1.f,1.f); // gui->draw(); if( cameraHandler->mTexture ) { glPushMatrix(); gl::draw( cameraHandler->mTexture ); glPopMatrix(); } gl::pushMatrices(); gl::setMatrices(camera ); gl::drawCoordinateFrame (300,0,0); gl::color(ColorA(1,1,1,0.5)); gl::drawLine(Vec3f(130,0,0), Vec3f(130,0,1500)); gl::drawLine(Vec3f(-130,0,0), Vec3f(-130,0,1500)); gl::color(ColorA(1,1,1,0.1)); for(int i=0;i<floorCaptures.size();i++) { floorCaptures[i]->draw(); } gl::color(ColorA(1,1,1,1)); GLfloat light_position[] = {1000,600 , 800,1 }; glLightfv( GL_LIGHT0, GL_POSITION, light_position ); glEnable( GL_LIGHT0 ); gl::pushMatrices(); glEnable( GL_LIGHT0 ); ColorA nodeColor =ColorA(1,0,0,1); ColorA ambientColor =ColorA(1,1,1,0.3); glEnable(GL_DEPTH_TEST); glEnable( GL_LIGHTING ); glMaterialfv( GL_FRONT, GL_DIFFUSE, nodeColor ); glMaterialfv( GL_FRONT, GL_AMBIENT, ambientColor ); for(int i=0;i<cubes.size();i++) { float size =cubes[i]->size; gl::pushMatrices(); gl::translate(cubes[i]->center); gl::rotate(Vec3f(0,cubes[i]->angle,0)); // cout << cubes[i]->angle<<endl ; gl::drawCube(Vec3f(0,0,0), Vec3f(size,size,size)); gl::popMatrices(); } glDisable( GL_LIGHTING ); glDisable( GL_LIGHT0 ); glDisable (GL_DEPTH_TEST); for(int i=0;i<cubes.size();i++) { gl::pushMatrices(); gl::translate(cubes[i]->center); gl::rotate(Vec3f(0,70,180)); gl::color(1.0f,1.0f,1.0f); font->drawString(toString(cubes[i]->center.x)+"-"+toString(cubes[i]->center.z),Vec2f(0,0)); gl::popMatrices(); } root->drawTarget(); root->drawCurrent(); position->drawTarget(); position->drawCurrent(); gl::popMatrices(); };
Model::Model(const std::string& path) { std::ostringstream json_path; json_path << "Model/" << path << ".json"; // Jsonからデータ取得 JsonTree data(loadAsset(json_path.str())); //------------------------------------------------------- // ワイヤーフレームの情報 // 頂点データの数を取得 int Vertex_Num = data["vertex_num"].getValue<int>(); // 頂点データの取得 std::vector<Vec3f> v; for (int i = 0; i < Vertex_Num; ++i) { std::ostringstream path; path << "v" << i; v.push_back({ Vec3f(data[path.str()]["x"].getValue<float>(), data[path.str()]["y"].getValue<float>(), data[path.str()]["z"].getValue<float>()) }); } // ワイヤーの色を取得 ColorA wire_color(data["wire_color"]["r"].getValue<float>(), data["wire_color"]["g"].getValue<float>(), data["wire_color"]["b"].getValue<float>(), data["wire_color"]["a"].getValue<float>()); // Face(ポリゴン)の数を取得 int Face_Num = data["face_num"].getValue<int>(); // Face(ポリゴン)の頂点座標を取得 for (int i = 0; i < Face_Num; ++i) { std::ostringstream path; path << "f" << i; faces.push_back({ { Vec3f(v[data[path.str()]["v1"].getValue<int>()]) }, { Vec3f(v[data[path.str()]["v2"].getValue<int>()]) }, { Vec3f(v[data[path.str()]["v3"].getValue<int>()]) }, { wire_color } }); } //------------------------------------------------------- // Meshの情報 // ポリゴンの頂点座標を取得 std::vector<Vec3f> vertices; for (int i = 0; i < Face_Num; ++i) { vertices.push_back({ Vec3f(faces[i].v1) }); vertices.push_back({ Vec3f(faces[i].v2) }); vertices.push_back({ Vec3f(faces[i].v3) }); } // 頂点座標の登録 m_mesh.appendVertices(&vertices[0], vertices.size()); // 頂点色を取得 std::vector<ColorA> color; for (int i = 0; i < Vertex_Num; ++i) { std::ostringstream path; path << "c" << i; color.push_back({ ColorA(data[path.str()]["r"].getValue<float>(), data[path.str()]["g"].getValue<float>(), data[path.str()]["b"].getValue<float>(), data[path.str()]["a"].getValue<float>()) }); } // ポリゴンの頂点色情報を取得 std::vector<ColorA> colors; for (int i = 0; i < Face_Num; ++i) { std::ostringstream path; path << "vc" << i; colors.push_back({ color[data[path.str()]["c1"].getValue<int>()] }); colors.push_back({ color[data[path.str()]["c2"].getValue<int>()] }); colors.push_back({ color[data[path.str()]["c3"].getValue<int>()] }); } // 頂点色を登録 m_mesh.appendColorsRgba(&colors[0], colors.size()); // ポリゴン結合番号情報 std::vector<uint32_t> indices; // Face_Num(ポリゴンの数) * 3 => ポリゴンそれぞれの頂点数を足したもの for (int i = 0; i < (Face_Num * 3); ++i) { indices.push_back(i); } // 結合番号を登録 m_mesh.appendIndices(&indices[0], indices.size()); }
void TextFragment::drawFragment(const vec2& baseline_location, float text_alpha) { vec2 location = baseline_location + vec2(0,g_skin.getFontBaslineOffset(m_font_type, m_small, m_bold, m_italic)); const gl::TextureFontRef& texture_font = getTextureFont(); if(m_is_spoiler) { float brighten_amount = (m_clicked ? 0.2f : 0.1f) * m_hover_percent; for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { ci::ColorA color(g_skin.getColor(Skin::SPOILER), text_alpha); if(m_hovered || m_clicked || m_hover_percent != 0.0f) { gl::color(ColorA(math<float>::min(1, color.r + brighten_amount), math<float>::min(1, color.g + brighten_amount), math<float>::min(1, color.b + brighten_amount), math<float>::min(1, color.a))); } else { gl::color(color); } Rectf rect = m_rect_array[i]; rect.offset(baseline_location); gl::drawSolidRect(rect); } } } if(!m_is_spoiler || !m_spoiled) { if((m_hovered || m_clicked || m_hover_percent != 0.0f) && m_spoiled) { for(int y = -2; y <= 2; y++) { for(int x = -2; x <= 2; x++) { gl::color(ColorA(m_color, (m_clicked ? 0.05f : 0.025f) * m_hover_percent * text_alpha)); texture_font->drawGlyphs(m_glyph_rendering_array, location + vec2(x, y)); if(m_underline) { gl::color(ColorA(m_underline_color, (m_clicked ? 0.05f : 0.025f) * m_hover_percent * text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getUnderlineOffset()); offset += vec2(x, y); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } if(m_strike) { gl::color(ColorA(m_strike_color, (m_clicked ? 0.05f : 0.025f) * m_hover_percent * text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getStrikeOffset(m_small)); offset += vec2(x, y); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } } } // brighten main color slightly float brighten_amount = (m_clicked ? 0.2f : 0.1f) * m_hover_percent; gl::color(ColorA(math<float>::min(1, m_color.r + brighten_amount), math<float>::min(1, m_color.g + brighten_amount), math<float>::min(1, m_color.b + brighten_amount), text_alpha)); texture_font->drawGlyphs(m_glyph_rendering_array, location); if(m_underline) { gl::color(ColorA(math<float>::min(1, m_underline_color.r + brighten_amount), math<float>::min(1, m_underline_color.g + brighten_amount), math<float>::min(1, m_underline_color.b + brighten_amount), text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getUnderlineOffset()); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } if(m_strike) { gl::color(ColorA(math<float>::min(1, m_strike_color.r + brighten_amount), math<float>::min(1, m_strike_color.g + brighten_amount), math<float>::min(1, m_strike_color.b + brighten_amount), text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getStrikeOffset(m_small)); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } } else { // this bit here is to show font rendering location. if(g_debug_text_rect_draw) { gl::ScopedLineWidth scopedLW(1); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::color(ci::ColorA(g_skin.getColor(Skin::LOL_WTF), text_alpha)); Rectf rect = m_rect_array[i]; rect.offset(baseline_location); gl::drawStrokedRect(rect); gl::color(ci::ColorA(g_skin.getColor(Skin::LOL_INF), text_alpha)); vec2 offset(0, g_skin.getBaselineDrop()); gl::drawLine(baseline_location + m_rect_array[i].getUpperLeft() + offset, baseline_location + m_rect_array[i].getUpperRight() + offset); } } } gl::color(ci::ColorA(m_color, text_alpha)); texture_font->drawGlyphs(m_glyph_rendering_array, location); if(m_underline) { gl::color(ci::ColorA(m_underline_color, text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getUnderlineOffset()); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } if(m_strike) { gl::color(ci::ColorA(m_strike_color, text_alpha)); gl::ScopedLineWidth scopedLW(g_skin.getLineThickness()); vec2 offset(0, -g_skin.getStrikeOffset(m_small)); for(size_t i = 0; i < m_rect_array.size(); i++) { if(m_rect_array[i].getWidth() > 0) { gl::drawLine(baseline_location + m_rect_array[i].getLowerLeft() + offset, baseline_location + m_rect_array[i].getLowerRight() + offset); } } } } } if(advanceHoverPercent()) { needsRedraw(); } }
ScopedColor::ScopedColor( float red, float green, float blue, float alpha ) : mCtx( gl::context() ) { mColor = mCtx->getCurrentColor(); mCtx->setCurrentColor( ColorA( red, green, blue, alpha ) ); }
#include "katana_base_includes.h" #include "light.h" // // RTTI Information // KIMPLEMENT_ROOT_RTTI( Light ); KIMPLEMENT_RTTI( AmbientLight, Light ); KIMPLEMENT_RTTI( DirectionLight, Light ); KIMPLEMENT_RTTI( PointLight, Light ); KIMPLEMENT_RTTI( SpotLight, PointLight ); // // Constants // const ColorA Light::DEFAULT_AMBIENT = ColorA( 1, 1, 1, 1 ); const ColorA Light::DEFAULT_DIFFUSE = ColorA( 1, 1, 1, 1 ); const ColorA Light::DEFAULT_SPECULAR = ColorA( 1, 1, 1, 1 ); const float Light::DEFAULT_RANGE = 30000; const Point3 DirectionLight::DEFAULT_DIRECTION = Point3( 0, 0, 1 ); const float PointLight::DEFAULT_CONSTANT_ATTENUATION = 1; const float PointLight::DEFAULT_LINEAR_ATTENUATION = 0; const float PointLight::DEFAULT_QUADRATIC_ATTENUATION = 0; const float SpotLight::DEFAULT_INNER_CONE_ANGLE = kmath::toRadians( 45 ); const float SpotLight::DEFAULT_OUTER_CONE_ANGLE = kmath::toRadians( 60 ); const float SpotLight::DEFAULT_FALLOFF = 1; // -------------------------------------------------------