Example #1
0
void LOTutorial::renderBackForSize(SunnyVector2D frameSize, SunnyVector2D center, float alpha, SunnyVector3D color)
{
    const float farDist = -20;
    
    if (isVAOSupported)
        glBindVertexArray(solidVAO);
    else
    {
        glBindBuffer(GL_ARRAY_BUFFER, solidVBO);
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
    }
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    SunnyMatrix m = getTranslateMatrix(SunnyVector3D(-0.5,0,0))* getScaleMatrix(SunnyVector3D(frameSize.x-backBorderSize*2/3,frameSize.y-backBorderSize*2/3,1)) * getTranslateMatrix(SunnyVector3D(center.x,center.y,farDist));
    sunnyUseShader(globalShaders[LOS_SolidObject]);
    glUniformMatrix4fv(globalModelview[LOS_SolidObject], 1, GL_FALSE, &(m.front.x));
    SunnyVector4D c = SunnyVector4D(color.x,color.y,color.z,alpha);
    glUniform4fv(uniformSO_Color,1, c);
    SunnyDrawArrays(0);
    
    m = getTranslateMatrix(SunnyVector3D(center.x,center.y,farDist));
    bindGameGlobal();
    sunnyUseShader(globalShaders[LOS_TexturedTSA]);
    glUniform1f(uniformTSA_A, alpha);
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    //left
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-frameSize.x/2, 0, 1,(frameSize.y-backCornerSize*2)/backSideSize));
    SunnyDrawArrays(LOMessageBorders_VAO+1);
    
    //right
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(frameSize.x/2,0, -1, (frameSize.y-backCornerSize*2)/backSideSize));
    SunnyDrawArrays(LOMessageBorders_VAO+1);
    
    //glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0, 0, 1, (frameSize.x-backCornerSize*2)/backSideSize));
    //top
    //m = getRotationZMatrix(-M_PI_2) * getTranslateMatrix(SunnyVector3D(center.x,center.y+frameSize.y/2,farDist));
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0,frameSize.y/2, (frameSize.x-backCornerSize*2)/backSideSize,1));
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    SunnyDrawArrays(LOMessageBorders_VAO+2);
    
    //bottom
