示例#1
0
const YsMatrix4x4 &YsViewPoint::GetViewMatrix(void) const
{
	if(YSTRUE!=matrixCached)
	{
		matrix.LoadIdentity();
		switch(YsCoordSysModel)
		{
		case YSRIGHT_ZMINUS_YPLUS:
			matrix.Translate(YsVec3(0.0,0.0,-GetViewDistance()));
			matrix.RotateXY(-GetViewAttitude().b());
			matrix.RotateZY(-GetViewAttitude().p());
			matrix.RotateXZ(-GetViewAttitude().h());
			break;
		case YSLEFT_ZPLUS_YPLUS:
			matrix.Scale(1.0,1.0,-1.0);
			matrix.Translate(YsVec3(0.0,0.0,GetViewDistance()));
			matrix.RotateXY(-GetViewAttitude().b());
			matrix.RotateZY(-GetViewAttitude().p());
			matrix.RotateXZ(-GetViewAttitude().h());
			break;
		}
		matrix.Translate(-GetViewTarget());
		matrixCached=YSTRUE;

		// Memo: Equivalent OpenGL transformation.
		// glTranslated(0.0,0.0,-GetViewDistance());
		// glRotated(-YsRadToDeg(GetViewAttitude().b()),0.0,0.0,1.0);
		// glRotated(-YsRadToDeg(GetViewAttitude().p()),1.0,0.0,0.0);
		// glRotated(-YsRadToDeg(GetViewAttitude().h()),0.0,1.0,0.0);
		// glTranslated(-GetViewTarget().x(),-GetViewTarget().y(),-GetViewTarget().z());
	}
	return matrix;
}
示例#2
0
void CreateUniformInitialParticleLocation(std::vector <YsVec3> &iniPos,int nx,int ny,int nz,const YsVec3 center,const double interval)
{
    const double sqrt3=1.7320508;
    const double sin72=0.9510565;

    const double stepx=interval;
    const double stepy=interval*sin72*sqrt3/2.0;
    const double stepz=interval*sqrt3/2.0;

    const double dx=stepx*(double)(nx-1);
    const double dy=stepy*(double)(ny-1);
    const double dz=stepz*(double)(nz-1);

    const YsVec3 o(-dx/2.0,-dy/2.0,-dz/2.0);

    for(int yy=0; yy<ny; ++yy)
    {
        const double xShift=(double)(yy%2)*interval/2.0;
        const double zShift=(double)(yy%2)*interval/3.0;

        for(int zz=0; zz<nz; ++zz)
        {
            for(int xx=0; xx<nx; ++xx)
            {
                const double xOffset=stepx*(double)xx+xShift;
                const double yOffset=stepy*(double)yy;
                const double zOffset=stepz*(double)zz+zShift;

                iniPos.push_back(center+o+YsVec3(xOffset,yOffset,zOffset));
            }
        }
    }
}
示例#3
0
Cylinder::Cylinder()
{
    radius=20.0;
    top=10.0;
    bottom=0.0;
    origin=YsVec3(0.0, 0.0, 0.0);
}
示例#4
0
文件: main.cpp 项目: HLH15/24783
void FsLazyWindowApplication::VtxNomToYsShell(YsShellExt &shl,const std::vector <float> &vtx,const std::vector <float> &nom)
{
	PrepareLatticeForConnection(ltc,vtx);

	shl.CleanUp();
	for(int i=0; i<vtx.size()/9; ++i)
	{
		const YsVec3 plNom(nom[i*9],nom[i*9+1],nom[i*9+2]);
		const YsVec3 vtPos[3]=
		{
			YsVec3(vtx[i*9  ],vtx[i*9+1],vtx[i*9+2]),
			YsVec3(vtx[i*9+3],vtx[i*9+4],vtx[i*9+5]),
			YsVec3(vtx[i*9+6],vtx[i*9+7],vtx[i*9+8]),
		};
		YsShell::VertexHandle vtHd[3];
		for(int i=0; i<3; ++i)
		{
			vtHd[i]=nullptr;
			auto idx=ltc.GetBlockIndex(vtPos[i]);
			if(true==ltc.IsInRange(idx))
			{
				for(auto tstVtHd : ltc.Elem(idx.x(),idx.y(),idx.z()))
				{
					if(shl.GetVertexPosition(tstVtHd)==vtPos[i])
					{
						vtHd[i]=tstVtHd;
						break;
					}
				}
			}
			if(nullptr==vtHd[i])
			{
				vtHd[i]=shl.AddVertex(vtPos[i]);
				if(true==ltc.IsInRange(idx))
				{
					ltc.Elem(idx.x(),idx.y(),idx.z()).push_back(vtHd[i]);
				}
			}
		}
		YsShell::PolygonHandle plHd;
		plHd=shl.AddPolygon(3,vtHd);
		shl.SetPolygonNormal(plHd,plNom);
	}
}
示例#5
0
void PrepareShell(YsShell &shl)
{
	int idx[8];
	idx[0]=shl.AddVertex(YsVec3(-2.5, 1.0, 1.0));
	idx[1]=shl.AddVertex(YsVec3( 2.5, 1.0, 1.0));
	idx[2]=shl.AddVertex(YsVec3(-2.5, 1.0,-1.0));
	idx[3]=shl.AddVertex(YsVec3( 2.5, 1.0,-1.0));
	idx[4]=shl.AddVertex(YsVec3(-2.5,-1.0,-1.0));
	idx[5]=shl.AddVertex(YsVec3( 2.5,-1.0,-1.0));
	idx[6]=shl.AddVertex(YsVec3(-2.5,-1.0, 1.0));
	idx[7]=shl.AddVertex(YsVec3( 2.5,-1.0, 1.0));

	int plg[4];
	plg[0]=idx[0];
	plg[1]=idx[1];
	plg[2]=idx[3];
	plg[3]=idx[2];
	shl.AddPolygon(4,plg);

	plg[0]=idx[2];
	plg[1]=idx[3];
	plg[2]=idx[5];
	plg[3]=idx[4];
	shl.AddPolygon(4,plg);

	plg[0]=idx[4];
	plg[1]=idx[5];
	plg[2]=idx[7];
	plg[3]=idx[6];
	shl.AddPolygon(4,plg);

	plg[0]=idx[6];
	plg[1]=idx[7];
	plg[2]=idx[1];
	plg[3]=idx[0];
	shl.AddPolygon(4,plg);

	plg[0]=idx[0];
	plg[1]=idx[2];
	plg[2]=idx[4];
	plg[3]=idx[6];
	shl.AddPolygon(4,plg);

	plg[0]=idx[7];
	plg[1]=idx[5];
	plg[2]=idx[3];
	plg[3]=idx[1];
	shl.AddPolygon(4,plg);
}
void FsGui3DInterface::DrawRectMarker(const YsVec3 &o,const double lng) const
{
	YsVec3 scrnO;
	YsTransform3DCoordToScreenCoord(scrnO,o,viewport,projViewModelTfm);

	YsVec3 quad[4]=
	{
		YsVec3(scrnO.x()-markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()+markerSize,scrnO.z()),
		YsVec3(scrnO.x()-markerSize,scrnO.y()+markerSize,scrnO.z())
	};
	YsTransformScreenCoordTo3DCoord(quad[0],quad[0],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[1],quad[1],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[2],quad[2],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[3],quad[3],viewport,projViewModelTfm);

	glBegin(GL_LINE_LOOP);
	glVertex3dv(quad[0]);
	glVertex3dv(quad[1]);
	glVertex3dv(quad[2]);
	glVertex3dv(quad[3]);
	glEnd();
}
void FsGui3DInterface::Draw(void) const
{
	needRedraw=YSFALSE;

	if(type==IFTYPE_BOX)
	{
		YsVec3 cen,o;

		glColor3d(0.0,1.0,0.0);

		glEnable(GL_LINE_STIPPLE);
		glLineStipple(1,0xf0f0);

		glBegin(GL_LINES);

		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[0].z());
		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[0].z());

		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[0].z());
		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[0].z());

		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[0].z());
		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[0].z());


		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[0].z());
		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[0].z());

		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[1].z());
		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[1].z());

		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[1].z());
		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[1].z());

		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[1].z());
		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[1].z());

		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[1].z());
		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[1].z());


		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[0].z());
		glVertex3d(box_pos[0].x(),box_pos[0].y(),box_pos[1].z());

		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[0].z());
		glVertex3d(box_pos[1].x(),box_pos[0].y(),box_pos[1].z());

		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[0].z());
		glVertex3d(box_pos[1].x(),box_pos[1].y(),box_pos[1].z());

		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[0].z());
		glVertex3d(box_pos[0].x(),box_pos[1].y(),box_pos[1].z());


		glEnd();

		glDisable(GL_LINE_STIPPLE);

		cen=(box_pos[0]+box_pos[1])/2.0;

		glPointSize(float(markerSize));
		glLineWidth(float(linePickingTolerance));

		o.Set(box_pos[0].x(),cen.y(),cen.z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3( 1.0,0.0,0.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(-1.0,0.0,0.0),pickerLength);

		o.Set(box_pos[1].x(),cen.y(),cen.z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3( 1.0,0.0,0.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(-1.0,0.0,0.0),pickerLength);

		o.Set(cen.x(),box_pos[0].y(),cen.z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3(0.0, 1.0,0.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(0.0,-1.0,0.0),pickerLength);

		o.Set(cen.x(),box_pos[1].y(),cen.z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3(0.0, 1.0,0.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(0.0,-1.0,0.0),pickerLength);

		o.Set(cen.x(),cen.y(),box_pos[0].z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3(0.0,0.0, 1.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(0.0,0.0,-1.0),pickerLength);

		o.Set(cen.x(),cen.y(),box_pos[1].z());
		glBegin(GL_POINTS);
		glVertex3dv(o.GetValue());
		glEnd();
		DrawLineByPixelLength(o,YsVec3(0.0,0.0, 1.0),pickerLength);
		DrawLineByPixelLength(o,YsVec3(0.0,0.0,-1.0),pickerLength);


		glPointSize(1);
		glLineWidth(1);

		if(dragging==YSTRUE)
		{
			switch(box_dragging)
			{
			case BOX_XMIN:
				glBegin(GL_LINES);
				glVertex3d(box_pos[0].x()-infiniteLongLine,cen.y(),cen.z());
				glVertex3d(box_pos[0].x()+infiniteLongLine,cen.y(),cen.z());
				glEnd();
				break;
			case BOX_XMAX:
				glBegin(GL_LINES);
				glVertex3d(box_pos[1].x()-infiniteLongLine,cen.y(),cen.z());
				glVertex3d(box_pos[1].x()+infiniteLongLine,cen.y(),cen.z());
				glEnd();
				break;
			case BOX_YMIN:
				glBegin(GL_LINES);
				glVertex3d(cen.x(),box_pos[0].y()-infiniteLongLine,cen.z());
				glVertex3d(cen.x(),box_pos[0].y()+infiniteLongLine,cen.z());
				glEnd();
				break;
			case BOX_YMAX:
				glBegin(GL_LINES);
				glVertex3d(cen.x(),box_pos[1].y()-infiniteLongLine,cen.z());
				glVertex3d(cen.x(),box_pos[1].y()+infiniteLongLine,cen.z());
				glEnd();
				break;
			case BOX_ZMIN:
				glBegin(GL_LINES);
				glVertex3d(cen.x(),cen.y(),box_pos[0].z()-infiniteLongLine);
				glVertex3d(cen.x(),cen.y(),box_pos[0].z()+infiniteLongLine);
				glEnd();
				break;
			case BOX_ZMAX:
				glBegin(GL_LINES);
				glVertex3d(cen.x(),cen.y(),box_pos[1].z()-infiniteLongLine);
				glVertex3d(cen.x(),cen.y(),box_pos[1].z()+infiniteLongLine);
				glEnd();
				break;
			}
		}
	}
	else if(type==IFTYPE_POINT)
	{
		glColor3d(0.0,1.0,0.0);

		glBegin(GL_LINE_STRIP);
		switch(point_dlg1->GetBasePlane())
		{
		case 0:
			glVertex3d(point_pos.x(),point_pos.y(),point_pos.z());
			glVertex3d(point_pos.x(),point_pos.y(),0.0);
			glVertex3d(point_pos.x(),0.0          ,0.0);
			glVertex3d(0.0          ,0.0          ,0.0);
			glVertex3d(0.0          ,point_pos.y(),0.0);
			glVertex3d(point_pos.x(),point_pos.y(),0.0);
			break;
		case 1:
			glVertex3d(point_pos.x(),point_pos.y(),point_pos.z());
			glVertex3d(point_pos.x(),0.0          ,point_pos.z());
			glVertex3d(0.0          ,0.0          ,point_pos.z());
			glVertex3d(0.0          ,0.0          ,0.0);
			glVertex3d(point_pos.x(),0.0          ,0.0);
			glVertex3d(point_pos.x(),0.0          ,point_pos.z());
			break;
		case 2:
			glVertex3d(point_pos.x(),point_pos.y(),point_pos.z());
			glVertex3d(0.0          ,point_pos.y(),point_pos.z());
			glVertex3d(0.0          ,0.0          ,point_pos.z());
			glVertex3d(0.0          ,0.0          ,0.0);
			glVertex3d(0.0          ,point_pos.y(),0.0);
			glVertex3d(0.0          ,point_pos.y(),point_pos.z());
			break;
		}

		glEnd();


		auto nom=point_dlg1->GetNormalDirection();

		if(POINT_Y==point_dragging)
		{
			glPushAttrib(GL_ENABLE_BIT);
			glLineWidth(1);
			glEnable(GL_LINE_STIPPLE);
			glLineStipple(1,0x0003);
			glBegin(GL_LINES);
			glVertex3dv((point_pos-nom*infiniteLongLine).GetValue());
			glVertex3dv((point_pos+nom*infiniteLongLine).GetValue());
			glEnd();
			glPopAttrib();
		}

		glLineWidth(float(linePickingTolerance));
		DrawLineByPixelLength(point_pos, nom,pickerLength);
		DrawLineByPixelLength(point_pos,-nom,pickerLength);
		glLineWidth(float(1));

		DrawRectMarker(point_pos,markerSize);
	}
	else if(type==IFTYPE_DRAGPOINT)
	{
		glColor3d(0.0,1.0,0.0);

		glPointSize(float(markerSize));
		glBegin(GL_POINTS);
		glVertex3dv(point_pos.GetValue());
		glEnd();
		glPointSize(1);


		YsVec3 dragDir[3];
		if(YSTRUE==point_dlg2->UseCustomOrientation())
		{
			dragDir[0]=point_dragDir[0];
			dragDir[1]=point_dragDir[1];
			dragDir[2]=point_dragDir[2];
		}
		else
		{
			dragDir[0]=YsXVec();
			dragDir[1]=YsYVec();
			dragDir[2]=YsZVec();
		}

		const DRAGTARGET pointDragTarget[3]=
		{
			POINT_X,
			POINT_Y,
			POINT_Z
		};


		int i;
		for(i=0; i<3; i++)
		{
			if(point_dragDirSwitch[i]==YSTRUE)
			{
				glLineWidth(float(linePickingTolerance));
				DrawLineByPixelLength(point_pos, dragDir[i],pickerLength);
				DrawLineByPixelLength(point_pos,-dragDir[i],pickerLength);
			}
			if(dragging==YSTRUE && point_dragging==pointDragTarget[i])
			{
				glPushAttrib(GL_ENABLE_BIT);
				glLineWidth(1);
				glEnable(GL_LINE_STIPPLE);
				glLineStipple(1,0x0003);
				glBegin(GL_LINES);
				glVertex3dv((point_pos-dragDir[i]*infiniteLongLine).GetValue());
				glVertex3dv((point_pos+dragDir[i]*infiniteLongLine).GetValue());
				glEnd();
				glPopAttrib();
			}
		}

		glLineWidth(1);
	}
	else if(type==IFTYPE_SLIDER)
	{
	}
	else if(type==IFTYPE_ROTATION)
	{
		if(dragging==YSTRUE)
		{
			glColor3d(1.0,0.0,5.0);
		}
		else
		{
			glColor3d(0.0,1.0,0.0);
		}


		glLineWidth(3);
		glBegin(GL_LINES);
		glVertex3dv((rot_center+rot_axis*infiniteLongLine).GetValue());
		glVertex3dv((rot_center-rot_axis*infiniteLongLine).GetValue());
		glEnd();
		glLineWidth(1);


		YsVec3 iVec=rot_iVec;
		YsVec3 jVec=rot_jVec;
		YsVec3 kVec=rot_kVec;

		YsMatrix4x4 mat,axisMat;
		YsAtt3 att;
		att.SetForwardVector(rot_axis);
		att.GetMatrix4x4(axisMat);
		mat.Initialize();
		mat.Rotate(rot_axis.x(),rot_axis.y(),rot_axis.z(),rot_angle);
		mat=mat*axisMat;
		mat.Scale(1.0,1.0,rot_mirror);
		mat.Scale(rot_ref_size,rot_ref_size,rot_ref_size);
		axisMat.Invert();
		mat=mat*axisMat;

		iVec=mat*iVec;
		jVec=mat*jVec;
		kVec=mat*kVec;

		glBegin(GL_LINES);
		for(int i=0; i<360; i+=30)
		{
			YsVec3 p[2];
			double a;
			a=YsPi*2.0*double(i)/360.0;
			p[0]=rot_center+iVec*cos(a)+jVec*1.0+kVec*sin(a);
			p[1]=rot_center+iVec*cos(a)-jVec*1.0+kVec*sin(a);

			glVertex3dv(p[0].GetValue());
			glVertex3dv(p[1].GetValue());
		}
		glEnd();

		glBegin(GL_LINE_LOOP);
		for(int i=0; i<360; i+=10)
		{
			double a;
			YsVec3 p;
			a=YsPi*2.0*double(i)/360.0;
			p=rot_center+iVec*cos(a)+jVec*1.0+kVec*sin(a);
			glVertex3dv(p.GetValue());
		}
		glEnd();

		glBegin(GL_LINE_LOOP);
		for(int i=0; i<360; i+=10)
		{
			double a;
			YsVec3 p;
			a=YsPi*2.0*double(i)/360.0;
			p=rot_center+iVec*cos(a)-jVec*1.0+kVec*sin(a);
			glVertex3dv(p.GetValue());
		}
		glEnd();


		// Side drag marker

		const YsVec3 sideX=rot_drag_dir*rot_ref_size*1.1;
		const YsVec3 sideY=(rot_drag_dir^rot_axis)*rot_ref_size*1.1;

		glLineWidth(3);

		glBegin(GL_LINE_LOOP);
		for(int i=0; i<360; i+=10)
		{
			const double a=YsPi*2.0*double(i)/360.0;
			YsVec3 p;
			p=rot_center+sideX*cos(a)+sideY*sin(a);
			glVertex3dv(p);
		}
		glEnd();


		if(ROTATION_HANDLE==rot_dragging)
		{
			glBegin(GL_LINES);
			glVertex3dv(rot_center);

			const YsVec3 radial=rot_ref_size*1.1*(rot_iVec*cos(rot_drag_angle)-rot_kVec*sin(rot_drag_angle));
			glVertex3dv(rot_center+radial);

			glEnd();
		}

		glLineWidth(1);
	}
}
YSRESULT YsShellExtEdit_StitchingUtil::ProcessNearestMutualExclusiveEdgeVertexPair(YsShellExtEdit &shl)
{
	YsShellExtEdit_TopologyUtil topoUtil;

	// See research note 2014/12/17
	// See research note 2014/12/30 for Condition 5

	auto edVtPairHd=edVtProx.GetNearestEdgeVertexPairHandle();
	if(edVtPairHd.IsNotNull())
	{
		// Must check if no single-use edge is connected to the vertex because of the previous stitching.

		auto edVtPair=edVtProx.GetEdgeVertexPair(edVtPairHd);

		#ifdef YS_DEBUG_SPECIFIC_VERTEX
		if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos)
		{
			YsPrintf("%s\n",shl.GetVertexPosition(edVtPair.vtHd).Txt());
			YsPrintf("%s %s\n",shl.GetVertexPosition(edVtPair.edVtHd[0]).Txt(),shl.GetVertexPosition(edVtPair.edVtHd[1]).Txt());
			YsPrintf("nSharingEdge=%d\n",edVtPair.nSharingEdge);
		}
		#endif


		if(2==YsShellExt_TopologyUtil::GetNumSingleUseEdgeConnectedToVertex(shl.Conv(),edVtPair.vtHd) &&  // Condition (3) of Mutual-Exclusive conditions
		   YSTRUE==YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.edVtHd))  // Condition (1) of Mutual-Exclusive conditions
		{
			if(1==edVtPair.nSharingEdge)  // Condition (4) of Mutual-Exclusive conditions
			{
				// Condition 5
				const double e1e2=shl.GetEdgeLength(edVtPair.edVtHd);
				if(shl.GetEdgeLength(edVtPair.vtHd,edVtPair.edVtHd[0])<e1e2 &&
				   shl.GetEdgeLength(edVtPair.vtHd,edVtPair.edVtHd[1])<e1e2)
				{
					// Mutual
					YSBOOL reverseProximityCheckOrVertexShared[2]=
					{
						YSFALSE,YSFALSE
					};

					YsShellExt_EdgeVertexProximityUtil::EDVTPAIR_HANDLE reverseCheckPairHd[2]=
					{
						edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[0]),
						edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[1]),
					};

					for(int i=0; i<2; ++i)  // Condition (2) and (2)' of Mutual-Exclusive conditions.
					{
						if(reverseCheckPairHd[i].IsNotNull())
						{
							YsShellExt_EdgeVertexProximityUtil::EdgeVertexPair reverseCheckPair=edVtProx.GetEdgeVertexPair(reverseCheckPairHd[i]);
							if(reverseCheckPair.edVtHd[0]==edVtPair.vtHd || reverseCheckPair.edVtHd[1]==edVtPair.vtHd)  // Condition (2) of Mutual-Exclusive conditions.
							{
								#ifdef YS_DEBUG_SPECIFIC_VERTEX
								if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos)
								{
									printf("%s %s\n",shl.GetVertexPosition(reverseCheckPair.edVtHd[0]).Txt(),shl.GetVertexPosition(reverseCheckPair.edVtHd[1]).Txt());
									printf("(2)\n");
								}
								#endif

								reverseProximityCheckOrVertexShared[i]=YSTRUE;
							}
						}
						if(YSTRUE!=reverseProximityCheckOrVertexShared[i])
						{
							if(YSTRUE==YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.vtHd,edVtPair.edVtHd[i]) &&
							   0==edVtProx.GetEdgeIsClosestOfHowManyVertex(edVtPair.vtHd,edVtPair.edVtHd[i]))
							{
								#ifdef YS_DEBUG_SPECIFIC_VERTEX
								if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos)
								{
									printf("(2)'\n");
								}
								#endif

								reverseProximityCheckOrVertexShared[i]=YSTRUE;
							}
						}
					}


					if(YSTRUE==reverseProximityCheckOrVertexShared[0] && YSTRUE==reverseProximityCheckOrVertexShared[1])
					{
						#ifdef YS_DEBUG_SPECIFIC_VERTEX
						if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos)
						{
							printf("%s %d\n",__FUNCTION__,__LINE__);
						}
						#endif

						#ifdef YS_DEBUG_SPECIFIC_EDGE
						if(YSTRUE==YsSameEdge(
							   watchEdVtPos[0],
							   watchEdVtPos[1],
							   shl.GetVertexPosition(edVtPair.edVtHd[0]),
							   shl.GetVertexPosition(edVtPair.edVtHd[1])))
						{
							printf("%s %d\n",__FUNCTION__,__LINE__);
							printf("%s\n",shl.GetVertexPosition(edVtPair.vtHd).Txt());
						}
						#endif

						topoUtil.InsertVertexOnEdge(shl,edVtPair.edVtHd,1,&edVtPair.vtHd);
					}
				}
			}
		}


		#if defined(YS_DEBUG_SPECIFIC_VERTEX) && defined(YS_DEBUG_SPECIFIC_VERTEX_STOP)
		if(shl.GetVertexPosition(edVtPair.vtHd)==YsVec3(-1456.334997,  64.171291,  -0.000000) ||
		   shl.GetVertexPosition(edVtPair.vtHd)==YsVec3(-1456.2094428700, 64.4021512874, -2.3092000235))
		{
			printf("%s %d>",__FUNCTION__,__LINE__);getchar();
		}
		#endif


		edVtProx.DeleteEdgeVertexPair(edVtPairHd);
		return YSOK;
	}
	return YSERR;
}
//////////////////////////////////////////////////////////// */

