Пример #1
0
void Calibrate::tabletPressEvent(coTUIElement *tUIItem)
{
    if (tUIItem == StepX)
    {
        stepX();
    }
    else if (tUIItem == StepY)
    {
        stepY();
    }
    else if (tUIItem == StepZ)
    {
        stepZ();
    }
    else if (tUIItem == Next)
    {
        stepNext();
    }
    else if (tUIItem == Save)
    {
        save();
    }
    else if (tUIItem == Load)
    {
        readFile();
    }
    else if (tUIItem == Capture)
    {
        osg::Matrix m = cover->getViewerMat();
        osg::Vec3 pos;
        pos = m.getTrans();
        fprintf(stderr, "\a"); // beep
        int n = cI * ny * nz + cJ * nz + cK;
        if (position)
        {
            if (position[n].x != MyNAN)
                fprintf(stderr, "\a"); // beep
            position[n].x = pos[0];
            position[n].y = pos[1];
            position[n].z = pos[2];
        }
        if (orientation)
        {
            orientation[n].o[0] = m(0, 0);
            orientation[n].o[1] = m(0, 1);
            orientation[n].o[2] = m(0, 2);
            orientation[n].o[3] = m(1, 0);
            orientation[n].o[4] = m(1, 1);
            orientation[n].o[5] = m(1, 2);
            orientation[n].o[6] = m(2, 0);
            orientation[n].o[7] = m(2, 1);
            orientation[n].o[8] = m(2, 2);
        }
        stepDown();
    }
}
Пример #2
0
	void Sprite::collectModel(const cml::Matrix44& m, const std::vector<Vertex>& vertexVec, const lw::Color& color, GLuint glId, bool hasAlpha){
		ImageStaticData& d = g_imageStaticData;
		hasAlpha = hasAlpha || color.a < 255;

		std::vector<Vertex>& v = d.vertexVec;

		if ( d.currVertexOffset == -2 ){
			BatchInfo& batchInfo = d.batchInfoVec.back();
			d.currTextureId = glId;
			d.currColor = color;
			d.currVertexOffset = (int)v.size();
			batchInfo.vertexOffset = d.currVertexOffset;
			batchInfo.textureId = d.currTextureId;
			batchInfo.hasAlpha = hasAlpha;
			batchInfo.color = color;
		}
		else if ( glId != d.currTextureId 
			|| color != d.currColor 
			|| d.currVertexOffset == -1) {
				d.currTextureId = glId;
				d.currColor = color;
				d.currVertexOffset = (int)v.size();
				BatchInfo batchInfo;
				batchInfo.vertexOffset = d.currVertexOffset;
				batchInfo.textureId = d.currTextureId;
				batchInfo.hasAlpha = hasAlpha;
				batchInfo.color = color; 
				d.batchInfoVec.push_back(batchInfo);
		}

		std::vector<Vertex>::const_iterator it = vertexVec.begin();
		std::vector<Vertex>::const_iterator itEnd = vertexVec.end();
		for ( ; it != itEnd; ++it ){
			cml::Vector3 p1;
			p1[0] = it->x; p1[1] = it->y; p1[2] = 0;
			p1 = cml::transform_point(m, p1);
			Vertex vtx;
			vtx = *it;
			vtx.x = p1[0]; vtx.y = p1[1];
			v.push_back(vtx);
		}
		stepZ();
	}
Пример #3
0
	void Sprite::collectModel(PODModel* pModel, int nodeIndex, lw::Color color){
		lwassert(pModel);
		stepZ();
		ImageStaticData& d = g_imageStaticData;

		if ( d.currVertexOffset == -2 ){
			BatchInfo& batchInfo = d.batchInfoVec.back();
			batchInfo.vertexOffset = -1;
			batchInfo.pModle = pModel;
			batchInfo.nodeIndex = (char)nodeIndex;
			batchInfo.color = color;
			d.currVertexOffset = -1;
		}else{
			BatchInfo batchInfo;
			batchInfo.vertexOffset = -1;
			batchInfo.pModle = pModel;
			batchInfo.nodeIndex = (char)nodeIndex;
			batchInfo.color = color;
			d.currVertexOffset = -1;
			d.batchInfoVec.push_back(batchInfo);
		}
	}