//    m = getRotationZMatrix(M_PI_2) * getTranslateMatrix(SunnyVector3D(center.x,center.y-frameSize.y/2,farDist));
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0,-frameSize.y/2, (frameSize.x-backCornerSize*2)/backSideSize,-1));
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    SunnyDrawArrays(LOMessageBorders_VAO+2);
    
    //Corners
    m = getTranslateMatrix(SunnyVector3D(center.x,center.y,farDist));
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-frameSize.x/2, frameSize.y/2, 1,1));
    SunnyDrawArrays(LOMessageBorders_VAO);
    
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(frameSize.x/2, frameSize.y/2, -1,1));
    SunnyDrawArrays(LOMessageBorders_VAO);
    
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(frameSize.x/2, -frameSize.y/2, -1,-1));
    SunnyDrawArrays(LOMessageBorders_VAO);
    
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-frameSize.x/2, -frameSize.y/2, 1,-1));
    SunnyDrawArrays(LOMessageBorders_VAO);
}
Example #2
0
const glm::mat4 & Transform::getOrientationScaleMatrix(){
	if(osDirty){
		osMatrix = getOrientationMatrix() * getScaleMatrix();
		osDirty = false;
	}
	return osMatrix;
}
Example #3
0
void
CloudTransformTool::update (int x, int y, BitMask modifiers, BitMask buttons)
{
  if (!cloud_ptr_)
    return;
  if (!(buttons & LEFT))
    return;
    
  double transform[MATRIX_SIZE];
    
  int dx = (x - x_);
  int dy = (y - y_);
  if (dx == 0 && dy == 0)
    return;
  trackball_.update(x, y);
  if (modifiers & CTRL)
    getTranslateMatrix(dx, dy, transform);
  else if (modifiers & ALT)
    getZTranslateMatrix(dy, transform);
  else if (modifiers & SHFT)
    getScaleMatrix(dy, transform);
  else
    trackball_.getRotationMatrix(transform);

  cloud_ptr_ -> multMatrix(transform);

  x_ = x;
  y_ = y;
}
Example #4
0
glm::mat4 Transform::getModelMatrix(){
	if(mDirty){
		mMatrix = getTranslationMatrix() * getOrientationMatrix() * getScaleMatrix();
		mDirty = false;
	}
	return mMatrix;
}
Example #5
0
void Node::addScale(float x, float y, float z)
{
	glm::vec3 scale = glm::vec3(x, y, z);
	glm::mat4 newScaleMatrix = glm::scale(getScaleMatrix(), scale);
	m_scaleMatrix = newScaleMatrix;

	updateModelMatrix(m_scaleMatrix);
}
Example #6
0
const glm::mat4& CTransformer::getModelMatrix() const
{
	if (m_model.m_matrixDirty)
	{
		m_model.m_matrix = getTranslationMatrix() * getRotationMatrix() * getScaleMatrix();
		m_model.m_matrixDirty = false;
	}
	return m_model.m_matrix;
}
Example #7
0
void LOTutorial::render()
{
    //render back
    bindGameGlobal();
    SHTextureBase::bindTexture(menuTexture);
    
    glDisable(GL_DEPTH_TEST);
    const float farDist = -20;
    //fade
    sunnyUseShader(globalShaders[LOS_TexturedTSA]);
    SunnyMatrix m = getTranslateMatrix(SunnyVector3D(mapSize.x/2,mapSize.y/2,farDist));
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    glUniform1f(uniformTSA_A, 0.5*appearAlpha);
    glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0,0,1,1));
    SunnyDrawArrays(LODeath_VAO+1);
    
    //Back
    renderBackForSize(frameSize,windowCenter,appearAlpha);
    
    float scale;
    if (okButton)
    {
        scale = okButtonAlpha/1.5;
        if (okButton->active) scale*=0.85;
        m = getScaleMatrix(scale);
        m.pos = okButton->matrix.pos;
        glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
        
        glUniform1f(uniformTSA_A, appearAlpha*okButtonAlpha);
        glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0, 0, 1, 1));
        SunnyDrawArrays(LOOkButtonBack_VAO);
        LOFont::writeText(&m, LOTA_Center, true, loLabelOk, SunnyVector4D(250,251,253,255*appearAlpha*okButtonAlpha)/255,SunnyVector4D(161,174,188,255*appearAlpha*okButtonAlpha)/255);
    }
    if (nameString)
    {
        m = getScaleMatrix(nameScale) * getTranslateMatrix(SunnyVector3D(namePosition.x,namePosition.y,-1));
        LOFont::writeText(&m, LOTA_Center, true, nameString, yellowInnerColor(appearAlpha),yellowOuterColor(appearAlpha));
    }
}
bool LOMagicDropInfo::renderOverlay()
{
    //Spells
    float YY = mapSize.y/2-0.3;
    if (dropChances[DropType_Puzzle])
        YY += verticalDistance;
    SunnyMatrix m = getScaleMatrix(0.5) * getTranslateMatrix(SunnyVector3D(mapSize.x/2-leftDistance,YY,-2));
    const float spellDistances = 0.85;
    SunnyMatrix m1;
    bindGameGlobal();
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Teleport, &m1, appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D( spellDistances,spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Speed, &m1, appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,-spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Life, &m1, appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(spellDistances,-spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Shield, &m1, appearAlpha);
    
    //Ability
    bindGameGlobal();
    m = getScaleMatrix(0.5) * getTranslateMatrix(SunnyVector3D(mapSize.x/2+rightDistance,YY,-2));
    
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Magnet, &m1, appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D( spellDistances,spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Time, &m1, appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(0,-spellDistances,0));
    LOMenu::renderSpellOverlay(LA_Doubler, &m1, appearAlpha);
    return true;
}
Example #9
0
uint32_t rSimpleMesh::getMatrix( rMat4f **_mat, rObjectBase::MATRIX_TYPES _type ) {
   switch ( _type ) {
      case SCALE: *_mat                 = getScaleMatrix(); return 0;
      case ROTATION: *_mat              = getRotationMatrix(); return 0;
      case TRANSLATION: *_mat           = getTranslationMatrix(); return 0;
      case CAMERA_MATRIX: *_mat         = getViewProjectionMatrix(); return 0;
      case MODEL_MATRIX: *_mat          = getModelMatrix(); return 0;
      case VIEW_MATRIX: *_mat           = getViewMatrix(); return 0;
      case PROJECTION_MATRIX: *_mat     = getProjectionMatrix(); return 0;
      case MODEL_VIEW_MATRIX: *_mat     = getModelViewMatrix(); return 0;
      case MODEL_VIEW_PROJECTION: *_mat = getModelViewProjectionMatrix(); return 0;
      case NORMAL_MATRIX: break;
   }

   return INDEX_OUT_OF_RANGE;
}
Example #10
0
void LOMagicDropInfo::render()
{
    LOTutorial::render();

    //Spells
    float YY = mapSize.y/2-0.3;
    if (dropChances[DropType_Puzzle])
        YY += verticalDistance;
    SunnyMatrix m = getScaleMatrix(0.5) * getTranslateMatrix(SunnyVector3D(mapSize.x/2-leftDistance,YY,-2));
    const float spellDistances = 0.85;
    SunnyMatrix m1;
    bindGameGlobal();
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,spellDistances,0));
    LOMenu::renderSpellButton(LA_Teleport, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D( spellDistances,spellDistances,0));
    LOMenu::renderSpellButton(LA_Speed, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,-spellDistances,0));
    LOMenu::renderSpellButton(LA_Life, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(spellDistances,-spellDistances,0));
    LOMenu::renderSpellButton(LA_Shield, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = getScaleMatrix(0.7) * m * getTranslateMatrix(SunnyVector3D(spellDistances*2.5,0,0));
    LOFont::writeText(&m1, LOTA_LeftCenter, true, dropChances[DropType_Spell],whiteInnerColor(appearAlpha),whiteOuterColor(appearAlpha));
    
    
    //Ability
    bindGameGlobal();
    m = getScaleMatrix(0.5) * getTranslateMatrix(SunnyVector3D(mapSize.x/2+rightDistance,YY,-2));
    
    m1 = m * getTranslateMatrix(SunnyVector3D(-spellDistances,spellDistances,0));
    LOMenu::renderSpellButton(LA_Magnet, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D( spellDistances,spellDistances,0));
    LOMenu::renderSpellButton(LA_Time, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = m * getTranslateMatrix(SunnyVector3D(0,-spellDistances,0));
    LOMenu::renderSpellButton(LA_Doubler, &m1, 1, 1, 0,false,appearAlpha);
    
    m1 = getScaleMatrix(0.7) * m * getTranslateMatrix(SunnyVector3D(spellDistances*2.5,0,0));
    LOFont::writeText(&m1, LOTA_LeftCenter, true, dropChances[DropType_Buff],whiteInnerColor(appearAlpha),whiteOuterColor(appearAlpha));
    
    //Puzzle
    if (dropChances[DropType_Puzzle])
    {
        bindGameGlobal();
        YY -= 3*verticalDistance;
        m = getScaleMatrix(0.5) * getTranslateMatrix(SunnyVector3D(mapSize.x/2 -1,YY,-2));
        m1 = getScaleMatrix(2) * m * getTranslateMatrix(SunnyVector3D(-2,0,0));
        LOMenu::renderPuzzleImage(&m1, appearAlpha);
        LOFont::writeText(&m, LOTA_LeftCenter, true, dropChances[DropType_Puzzle],whiteInnerColor(appearAlpha),whiteOuterColor(appearAlpha));
    }
}
Example #11
0
void LOBonfire::renderAfterPlayer(SunnyMatrix *MV)
{
    SunnyMatrix m1 = getTranslateMatrix(SunnyVector3D(position.x, position.y, 0)) **MV;
    float scale;    
    SunnyMatrix m;
    for (short i = 0;i<smokesCount;i++)
    {
        scale = 3.0*(customBonfireSmokeLifeTime-smokes[i].lifeTime)/customBonfireSmokeLifeTime;
        if (scale>1.0) glUniform1f(uniformTSA_A, (3.0 - scale)/2.0);//glColor4f(1, 1, 1, (3.0 - scale)/2.0);
        else
            glUniform1f(uniformTSA_A, 1);//glColor4f(1, 1, 1, 1.0);
        
        m = getTranslateMatrix(SunnyVector3D(smokes[i].position.x, smokes[i].position.y,0)) *m1;
        m = getScaleMatrix(SunnyVector3D(scale, scale, 1))*m;
        glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
        glDrawArrays(GL_TRIANGLE_STRIP, (smokes[i].smokeNum+LOBonfire_VAO)*4, 4);
    }
}
Example #12
0
int main(){

	std::ofstream of;
	of.open("benchmark/score_out.txt");
	std::cerr.rdbuf(of.rdbuf());

	cv::Mat K2P = cv::Mat::eye(4,4,CV_32F);

#if PTAMM_STYLE == 1
	K2P = getScaleMatrix(-1,-1,1);
#endif

	initAndLoad(cv::Mat::eye(4,4,CV_32F),K2P,&vidRecord,&wcSkeletons,"map000000_whitesweater_edit/video/",false);

#if PTAMM_STYLE == 1
	LoadWorldCoordinateSkeletons(wcSkeletons, "map000000_whitesweater/GhostGame.xml");
#else
	zeroWorldCoordinateSkeletons(cv::Mat::eye(4,4,CV_32F),&vidRecord,&wcSkeletons);
#endif
	
	cv::Vec3f skeleCenter = calcSkeleCenter(wcSkeletons[0]);

	//cv::Mat shittyTransformMatrix = /*getTranslationMatrix(cv::Vec3f(0,0,1000)); */ getRotationMatrix4(cv::Vec3f(1,0,1), CV_PI);
	//cv::FileStorage fs("ptammat.yml", cv::FileStorage::READ);
	//fs["matCfW"] >> shittyTransformMatrix;
	//for(int i=0;i<wcSkeletons.size();++i){
	//	wcSkeletons[i].points = shittyTransformMatrix * wcSkeletons[i].points;
	//}

	cylinderBody.Load("map000000-custCB/");

#if PTAMM_STYLE == 1
	cylinderBody.radiusModifier = 0.658017;
#endif

	calculateSkeletonOffsetPoints(vidRecord,wcSkeletons,cylinderBody);
	//limbrary.Load("map000000_whitesweater-custCB-clust/");
	limbrary.Load("map000000_whitesweater_edit-custCB-clean-test/");

	//LoadStatusRecord("map000000_whitesweater/estim/", estimRecord);
	//std::vector<Skeleton> wcSkeletonsEstim = wcSkeletons;
	//interpolate(estimRecord, wcSkeletonsEstim);

	cv::Vec3f translation(0,0,0);
	cv::Vec3f rotation(0,CV_PI/2,0);


	cv::Mat im(480, 640, CV_8UC4, cv::Scalar(255,255,255,0));
	int frame = 100;
	int r = 8;
	int maxr = 16-4;
	rotation(1) = CV_PI/2 - r * (CV_PI/16);

	int p = 8;
	rotation(0) = CV_PI/2 - (CV_PI/16) * p;

	rotation(2) = 0;

	//smoothKinectPoints(wcSkeletons, 0.5);

	bool play = true;
	while(true){

		{

			unsigned char options = GD_DRAW ;// | GD_NOWEIGHT | GD_NOLIMBRARY;
			cv::Mat draw = im.clone();
			cv::Mat zBuf;

			cv::Mat transform = getTranslationMatrix(translation) * getTranslationMatrix(skeleCenter) *
				mat3_to_mat4(getRotationMatrix(cv::Vec3f(1,0,0),rotation(0)) * getRotationMatrix(cv::Vec3f(0,1,0),rotation(1)) * getRotationMatrix(cv::Vec3f(0,0,1),rotation(2)))
				* getTranslationMatrix(-skeleCenter);

#if PTAMM_STYLE == 1
			cv::FileStorage fs("ptammat.yml", cv::FileStorage::READ);
			fs["matCfW"] >> transform;
		
			transform = getTranslationMatrix(translation) * getTranslationMatrix(skeleCenter) *
				mat3_to_mat4(getRotationMatrix(cv::Vec3f(1,0,0),rotation(0)) * getRotationMatrix(cv::Vec3f(0,1,0),rotation(1)) * getRotationMatrix(cv::Vec3f(0,0,1),rotation(2)))
				* getTranslationMatrix(-skeleCenter) * transform;
#endif

			ScoreList scoreList[NUMLIMBS];


			ghostdraw_parallel(frame, K2P.inv() * transform /* shittyTransformMatrix.inv()*/, vidRecord, wcSkeletons, cylinderBody, limbrary, draw, zBuf, options, scoreList);

			/*
			//hybrid
			cv::Mat draw2 = im.clone();
			options = GD_CYL ;
		
			ghostdraw_parallel(frame, transform, vidRecord, wcSkeletons, cylinderBody, limbrary, draw2, options);

			cv::Mat candidate = vidRecord[scoreList[0].front().first].videoFrame.mat;

			cv::Mat cand_resize(HEIGHT, WIDTH, CV_8UC3, cv::Scalar(200,200,200));
			int gap_y = (HEIGHT-candidate.rows)/2;
			int gap_x = (HEIGHT-candidate.cols)/2;
			//candidate.copyTo(cand_resize(cv::Range(gap_y,gap_y + candidate.rows), cv::Range(gap_x,gap_x+candidate.cols)));
			candidate.copyTo(draw(cv::Range(0,candidate.rows), cv::Range(0,candidate.cols)));
			cv::rectangle(draw,cv::Rect(0,0,candidate.cols,candidate.rows),cv::Scalar(200,150,100));

			cv::Mat combine(HEIGHT*2,WIDTH,CV_8UC3);

			draw2.copyTo(combine(cv::Range(0,draw2.rows),cv::Range(0,draw2.cols)));
			draw.copyTo(combine(cv::Range(draw2.rows,draw.rows+draw2.rows),cv::Range(0,draw.cols)));
			//cand_resize.copyTo(combine(cv::Range(draw.rows+draw2.rows,draw.rows+draw2.rows+cand_resize.rows),cv::Range(0,cand_resize.cols)));*/

		
			//hybrid
			//cv::Mat draw2 = im.clone();
			//
			//ghostdraw_parallel(frame, transform, vidRecord, wcSkeletonsEstim, cylinderBody, limbrary, draw2, zBuf, options);
			//
			//cv::Mat combine(HEIGHT*2,WIDTH,CV_8UC4);
			//
			//draw2.copyTo(combine(cv::Range(0,draw2.rows),cv::Range(0,draw2.cols)));
			//draw.copyTo(combine(cv::Range(draw2.rows,draw.rows+draw2.rows),cv::Range(0,draw.cols)));


			cv::imshow("pic", draw);

			cv::Mat zBufNorm;
			cv::normalize(zBuf, zBufNorm, 0, 255, cv::NORM_MINMAX);

			cv::Mat zBuf8(zBuf.rows, zBuf.cols, CV_8U);
			for(int i=0;i<zBuf.rows*zBuf.cols;++i){
				zBuf8.ptr<unsigned char>()[i] = 255-zBufNorm.ptr<unsigned short>()[i];
			}

			cv::imshow("depth", zBuf8);

			std::string dir = "out_ws_interpcmp/";
			CreateDirectoryA(dir.c_str(), NULL);

			std::stringstream ss;
			ss << dir << 
				"frame" << std::setfill('0') << std::setw(3) << frame << 
				"r" << std::setw(2) << r <<
				"p" << p << ".png";

			//cv::imwrite(ss.str(), draw);

			if(play)
			{
				if(++frame >= vidRecord.size()){
					frame = 100;
					++r;
					rotation(1) = CV_PI/2 - r * (CV_PI/16);

					if(r > maxr)
					{
						return 0;
					}
				}
			}
		}

		char q = cv::waitKey(10);

		if(q=='q') return 0;
		else if(q=='w'){
			translation(2) -= 1;
		}else if(q=='s'){
			translation(2) += 1;
		}else if(q=='a'){
			rotation(1) += CV_PI/16;
		}else if(q=='d'){
			rotation(1) -= CV_PI/16;
		}else if(q=='z'){
			rotation (2) += CV_PI/64;
		}else if(q=='x'){
			rotation (2) -= CV_PI/64;
		}else if(q=='p'){
			play = !play;
		}

		
	}
}
Example #13
0
void LOPuzzle::render()
{
    if (!puzzleTextureID<0 || puzzleObject==0) return;
    
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_CULL_FACE);

    SHTextureBase::bindTexture(puzzleTextureID);
    SunnyMatrix m1 = getScaleMatrix(puzzlePartsScale) *  getRotationXMatrix(M_PI_2);
    SunnyMatrix m;
    puzzleObject->prepareForRender(isVAOSupported);
    
    sunnyUseShader(globalShaders[LOS_Textured3D]);
    glUniform4fv(uniform3D_C, 1, SunnyVector4D(1,1,1,1));

    float depth = 0;
    float shadowD = 0;
    for (short i = puzzleHorizontalSize*puzzleVerticalSize-1;i>=0;i--)
    if (puzzleParts[renderOrder[i]].active)
    {
        if (rotatingParts[renderOrder[i]].isRotating)
        {
            float angle = (- 1 + rotatingParts[renderOrder[i]].time/ppRotationTime)*M_PI_2;
            SunnyVector2D distance = puzzleParts[renderOrder[i]].position - rotatingParts[renderOrder[i]].origin;
            SunnyVector2D pos;
            pos.x = distance.x*cosf(angle) + distance.y*sinf(angle);
            pos.y =-distance.x*sinf(angle) + distance.y*cosf(angle);
            pos += rotatingParts[renderOrder[i]].origin;
            angle = (puzzleParts[renderOrder[i]].rotation - 1 + rotatingParts[renderOrder[i]].time/ppRotationTime)*M_PI_2;
            m = getRotationZMatrix(-angle) * getTranslateMatrix(SunnyVector3D(pos.x,pos.y,-5));
        } else
        {
            m = getRotationZMatrix(-puzzleParts[renderOrder[i]].rotation*M_PI_2) * getTranslateMatrix(SunnyVector3D(puzzleParts[renderOrder[i]].position.x,puzzleParts[renderOrder[i]].position.y,-200+depth));
        }
        if (puzzleHeight[renderOrder[i]]>1)
        {
            m =  getScaleMatrix(puzzleHeight[renderOrder[i]]) * getRotationXMatrix(-M_PI*4*(puzzleHeight[renderOrder[i]]-1))*  m;
            puzzleHeight[renderOrder[i]] -= deltaTime;
            if (puzzleHeight[renderOrder[i]]<1)
                puzzleHeight[renderOrder[i]] = 1;
        }
        m = getTranslateMatrix(partsTranslations[renderOrder[i]]) * m1*m;
        glUniformMatrix4fv(globalModelview[LOS_Textured3D], 1, GL_FALSE, &(m.front.x));
        puzzleObject->renderObject(objectsNumbers[renderOrder[i]]);
        
        if (i+1 == selectedPartsCount)
            shadowD = depth;

        depth += 5;
    }
    
    if (selectedParts)
    {
        glEnable(GL_BLEND);
        SunnyVector3D shadowSize(-0.15,-0.15,-1);
        sunnyUseShader(globalShaders[LOS_Textured3DA]);
        glUniform4fv(uniform3D_A, 1, SunnyVector4D(0,0,0,0.3));
        for (short i = 0;i<selectedPartsCount;i++)
        {
            if (rotatingParts[selectedParts[i]].isRotating)
            {
                float angle = (- 1 + rotatingParts[selectedParts[i]].time/ppRotationTime)*M_PI_2;
                SunnyVector2D distance = puzzleParts[selectedParts[i]].position - rotatingParts[selectedParts[i]].origin;
                SunnyVector2D pos;
                pos.x = distance.x*cosf(angle) + distance.y*sinf(angle);
                pos.y =-distance.x*sinf(angle) + distance.y*cosf(angle);
                pos += rotatingParts[selectedParts[i]].origin;
                angle = (puzzleParts[selectedParts[i]].rotation - 1 + rotatingParts[selectedParts[i]].time/ppRotationTime)*M_PI_2;
                m = getRotationZMatrix(-angle) * getTranslateMatrix(SunnyVector3D(pos.x,pos.y,-5));
            } else
                m = getRotationZMatrix(-puzzleParts[selectedParts[i]].rotation*M_PI_2) * getTranslateMatrix(SunnyVector3D(puzzleParts[selectedParts[i]].position.x+shadowSize.x,puzzleParts[selectedParts[i]].position.y+shadowSize.y,-200+shadowSize.z+shadowD));
            m = getTranslateMatrix(partsTranslations[renderOrder[i]]) * m1*m;
            glUniformMatrix4fv(globalModelview[LOS_Textured3DA], 1, GL_FALSE, &(m.front.x));
            puzzleObject->renderObject(objectsNumbers[selectedParts[i]]);
        }
    }
    glDisable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
    bindGameGlobal();
    SHTextureBase::bindTexture(menuTexture);
    
    const float mapKoef = mapSize.x/1920;
    const float farDist = -20;
    //fade
    sunnyUseShader(globalShaders[LOS_TexturedTSA]);
    m = sunnyIdentityMatrix;
    glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(m.front.x));
    glUniform1f(uniformTSA_A, 1);
    
    //Buttons
    {
        
        m = getTranslateMatrix(SunnyVector3D(0,0,farDist));
        glUniform1f(uniformTSA_A, 1);
        float btnScale;
        SunnyMatrix rot;
        rot = m;
        //Back
        rot.pos = puzzleButtons[PuzzleButton_Back]->matrix.pos;
        puzzleButtons[PuzzleButton_Back]->active?btnScale = defaultButtonScale:btnScale = 1;
        glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(rot.front.x));
        btnScale *= 0.82;
        glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0, 0, btnScale, btnScale));
        SunnyDrawArrays(LOLCButtonsVAO);
        glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-4*mapKoef, 6*mapKoef, btnScale, btnScale));
        SunnyDrawArrays(LOLCButtonsVAO+6);
        
