示例#1
0
void CCustomObject::AnimationDrawPath()
{
    // motion path
	VERIFY (m_Motion);
#ifdef _EDITOR
	if (EPrefs->object_flags.is(epoDrawAnimPath)){
        float fps 				= m_Motion->FPS();
        float min_t				= (float)m_Motion->FrameStart()/fps;
        float max_t				= (float)m_Motion->FrameEnd()/fps;

        Fvector 				T,r;
        u32 clr					= 0xffffffff;
        path_points.clear		();
        for (float t=min_t; (t<max_t)||fsimilar(t,max_t,EPS_L); t+=1/30.f){
            m_Motion->_Evaluate	(t,T,r);
            path_points.push_back(T);
        }

        Device.SetShader		(Device.m_WireShader);
        RCache.set_xform_world	(Fidentity);
        if (!path_points.empty())
        	DU_impl.DrawPrimitiveL		(D3DPT_LINESTRIP,path_points.size()-1,path_points.begin(),path_points.size(),clr,true,false);
        CEnvelope* E 			= m_Motion->Envelope();
        for (KeyIt k_it=E->keys.begin(); k_it!=E->keys.end(); k_it++){
            m_Motion->_Evaluate	((*k_it)->time,T,r);
            if (Device.m_Camera.GetPosition().distance_to_sqr(T)<50.f*50.f){
                DU_impl.DrawCross	(T,0.1f,0.1f,0.1f, 0.1f,0.1f,0.1f, clr,false);
                DU_impl.OutText		(T,AnsiString().sprintf("K: %3.3f",(*k_it)->time).c_str(),0xffffffff,0x00000000);
            }
        }
    }
#endif    
}
示例#2
0
int AppendVertex(FvectorVec& _points, MPoint& _pt)
{
	Fvector pt; 
	// convert from internal units to the current ui units
	MDistance dst_x	(_pt.x);
	MDistance dst_y	(_pt.y);
	MDistance dst_z	(_pt.z);
	pt.set		((float)dst_x.asMeters(),(float)dst_y.asMeters(),-(float)dst_z.asMeters());

	for (FvectorIt it=_points.begin(); it!=_points.end(); it++)
		if (it->similar(pt)) return it-_points.begin();
	_points.push_back(pt);
	return _points.size()-1;
}
示例#3
0
bool CEditableMesh::OptimizeFace(st_Face& face){
	Fvector points[3];
	int mface[3];
	int k;

	for (k=0; k<3; k++){
    	points[k].set(m_Verts[face.pv[k].pindex]);
		mface[k] = -1;
    }

	// get similar vert idx list
	for (k=0; k<3; k++){
		U32Vec* vl;
		int ix,iy,iz;
		ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX);
		iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY);
		iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ);
		vl = &(VM[ix][iy][iz]);
		for(U32It it=vl->begin();it!=vl->end(); it++){
			FvectorIt v = m_NewPoints.begin()+(*it);
            if( v->similar(points[k],EPS) )
                mface[k] = *it;
		}
	}
	for(k=0; k<3; k++ ){
		if( mface[k] == -1 ){
			mface[k] = m_NewPoints.size();
			m_NewPoints.push_back( points[k] );
			int ix,iy,iz;
			ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX);
			iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY);
			iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ);
			VM[ix][iy][iz].push_back(mface[k]);
			int ixE,iyE,izE;
			ixE = iFloor(float(points[k].x+VMeps.x-VMmin.x)/VMscale.x*MX);
			iyE = iFloor(float(points[k].y+VMeps.y-VMmin.y)/VMscale.y*MY);
			izE = iFloor(float(points[k].z+VMeps.z-VMmin.z)/VMscale.z*MZ);
			if (ixE!=ix)
				VM[ixE][iy][iz].push_back(mface[k]);
			if (iyE!=iy)
				VM[ix][iyE][iz].push_back(mface[k]);
			if (izE!=iz)
				VM[ix][iy][izE].push_back(mface[k]);
			if ((ixE!=ix)&&(iyE!=iy))
				VM[ixE][iyE][iz].push_back(mface[k]);
			if ((ixE!=ix)&&(izE!=iz))
				VM[ixE][iy][izE].push_back(mface[k]);
			if ((iyE!=iy)&&(izE!=iz))
				VM[ix][iyE][izE].push_back(mface[k]);
			if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz))
				VM[ixE][iyE][izE].push_back(mface[k]);
		}
	}

	if ((mface[0]==mface[1])||(mface[1]==mface[2])||(mface[0]==mface[2])){
		Msg("!Optimize: Invalid face found. Removed.");
        return false;
	}else{
    	face.pv[0].pindex = mface[0];
    	face.pv[1].pindex = mface[1];
    	face.pv[2].pindex = mface[2];
        return true;
	}
}