コード例 #1
0
void ScrollBar::handleScrollTouch(ds::ui::Sprite* bs, const ds::ui::TouchInfo& ti){
	if(ti.mFingerIndex == 0){
		ci::Vec3f localPos = globalToLocal(ti.mCurrentGlobalPoint);
		
		float destPercent;
		if(mVertical){

			// This may not be right. Feel free to fix, but be sure you get it right and check multiple instances
			if(getPerspective()){
				localPos.y -= getHeight()/2.0f;
			}

			destPercent = localPos.y / getHeight();
		} else {
			destPercent = localPos.x / getWidth();
		}

		if(destPercent < 0.0f) destPercent = 0.0f;
		if(destPercent > 1.0f) destPercent = 1.0f;

		if(mScrollMoveCallback){
			mScrollMoveCallback(destPercent);
		}
	}
}
コード例 #2
0
ファイル: scroll_list.cpp プロジェクト: s133p/ds_cinder
void ScrollList::pushItemsTop(){
	if (mVerticalScrolling){
		float scrollHeight = mScrollableHolder->getHeight();
		if(getPerspective()){
			if(!mItemPlaceHolders.empty() &&
			   mItemPlaceHolders[0].mY < scrollHeight - mStartPositionY - mIncrementAmount
			   ){
				float delta = scrollHeight - mItemPlaceHolders[0].mY - mStartPositionY - mIncrementAmount;
				for(auto it = mItemPlaceHolders.begin(); it < mItemPlaceHolders.end(); ++it){
					(*it).mY += delta;
				}
			}
		} else {
			if(!mItemPlaceHolders.empty() &&
			   mItemPlaceHolders.back().mY < scrollHeight - mIncrementAmount
			   ){
				float delta = scrollHeight - mItemPlaceHolders.back().mY - mIncrementAmount;
				for(auto it = mItemPlaceHolders.begin(); it < mItemPlaceHolders.end(); ++it){
					(*it).mY += delta;
				}
			}
		}

	}

}
コード例 #3
0
ファイル: view.cpp プロジェクト: pwag42/moba_source
void View::updateCamera()
{
	getPerspective();

	gluLookAt(eye.x,eye.y,eye.z,
		at.x,at.y,at.z,
		up.dx,up.dy,up.dz);
}
コード例 #4
0
void PanoramicVideo::drawLocalClient(){

	if(mVideoSprite){

		ci::gl::TextureRef videoTexture = mVideoSprite->getFinalOutTexture();
		if(!videoTexture) return;
		
		ci::Area newViewportBounds;

		DS_REPORT_GL_ERRORS();

		if(!getPerspective()){
			ci::Rectf bb = getBoundingBox();
			ci::vec3 ul = getParent()->localToGlobal(ci::vec3(bb.getUpperLeft(), 0.0f));
			ci::vec3 br = getParent()->localToGlobal(ci::vec3(bb.getLowerRight(), 0.0f));

			float yScale = mEngine.getSrcRect().getHeight() / mEngine.getDstRect().getHeight();
			float xScale = mEngine.getSrcRect().getWidth() / mEngine.getDstRect().getWidth();

			// even though we're not in perspective, the cinder perspective camera starts from the bottom of the window
			// and counts upwards for y. So reverse that to draw where we expect
			ul = ul - ci::vec3(mEngine.getSrcRect().getUpperLeft(), 0.0f);
			ul.y /= yScale;
			ul.x /= xScale;
			ul.y = ci::app::getWindowBounds().getHeight() - ul.y;

			br = br - ci::vec3(mEngine.getSrcRect().getUpperLeft(), 0.0f);
			br.y /= yScale;
			br.x /= xScale;
			br.y = ci::app::getWindowBounds().getHeight() - br.y;

			newViewportBounds = ci::Area(ci::vec2(ul), ci::vec2(br));
		} else {
			ci::vec3 ul = getParent()->localToGlobal(getPosition() - getCenter()*getSize());
			ul = ul - ci::vec3(mEngine.getSrcRect().getUpperLeft(), 0.0f);
			ci::vec3 br = ul + ci::vec3(getWidth(), getHeight(), 0.0f);
			newViewportBounds = ci::Area(ci::vec2(ul.x, br.y), ci::vec2(br.x, ul.y));
		}

		// might have to figure this out for client/server
		//ci::gl::ScopedViewport newViewport(newViewportBounds);

		videoTexture->bind();

		ci::gl::ScopedMatrices matricies;
		ci::gl::setMatrices(mCamera);
		
		ci::gl::rotate(ci::toRadians(mXRot), 0.0f, 0.0f, 1.0f);
		ci::gl::rotate(ci::toRadians(mYRot), 0.0f, 1.0f, 0.0);
		ci::gl::draw(mSphereVbo);

		videoTexture->unbind();
		
	}
}
コード例 #5
0
Ray CameraComponent::getRayFromMouse(glm::vec2 mp)
{
	glm::vec2 mousePos = mp - dims.StartPixel();
	float x = (2.0f*mousePos.x)/dims.WidthPixel() - 1.0f;
	float y = 1.0f - (2.0f* mousePos.y)/dims.HeightPixel();
	float z = -1.0f;
	
	glm::mat4x4 undoCam = glm::inverse(getWorld2View());
	glm::vec4 temp = glm::inverse(getPerspective() * undoCam) * glm::vec4(x,y,z,0.0);

	Ray ret;

	ret.direction = glm::normalize(glm::vec3(undoCam * glm::vec4(temp.x,temp.y,z,0.0)));
	ret.origin = Parent()->getTrans()->pos;
	return ret;
}
コード例 #6
0
ファイル: gl_code.cpp プロジェクト: demuyan/NDKBook_2nd
// フレーム前初期化
void prepareFrame(struct engine* engine) {

  // ViewPortを指定
  glViewport(0, 0, engine->width, engine->height);
  // 塗りつぶし色設定
  glClearColor(.7f, .7f, .9f, 1.f);
  // カラーバッファ、デプスバッファをクリアー
  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

  // 背面は表示しない
  glCullFace(GL_BACK);

  // 透視変換行列の設定
  GLint projectionUniform = glGetUniformLocation(gProgram, "Projection");                          /////----- (1) ここから
  mat4 projectionMatrix = getPerspective(45, (float) engine->width / engine->height, 0.5f, 500);
  glUniformMatrix4fv(projectionUniform, 1, 0, projectionMatrix.Pointer());                         /////----- (1) ここまで
}
コード例 #7
0
void ScrollList::layout(){

	layoutItems();


	if(mVerticalScrolling){
		float scrollyHeight = mScrollableHolder->getHeight();

		if(scrollyHeight < getHeight()){
			scrollyHeight = getHeight();
		}

		if(mScrollableHolder){
			mScrollableHolder->setSize(getWidth(), scrollyHeight);
		}
		if (getPerspective()){
			if(mFillFromTop){
				pushItemsTop();
			}
		} else if(!mFillFromTop){
			pushItemsTop();
		}

	} else {
		float scrollyWidth = mScrollableHolder->getWidth();

		if(scrollyWidth < getWidth()){
			scrollyWidth = getWidth();
		}

		if(mScrollableHolder){
			mScrollableHolder->setSize(scrollyWidth, getHeight());
		}
	}

	if(mScrollArea){
		mScrollArea->setScrollSize(getWidth(), getHeight());
	}


	assignItems();
}