Пример #4
0
	void Sprite::collect(float x, float y, float w, float h, float rotate, bool flipH, bool flipV, lw::Color color){
		ImageStaticData& d = g_imageStaticData;

		stepZ();

		float posX1 = -_ancX;
		float posY1 = -_ancY;
		float posX2 = 0;
		float posY2 = 0;
		if ( w <= 0 ){
			posX2 = posX1 + (float)_width;
		}else{
			posX2 = posX1 + w;
		}
		if ( h <= 0 ){
			posY2 = posY1 + (float)_height;
		}else{
			posY2 = posY1 + h;
		}

		cml::Vector3 p1;
		p1[0] = posX1; p1[1] = posY1; p1[2] = 0;
		cml::Vector3 p2;
		p2[0] = posX1; p2[1] = posY2; p2[2] = 0;
		cml::Vector3 p3;
		p3[0] = posX2; p3[1] = posY1; p3[2] = 0;
		cml::Vector3 p4;
		p4[0] = posX2; p4[1] = posY2; p4[2] = 0;

		if ( rotate != 0.f ){
			cml::Matrix44 m;
			cml::matrix_rotation_world_z(m, rotate);
			p1 = cml::transform_point(m, p1);
			p2 = cml::transform_point(m, p2);
			p3 = cml::transform_point(m, p3);
			p4 = cml::transform_point(m, p4);
		}
		p1[0]+=x; p1[1]+=y;
		p2[0]+=x; p2[1]+=y;
		p3[0]+=x; p3[1]+=y;
		p4[0]+=x; p4[1]+=y;

		float minx = min(p1[0], p2[0]);
		minx = min(minx, p3[0]);
		minx = min(minx, p4[0]);
		float miny = min(p1[1], p2[1]);
		miny = min(miny, p3[1]);
		miny = min(miny, p4[1]);
		float maxx = max(p1[0], p2[0]);
		maxx = max(maxx, p3[0]);
		maxx = max(maxx, p4[0]);
		float maxy = max(p1[1], p2[1]);
		maxy = max(maxy, p3[1]);
		maxy = max(maxy, p4[1]);

		const App::Config conf = App::getConfig();
		int clientW = conf.width;
		int clientH = conf.height;
		if ( minx >= clientW || maxx <= 0 
			|| miny >= clientH || maxy <= 0 ){
				return;
		}
		std::vector<Vertex>& vertexVec = d.vertexVec;

		if ( d.currVertexOffset == -2 ){
			BatchInfo& batchInfo = d.batchInfoVec.back();
			d.currTextureId = _glId;
			d.currColor = color;
			d.currVertexOffset = (int)vertexVec.size();
			batchInfo.vertexOffset = d.currVertexOffset;
			batchInfo.textureId = d.currTextureId;
			batchInfo.hasAlpha = _hasAlpha;
			batchInfo.color = color;
		}
		else if ( _glId != d.currTextureId 
			|| color != d.currColor 
			|| d.currVertexOffset == -1) {
				d.currTextureId = _glId;
				d.currColor = color;
				d.currVertexOffset = (int)vertexVec.size();
				BatchInfo batchInfo;
				batchInfo.vertexOffset = d.currVertexOffset;
				batchInfo.textureId = d.currTextureId;
				batchInfo.hasAlpha = _hasAlpha;
				batchInfo.color = color; 
				d.batchInfoVec.push_back(batchInfo);
		}
		

		//1
		Vertex v;
		v.x = p1[0];
		v.y = -p1[1];
		v.z = g_currZ;
		if ( flipH ){
			v.u = _u2;
		}else{
			v.u = _u1;
		}
		if ( flipV ){
			v.v = 1.f - _v2;
		}else{
			v.v = 1.f - _v1;
		}
		vertexVec.push_back(v);

		//2
		v.x = p2[0];
		v.y = -p2[1];
		v.z = g_currZ;
		if ( flipH ){
			v.u = _u2;
		}else{
			v.u = _u1;
		}
		if ( flipV ){
			v.v = 1.f - _v1;
		}else{
			v.v = 1.f - _v2;
		}
		vertexVec.push_back(v);

		//3
		v.x = p3[0];
		v.y = -p3[1];
		v.z = g_currZ;
		if ( flipH ){
			v.u = _u1;
		}else{
			v.u = _u2;
		}
		if ( flipV ){
			v.v = 1.f - _v2;
		}else{
			v.v = 1.f - _v1;
		}
		vertexVec.push_back(v);

		//3
		v.x = p3[0];
		v.y = -p3[1];
		v.z = g_currZ;
		if ( flipH ){
			v.u = _u1;
		}else{
			v.u = _u2;
		}
		if ( flipV ){
			v.v = 1.f - _v2;
		}else{
			v.v = 1.f - _v1;
		}
		vertexVec.push_back(v);

		//2
		v.x = p2[0];
		v.y = -p2[1];
		v.z = g_currZ;

		if ( flipH ){
			v.u = _u2;
		}else{
			v.u = _u1;
		}
		if ( flipV ){
			v.v = 1.f - _v1;
		}else{
			v.v = 1.f - _v2;
		}
		vertexVec.push_back(v);

		//4
		v.x = p4[0];
		v.y = -p4[1];
		v.z = g_currZ;
		if ( flipH ){
			v.u = _u1;
		}else{
			v.u = _u2;
		}
		if ( flipV ){
			v.v = 1.f - _v1;
		}else{
			v.v = 1.f - _v2;
		}

		vertexVec.push_back(v);
	}
