コード例 #1
0
ファイル: llhudtext.cpp プロジェクト: wish-ds/firestorm-ds
void LLHUDText::renderAllHUD()
{
    LLGLState::checkStates();
    LLGLState::checkTextureChannels();
    LLGLState::checkClientArrays();

    {
        LLGLEnable color_mat(GL_COLOR_MATERIAL);
        LLGLDepthTest depth(GL_FALSE, GL_FALSE);

        VisibleTextObjectIterator text_it;

        for (text_it = sVisibleHUDTextObjects.begin(); text_it != sVisibleHUDTextObjects.end(); ++text_it)
        {
            (*text_it)->renderText();
        }
    }

    LLVertexBuffer::unbind();

    LLVertexBuffer::unbind();

    LLGLState::checkStates();
    LLGLState::checkTextureChannels();
    LLGLState::checkClientArrays();
}
コード例 #2
0
ファイル: Source.cpp プロジェクト: abardam/KinectDump
int main(int argc, char ** argv){

	std::string dir;
	if (argc >= 2){
		dir = std::string(argv[1]);
	}
	else{
		dir = "vid/";
	}
	int startframe = 0;
	if (argc >= 3){
		startframe = atoi(argv[2]);
	}
	else{
		startframe = 0;
	}
	

	CreateDirectory(dir.c_str(), NULL);

	Kinect2Manager kinect_manager;
	kinect_manager.InitializeDefaultSensorSeparateReaders();

	cv::FileStorage fs;
	std::stringstream filename_ss;
	int counter = 0;

	std::vector<KinectFrame> color_frames;
	std::vector<KinectFrame> depth_frames;
	int offset = 0;

	bool b_record = false;



	cv::namedWindow("img");

	cv::Mat depth_prev;

	while (true){

#ifdef DUMP_COLOR
		kinect_manager.Update(Update::Color);

		int color_width = kinect_manager.getColorWidth();
		int color_height = kinect_manager.getColorHeight();
		INT64 color_time = kinect_manager.GetColorTime();

		bool color_valid = color_height > 0 && color_width > 0;
#endif

#ifdef DUMP_DEPTH
		kinect_manager.Update(Update::Depth |Update::Body | Update::MapColorToDepth );

		int depth_width = kinect_manager.getDepthWidth();
		int depth_height = kinect_manager.getDepthHeight();
		INT64 depth_time = kinect_manager.GetDepthTime();

		bool depth_valid = depth_height > 0 && depth_width > 0;
#endif

#ifdef DUMP_COLOR
		if (color_valid){
			RGBQUAD * color_rgb = kinect_manager.GetColorRGBX();
			cv::Mat color_mat(color_height, color_width, CV_8UC4, color_rgb);

			if (b_record){
				if (color_frames.empty() || color_frames.back().time != color_time){
					color_frames.push_back(KinectFrame());
					color_frames.back().img_rgba = color_mat.clone();
					color_frames.back().time = color_time;
				}
			}
		}
#endif

#ifdef DUMP_DEPTH
		if (depth_valid){
			USHORT * depth = kinect_manager.GetDepth();
			cv::Mat depth_mat(depth_height, depth_width, cv::DataType<USHORT>::type, depth);

			if (b_record){
				if (depth_frames.empty() || depth_frames.back().time != depth_time){
					depth_frames.push_back(KinectFrame());

					depth_frames.back().img_depth = depth_mat.clone();

					//color map to depth

					int * depth_space_X = kinect_manager.GetColorXMappedToDepth();
					int * depth_space_Y = kinect_manager.GetColorYMappedToDepth();
					//depth-sized mat specifying which color coordinates
					cv::Mat depthspace_pts(depth_height, depth_width, cv::DataType<cv::Vec2s>::type, cv::Scalar(-1, -1));
					
					for (int y = 0; y < depth_height; ++y){
						for (int x = 0; x < depth_width; ++x){
							depthspace_pts.ptr<cv::Vec2s>(y)[x] = cv::Vec2s(*depth_space_X, *depth_space_Y);
							++depth_space_X;
							++depth_space_Y;
						}
					}
					
					depth_frames.back().map_color_to_depth = (depthspace_pts);


					//joints
					if (kinect_manager.getSkeletonIsGood()){
						int num_joints = JointType_Count;
						Joint* joints = kinect_manager.GetJoints();
						JointOrientation* joint_orientations = kinect_manager.GetJointOrientations();


						depth_frames.back().joints = (std::vector<Joint>(num_joints));
						depth_frames.back().joint_orientations = (std::vector<JointOrientation>(num_joints));

						for (int j = 0; j < JointType_Count; ++j){
							depth_frames.back().joints[j] = joints[j];
							depth_frames.back().joint_orientations[j] = joint_orientations[j];
						}

						depth_frames.back().lefthand_confidence = (kinect_manager.getHandLeftConfidence());
						depth_frames.back().righthand_confidence = (kinect_manager.getHandRightConfidence());
					}

					depth_frames.back().time = depth_time + startframe;
				}
			}
		}
#endif

		char q = cv::waitKey(15);
		if (q == 'r'){
			b_record = !b_record;
			if (b_record){
				std::cout << "start recording\n";
			}
			else{
				std::cout << "stop recording\n";
			}
		}
		else if (q == 'q' || q == 's'){
			save(dir, depth_frames);
			save(dir, color_frames);
			b_record = false;

			if (q == 'q')
				return 0;
		}
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// render()
//-----------------------------------------------------------------------------
void LLHUDEffectLookAt::render()
{
    if (gSavedSettings.getBOOL("EmeraldDontShowMyLookAt") &&
        (gAgent.getAvatarObject() == ((LLVOAvatar*)(LLViewerObject*)mSourceObject))) return;
	if (sDebugLookAt && mSourceObject.notNull())
	{
		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);

		LLVector3 target = mTargetPos + ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->mHeadp->getWorldPosition();
		glMatrixMode(GL_MODELVIEW);
		gGL.pushMatrix();
		gGL.translatef(target.mV[VX], target.mV[VY], target.mV[VZ]);
		glScalef(0.3f, 0.3f, 0.3f);
		gGL.begin(LLRender::LINES);
		{
			LLColor3 color = (*mAttentions)[mTargetType].mColor;
			gGL.color3f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]);
			gGL.vertex3f(-1.f, 0.f, 0.f);
			gGL.vertex3f(1.f, 0.f, 0.f);

			gGL.vertex3f(0.f, -1.f, 0.f);
			gGL.vertex3f(0.f, 1.f, 0.f);

			gGL.vertex3f(0.f, 0.f, -1.f);
			gGL.vertex3f(0.f, 0.f, 1.f);
		} gGL.end();
		gGL.popMatrix();
		if( gSavedSettings.getBOOL("EmeraldShowLookAtNames") )
		{
			//const LLFontGL* fontp = LLFontGL::sSansSerifSmall;
			const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
			LLGLEnable color_mat(GL_COLOR_MATERIAL);
			LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
			LLGLState gls_blend(GL_BLEND, TRUE);
			LLGLState gls_alpha(GL_ALPHA_TEST, TRUE);
			glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
			gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
			gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);

			// Well.. after that nasty complex try at somehow getting it to work initialising all sorts of stuff
			// It seems to work and fix the previous bug of merely displaying untextured cubes, 
			// probably due to the helpful getTexUnit->enable. - Nexii
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			LLVector3 render_pos = target + LLVector3( 0.f, 0.f, 0.25f );
			LLColor4 Color = LLColor4( (*mAttentions)[mTargetType].mColor, 1.0f ); 
			std::string text = ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->getFullname();
			
// [RLVa:KB] - Alternate: Emerald-370
			// Show anonyms in place of actual names when @shownames=n restricted
			if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
			{
				text = RlvStrings::getAnonym(text);
			}
// [/RLVa:KB]

			// render shadow first
//			gViewerWindow->setupViewport(1, -1);
//			hud_render_utf8text(text, render_pos, *fontp, LLFontGL::NORMAL, -0.5f * fontp->getWidthF32(text), 3.f, LLColor4( 0.f, 0.f, 0.f, 0.5f ), FALSE );
			gViewerWindow->setupViewport();
			hud_render_utf8text(text, render_pos, *fontp, LLFontGL::NORMAL, -0.5f * fontp->getWidthF32(text), 3.f, Color, FALSE );
			
			glPopMatrix();
		}
	}
}