#include "ysshellext_condition.h"
#include "ysshellext_trackingutil.h"
#include "ysshellextedit_stitchingutil.h"
#include "ysshellextedit_localop.h"
#include "ysshellextedit_topologyutil.h"


 #define YS_DEBUG_SPECIFIC_EDGE
// #define YS_DEBUG_SPECIFIC_VERTEX
// #define YS_DEBUG_SPECIFIC_VERTEX_STOP


#ifdef YS_DEBUG_SPECIFIC_VERTEX
static const YsVec3 watchVtPos=YsVec3(-1456.2094428700, 64.4021512874, -2.3092000235);
#endif

#ifdef YS_DEBUG_SPECIFIC_EDGE
static const YsVec3 watchEdVtPos[2]={YsVec3(-1473.708958,  59.165942,  -4.809200),YsVec3(-1475.941299,  64.107875,  -4.809200)};

#endif



YSRESULT YsShellExtEdit_FreeStitching(YsShellExtEdit &shl)
{
	YsShellExtEdit::StopIncUndo incUndo(shl);

	YsShellExtEdit_StitchingUtil stitchUtil;
	stitchUtil.PrepareForSingleUseEdge(shl.Conv());
示例#10
0
int main(int argc,char **argv)
{
    Options opt;
    if(!parse_args(&opt,argc,argv)){
        return 1;
    }
    char strk[256],strmu[256],strsigma[256],striso[256];
    int terminate=0;
    CameraObject camera;
    OrbitingViewer orbit;

	orbit.focusY=4.0;

    camera.z=10.0;

    FsOpenWindow(16,16,800,600,1);


    Cylinder cylinder;
	cylinder.setRadius(9.0);

    YsVec3 min(-10.0,0.0,-10.0);
    YsVec3 max(10.0,20.0,10.0);
    Box box;
    box.setMinMax(min,max);

    std::vector <YsVec3> iniPos;
    const double interval=0.9;
    CreateUniformInitialParticleLocation(iniPos,10,40,10,YsVec3(10.0,20.0,0.0),interval);

    std::vector <YsVec3> drip;
    CreateUniformInitialParticleLocation(drip,5,5,5,YsVec3(0.0,20.0,0.0),interval);

	ParticleSimulation sim;
    if(opt.infile){
        sim.read(opt.infile);
    }
    else{
	    //sim.init(iniPos);
    }
	sim.setObstacle(box);
	//sim.calculate_force();
	//sim.calculate_force();

	sim.mode=sim.MODE_NORMAL;



	glClearColor(0,0,0,0);

	YSBOOL pause=YSFALSE;
    YSBOOL cube=YSFALSE;
    YSBOOL savestl=YSFALSE;

    while(0==terminate)
    {
        FsPollDevice();

        int wid,hei;
        FsGetWindowSize(wid,hei);

        int key=FsInkey();
        switch(key)
        {
        case FSKEY_K:
            {
            printf("Enter k:\n");
            fscanf(stdin,"%lf",strk);
            double k=atof(strk);
            sim.setK(k);
            break;
            }
        case FSKEY_M:
            {
            printf("Enter mu:\n");
            fscanf(stdin,"%lf",strmu);
            double mu=atof(strmu);
            sim.setMu(mu);
            break;
            }
        case FSKEY_S:
            {
            printf("Enter Sigma:\n");
            fscanf(stdin,"%lf",strmu);
            double sigma=atof(strsigma);
            sim.setSigma(sigma);
            break;
            }
        case FSKEY_Q:
            if(cube){
                cube=YSFALSE;
            }
            else{
                cube=YSTRUE;
            }
            break;
        case FSKEY_I:
            {
                printf("Enter isolevel:\n");
                fscanf(stdin,"%lf",striso);
                double iso=atof(striso);
                sim.setIso(iso);
                break;
            }
        case FSKEY_L:
            if(savestl){
                savestl=YSFALSE;
            }
            else{
                savestl=YSTRUE;
            }
            break;

        case FSKEY_D:
            sim.placeParticles(drip);
            break;

		case FSKEY_P:
			YsFlip(pause);
			break;
        case FSKEY_ESC:
            terminate=1;
            break;
        }


		if(FSKEY_SPACE==key || YSTRUE!=pause)
		{
			sim.update();
		}

        if(0!=FsGetKeyState(FSKEY_LEFT))
        {
            orbit.h+=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_RIGHT))
        {
            orbit.h-=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_UP))
        {
            orbit.p+=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_DOWN))
        {
            orbit.p-=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_F) && orbit.dist>1.0)
        {
            orbit.dist/=1.05;
        }
        if(0!=FsGetKeyState(FSKEY_B) && orbit.dist<200.0)
        {
            orbit.dist*=1.05;
        }
        orbit.SetUpCamera(camera);

        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

        glViewport(0,0,wid,hei);

        // Set up 3D drawing
        camera.SetUpCameraProjection();
        camera.SetUpCameraTransformation();

        glEnable(GL_DEPTH_TEST);
        glEnable(GL_POLYGON_OFFSET_FILL);
        glPolygonOffset(1,1);

        // 3D drawing from here
		glPushMatrix();
		glPointSize(3);
        if(cube){
           sim.drawMesh();
           if(savestl){
               sim.shl.SaveBinStl("test.stl");
               printf("stl saved\n");
               savestl=YSFALSE;
           }
        }
        else{
            sim.drawParticles();
        }
        //sim.drawColorFieldGrid();

        glPopMatrix();

        // Set up 2D drawing
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,(float)wid-1,(float)hei-1,0,-1,1);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glDisable(GL_DEPTH_TEST);

        FsSwapBuffers();
        FsSleep(25);
    }
    //sim.write(opt.outfile);

    return 0;
}
void GeblGuiEditorBase::Draw(void)
{
	if(YSTRUE!=drawingMasterSwitch)
	{
		DrawGuiOnly();
		return;
	}

	// Do this at the beginning of Draw funtion.  This will allow one of the elements set SetNeedRedraw(YSTRUE) 
	// within drawing function so that Draw function will be called again in the next iteragion. >>
	SetNeedRedraw(YSFALSE);
	drawEnv.SetNeedRedraw(YSFALSE);
	threeDInterface.SetNeedRedraw(YSFALSE);
	// <<


	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(1,1);


	if(NULL==slHd)
	{
		if(NULL!=GetTopStatusBar())
		{
			GetTopStatusBar()->ClearStringAll();
		}
		if(NULL!=GetBottomStatusBar())
		{
			GetBottomStatusBar()->ClearStringAll();
		}
	}

	if(NULL!=slHd && NULL!=GetTopStatusBar())
	{
		YsWString ful,pth,fil;
		slHd->GetFileName(ful);
		ful.SeparatePathFile(pth,fil);
		if(YSTRUE==slHd->IsModified())
		{
			fil.Append(L"(*)");
		}

		YsWString curMsg;
		if(0!=YsWString::Strcmp(fil,GetTopStatusBar()->GetString(curMsg,0)))
		{
			GetTopStatusBar()->SetString(0,fil);
		}
	}

	if(NULL!=slHd && NULL!=GetBottomStatusBar())
	{
		YsString str("Selection");
		YsString append;

		{
			YsArray <YsShellVertexHandle> selVtHd;
			slHd->GetSelectedVertex(selVtHd);
			if(0<selVtHd.GetN())
			{
				append.Printf("  Vertex:%d",(int)selVtHd.GetN());
				str.Append(append);
			}
		}
		{
			YsArray <YsShellPolygonHandle> selPlHd;
			slHd->GetSelectedPolygon(selPlHd);
			if(0<selPlHd.GetN())
			{
				append.Printf("  Polygon:%d",(int)selPlHd.GetN());
				str.Append(append);
			}
		}
		{
			YsArray <YsShellExt::ConstEdgeHandle> selCeHd;
			slHd->GetSelectedConstEdge(selCeHd);
			if(0<selCeHd.GetN())
			{
				append.Printf("  ConstEdge:%d",(int)selCeHd.GetN());
				str.Append(append);
			}
		}
		{
			YsArray <YsShellExt::FaceGroupHandle> selFgHd;
			slHd->GetSelectedFaceGroup(selFgHd);
			if(0<selFgHd.GetN())
			{
				append.Printf("  FaceGroup:%d",(int)selFgHd.GetN());
				str.Append(append);
			}
		}
		GetBottomStatusBar()->SetString(0,str);
	}


	int viewport[4];
	drawEnv.GetOpenGlCompatibleViewport(viewport);
	drawEnv.SetVerticalOrientation(YSTRUE);
	drawEnv.UpdateNearFar();


	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);


	if(YsCoordSysModel==YSOPENGL)
	{
		glFrontFace(GL_CCW);
	}
	else
	{
		glFrontFace(GL_CW);
	}


	const YsMatrix4x4 &projMat=drawEnv.GetProjectionMatrix();
	const YsMatrix4x4 &viewMat=drawEnv.GetViewMatrix();
	const YsMatrix4x4 projViewMat=(projMat*viewMat);

	threeDInterface.SetViewport(viewport);
	threeDInterface.SetProjViewModelMatrix(projViewMat);


	glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);

	GLfloat glProjMat[16];
	projMat.GetOpenGlCompatibleMatrix(glProjMat);

	GLfloat glModelviewMat[16];
	viewMat.GetOpenGlCompatibleMatrix(glModelviewMat);


	// glMatrixMode(GL_PROJECTION);
	// glLoadIdentity();
	// glMultMatrixf(glProjMat);
	// glMatrixMode(GL_MODELVIEW);
	// glLoadIdentity();
	// glMultMatrixf(glModelviewMat);


	YsGLSLSetShared3DRendererProjection(glProjMat);
	YsGLSLSetShared3DRendererModelView(glModelviewMat);


	YsVec3 lightDir=YsUnitVector(YsVec3(0.1,1.0,3.0));
	const GLfloat lightDirf[]={lightDir.xf(),lightDir.yf(),lightDir.zf()};
	YsGLSLSetShared3DRendererDirectionalLightInCameraCoordinatefv(0,lightDirf);
	YsGLSLSetShared3DRendererSpecularColor(config->GetSpecularColor());
	YsGLSLSetShared3DRendererAmbientColor(config->GetAmbientColor());
	YsGLSLSetShared3DRendererLightColor(0,config->GetLightColor());



	actuallyDrawVertex=drawVertex;
	actuallyDrawConstEdge=drawConstEdge;
	actuallyDrawPolygonEdge=drawPolygonEdge;
	actuallyDrawPolygon=drawPolygon;
	actuallyDrawShrunkPolygon=drawShrunkPolygon;
	actuallyDrawNonManifoldEdge=drawNonManifoldEdge;

	if(NULL!=UIBeforeDrawCallBack)
	{
		(*UIBeforeDrawCallBack)(*this);
	}

	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);


	if(YSTRUE==viewDrawBackgroundGradation->GetCheck() && (NULL==guiExtension || YSTRUE!=guiExtension->DrawBackground()))
	{
// Linear interpolation looks to be too fast.  Probably need three colors.
		YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer());
		YsGLSLUseWindowCoordinateInPlain2DDrawing(YsGLSLSharedPlain2DRenderer(),YSTRUE);

		glDepthMask(0);

		const GLfloat rect[12]=
		{
			0                   ,0,
			(GLfloat)viewport[2],0,
			0                   ,(GLfloat)viewport[3]/2.0f,
			(GLfloat)viewport[2],(GLfloat)viewport[3]/2.0f,
			0                   ,(GLfloat)viewport[3],
			(GLfloat)viewport[2],(GLfloat)viewport[3]
		};
		const GLfloat color[24]=
		{
			config->bgColor[0].Rf(),config->bgColor[0].Gf(),config->bgColor[0].Bf(),1,
			config->bgColor[0].Rf(),config->bgColor[0].Gf(),config->bgColor[0].Bf(),1,
			config->bgColor[1].Rf(),config->bgColor[1].Gf(),config->bgColor[1].Bf(),1,
			config->bgColor[1].Rf(),config->bgColor[1].Gf(),config->bgColor[1].Bf(),1,
			config->bgColor[2].Rf(),config->bgColor[2].Gf(),config->bgColor[2].Bf(),1,
			config->bgColor[2].Rf(),config->bgColor[2].Gf(),config->bgColor[2].Bf(),1
		};
		YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(),GL_TRIANGLE_STRIP,6,rect,color);

		glDepthMask(1);

		YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer());
	}



	threeDInterface.Draw();


	if(NULL!=slHd && YSTRUE==slHd->NeedRemakeHighlightVertexBuffer())
	{
		slHd->GetHighlight().RemakeVertexBuffer(*slHd);
		slHd->SetNeedRemakeHighlightVertexBuffer(YSFALSE);
	}

	if(NEED_REMAKE_DRAWING_NONE!=needRemakeDrawingBuffer || (nullptr!=slHd && YSTRUE==slHd->GetTemporaryModification().Changed()))
	{
		RemakeDrawingBuffer(slHd,needRemakeDrawingBuffer);
		needRemakeDrawingBuffer=NEED_REMAKE_DRAWING_NONE;
		slHd->GetTemporaryModification().ClearChangeFlag();
	}
	if(NEED_REMAKE_DRAWING_NONE!=needRemakeDrawingBuffer_for_OtherShell && YSTRUE==actuallyDrawOtherShell)
	{
		YsArray <YsShellDnmContainer <YsShellExtEditGui>::Node *> allNode;
		shlGrp.GetNodePointerAll(allNode);
		for(YSSIZE_T nodeIdx=0; nodeIdx<allNode.GetN(); ++nodeIdx)
		{
			if(slHd!=allNode[nodeIdx])
			{
				RemakeDrawingBuffer(allNode[nodeIdx],needRemakeDrawingBuffer_for_OtherShell);
			}
		}
		needRemakeDrawingBuffer_for_OtherShell=NEED_REMAKE_DRAWING_NONE;
	}


	{
		GLfloat prevTfm[16];
		GLfloat curNodeTfm[16];
		if(YSTRUE==dnmEditMode)
		{
			YsMatrix4x4 curMat;
			{
				YsGLSLShaded3DRenderer renderer;
				renderer.GetModelView(prevTfm);
				curMat.CreateFromOpenGlCompatibleMatrix(prevTfm);
			}
			YsMatrix4x4 tfm=curMat*dnmState.GetNodeToRootTransformation(slHd);
			tfm.GetOpenGlCompatibleMatrix(curNodeTfm);
			YsGLSLSetShared3DRendererModelView(curNodeTfm);
		}


		YsShellExtDrawingBuffer &drawBuf=slHd->GetDrawingBuffer();
		if(YSTRUE==actuallyDrawVertex && NULL!=slHd)
		{
			GeblGuiFoundation::DrawVertex(*slHd,viewport);
		}
		if(0<drawBuf.selectedVertexPosBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawSelectedVertex(*slHd,viewport);
		}
		if(0<drawBuf.selectedVertexLineBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawSelectedVertexLine(*slHd);
		}
		if(YSTRUE==actuallyDrawPolygonEdge && NULL!=slHd)
		{
			GeblGuiFoundation::DrawPolygonEdge(*slHd);
		}
		if(YSTRUE==actuallyDrawShrunkPolygon && NULL!=slHd)
		{
			GeblGuiFoundation::DrawShrunkPolygon(*slHd);

		}
		if(0<drawBuf.selectedPolygonPosBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawSelectedPolygon(*slHd);
		}
		if(YSTRUE==actuallyDrawConstEdge && 0<drawBuf.constEdgeVtxBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawConstEdge(*slHd);
		}
		if(0<drawBuf.selectedConstEdgeVtxBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawSelectedConstEdge(*slHd);
		}
		if(YSTRUE==dnmEditMode)
		{
			YsGLSLSetShared3DRendererModelView(prevTfm);
		}


		if(YSTRUE!=dnmEditMode)
		{
			DrawInGeometryEditMode();
		}
		else
		{
			DrawInDnmEditMode();
		}


		if(YSTRUE==dnmEditMode)
		{
			YsGLSLSetShared3DRendererModelView(curNodeTfm);
		}
		if(0<=drawBuf.selectedFaceGroupVtxBuffer.GetNumVertex() && NULL!=slHd)
		{
			GeblGuiFoundation::DrawSelectedFaceGroup(*slHd);
		}
		if(YSTRUE==dnmEditMode)
		{
			YsGLSLSetShared3DRendererModelView(prevTfm);
		}
	}




	if(NULL!=slHd && YSTRUE==actuallyDrawNonManifoldEdge)
	{
		if(YSTRUE==nonManifoldEdgeCache.IsModified(slHd))
		{
			nonManifoldEdgeCache.CacheNonManifoldEdge(slHd);
		}
		struct YsGLSL3DRenderer *renderer=YsGLSLSharedVariColor3DRenderer();
		YsGLSLUse3DRenderer(renderer);

		glLineWidth(3);
		YsGLSLDrawPrimitiveVtxColfv(renderer,GL_LINES,nonManifoldEdgeCache.lineVtxBuf.GetNi(),nonManifoldEdgeCache.lineVtxBuf,nonManifoldEdgeCache.lineColBuf);
		glLineWidth(1);

		YsGLSLEndUse3DRenderer(renderer);

		// The following could have easily be done by glPointSize.  However, stupid OpenGL ES 2.0 got rid of glPointSize.
		// OpenGL ES should be gone.  The hardware on the tablets and smart phones are good enough to support full-blown
		// OpenGL.  OpenGL ES will be remembered as a dark history of OpenGL.  That is bad.  Not as bad as Direct 3D though.
		renderer=YsGLSLSharedVariColorMarkerByPointSprite3DRenderer();
		YsGLSLUse3DRenderer(renderer);

#ifdef GL_PROGRAM_POINT_SIZE
		glEnable(GL_POINT_SPRITE);
		glEnable(GL_PROGRAM_POINT_SIZE);
#endif
		YsGLSLSet3DRendererUniformMarkerType(renderer,YSGLSL_MARKER_TYPE_RECT);
		YsGLSLSet3DRendererUniformMarkerDimension(renderer,3.0f);
		YsGLSLDrawPrimitiveVtxColfv(
		    renderer,GL_POINTS,
		    nonManifoldEdgeCache.pointVtxBuf.GetNi(),
		    nonManifoldEdgeCache.pointVtxBuf,
		    nonManifoldEdgeCache.pointColBuf);
#ifdef GL_PROGRAM_POINT_SIZE
		glDisable(GL_POINT_SPRITE);
		glDisable(GL_PROGRAM_POINT_SIZE);
#endif
		YsGLSLEndUse3DRenderer(renderer);
	}

	if(YSTRUE==drawHighlight)
	{
		auto &bufManager=YsGLBufferManager::GetSharedBufferManager();
		auto &highlight=slHd->GetHighlight();

		YsGLSLRenderer renderer(YsGLSLSharedFlat3DRenderer());

		const GLfloat blue[]={0.0f,0.0f,1.0f,1.0f};
		YsGLSLSet3DRendererUniformColorfv(renderer,blue);

		{
			auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedEdgeVboHandle);
			if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState())
			{
				unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_LINES);
			}
		}

		glLineWidth(2);
		{
			auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedThickEdgeVboHandle);
			if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState())
			{
				unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_LINES);
			}
		}
		glLineWidth(1);

		const GLfloat darkBlue[]={0.0f,0.0f,0.7f,1.0f};
		YsGLSLSet3DRendererUniformColorfv(renderer,darkBlue);
		{
			auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedPolygonVboHandle);
			if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState())
			{
				unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_TRIANGLES);
			}
		}
	}

	if(NULL!=UIDrawCallBack3D)
	{
		UIDrawCallBack3D(*this);
	}
	if(draw3dCallBack)
	{
		draw3dCallBack();
	}


	refBmpStore->Draw();


	if(YSTRUE==drawAxis)
	{
		const GLfloat axisLength=5.0;
		GeblGuiFoundation::DrawAxis(axisLength,viewport,projMat,viewMat);
	}



	// 2D Drawing
	// glMatrixMode(GL_PROJECTION);
	// glLoadIdentity();
	// glOrtho(0.0,(double)viewport[2],(double)viewport[3],0.0,-1.0,1.0);
	// glMatrixMode(GL_MODELVIEW);
	// glLoadIdentity();

	YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer());
	YsGLSLUseWindowCoordinateInPlain2DDrawing(YsGLSLSharedPlain2DRenderer(),YSTRUE);
	{
		if(YSTRUE==lBtnDown)
		{
			const GLfloat rect[8]=
			{
				(GLfloat)lBtnDownMx,(GLfloat)lBtnDownMy,
				(GLfloat)moveMx,    (GLfloat)lBtnDownMy,
				(GLfloat)moveMx,    (GLfloat)moveMy,
				(GLfloat)lBtnDownMx,(GLfloat)moveMy
			};
			const GLfloat color[16]=
			{
				0,0,0,0.8f,
				0,0,0,0.8f,
				0,0,0,0.8f,
				0,0,0,0.8f
			};
			YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(),GL_LINE_LOOP,4,rect,color);
		}
	}
	YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer());

	glDisable(GL_DEPTH_TEST);

	FsGuiCanvas::Show();

	if(NULL!=UIDrawCallBack2D)
	{
		(*UIDrawCallBack2D)(*this);
	}

	FsSwapBuffers();
}