Пример #5
0
	void Sprite::collect(const cml::Matrix33& m, lw::Color color){
		ImageStaticData& d = g_imageStaticData;

		stepZ();

		float posX1 = -_ancX;
		float posY1 = -_ancY;
		float posX2 = posX1 + (float)_width;
		float posY2 = posY1 + (float)_height;

		std::vector<Vertex>& vertexVec = d.vertexVec;

		if ( d.currVertexOffset == -2 ){
			BatchInfo& batchInfo = d.batchInfoVec.back();
			d.currTextureId = _glId;
			d.currColor = color;
			d.currVertexOffset = (int)vertexVec.size();
			batchInfo.vertexOffset = d.currVertexOffset;
			batchInfo.textureId = d.currTextureId;
			batchInfo.hasAlpha = _hasAlpha;
			batchInfo.color = color;
		}else if ( _glId != d.currTextureId 
			|| color != d.currColor 
			|| d.currVertexOffset == -1 ) {
				d.currTextureId = _glId;
				d.currColor = color;
				d.currVertexOffset = (int)vertexVec.size();
				BatchInfo batchInfo;
				batchInfo.vertexOffset = d.currVertexOffset;
				batchInfo.textureId = d.currTextureId;
				batchInfo.hasAlpha = _hasAlpha;
				batchInfo.color = color; 
				d.batchInfoVec.push_back(batchInfo);
		}

		//
		cml::Vector2 p1;
		p1[0] = posX1; p1[1] = posY1;
		p1 = cml::transform_point_2D(m, p1);
		cml::Vector2 p2;
		p2[0] = posX1; p2[1] = posY2;
		p2 = cml::transform_point_2D(m, p2);
		cml::Vector2 p3;
		p3[0] = posX2; p3[1] = posY1;
		p3 = cml::transform_point_2D(m, p3);
		cml::Vector2 p4;
		p4[0] = posX2; p4[1] = posY2;
		p4 = cml::transform_point_2D(m, p4);

		//
		float minx = min(p1[0], p2[0]);
		minx = min(minx, p3[0]);
		minx = min(minx, p4[0]);
		float miny = min(p1[1], p2[1]);
		miny = min(miny, p3[1]);
		miny = min(miny, p4[1]);
		float maxx = max(p1[0], p2[0]);
		maxx = max(maxx, p3[0]);
		maxx = max(maxx, p4[0]);
		float maxy = max(p1[1], p2[1]);
		maxy = max(maxy, p3[1]);
		maxy = max(maxy, p4[1]);

		const App::Config conf = App::getConfig();
		int clientW = conf.width;
		int clientH = conf.height;
		if ( minx >= clientW || maxx <= 0 
			|| miny >= clientH || maxy <= 0 ){
				return;
		}

		//1
		Vertex v;
		v.x = p1[0];
		v.y = -p1[1];
		v.z = g_currZ;
		v.u = _u1;
		v.v = 1.f -_v1;
		vertexVec.push_back(v);

		//2
		v.x = p2[0];
		v.y = -p2[1];
		v.z = g_currZ;
		v.u = _u1;
		v.v = 1.f -_v2;
		vertexVec.push_back(v);

		//3
		v.x = p3[0];
		v.y = -p3[1];
		v.z = g_currZ;
		v.u = _u2;
		v.v = 1.f -_v1;
		vertexVec.push_back(v);

		//3
		v.x = p3[0];
		v.y = -p3[1];
		v.z = g_currZ;
		v.u = _u2;
		v.v = 1.f -_v1;
		vertexVec.push_back(v);

		//2
		v.x = p2[0];
		v.y = -p2[1];
		v.z = g_currZ;
		v.u = _u1;
		v.v = 1.f -_v2;
		vertexVec.push_back(v);

		//4
		v.x = p4[0];
		v.y = -p4[1];
		v.z = g_currZ;
		v.u = _u2;
		v.v = 1.f -_v2;
		vertexVec.push_back(v);
	}