//        //Store
//        rot.pos = puzzleButtons[PuzzleButton_Store]->matrix.pos;
//        puzzleButtons[PuzzleButton_Store]->active?btnScale = defaultButtonScale:btnScale = 1;
//        glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(rot.front.x));
//        glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0, 0, btnScale, btnScale));
//        SunnyDrawArrays(LOLCButtonsVAO);
//        glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-4*mapKoef, -2*mapKoef, btnScale, btnScale));
//        SunnyDrawArrays(LOLCButtonsVAO+2);
        
        //break
        if (!puzzleButtons[PuzzleButton_Break]->hidden)
        {
            rot.pos = puzzleButtons[PuzzleButton_Break]->matrix.pos;
            puzzleButtons[PuzzleButton_Break]->active?btnScale = defaultButtonScale:btnScale = 1;
            glUniformMatrix4fv(globalModelview[LOS_TexturedTSA], 1, GL_FALSE, &(rot.front.x));
            btnScale *= 0.82;
            glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(0, 0, btnScale, btnScale));
            SunnyDrawArrays(LOLCButtonsVAO);
            glUniform4fv(uniformTSA_TR, 1, SunnyVector4D(-2*mapKoef, 4*mapKoef, btnScale, btnScale));
            SunnyDrawArrays(LOLCButtonsVAO+3);
        }
    }
}