示例#1
0
void Camera2D::DrawGrid(float size)
{
    bbox2f b = getBounding();

    float x = floor(b.min.x/size)*size;
    float y = floor(b.min.y/size)*size;

    glBegin(GL_LINES);
    while(x <= b.max.x)
    {
        if ( x >= b.min.x)
        {
            glVertex2f(x, b.min.y);
            glVertex2f(x, b.max.y);
        }
        x += size;
    }

    while(y <= b.max.y)
    {
        if ( y >= b.min.y)
        {
            glVertex2f(b.min.x, y);
            glVertex2f(b.max.x, y);
        }
        y += size;
    }
    glEnd();
}
示例#2
0
文件: Item.cpp 项目: 7ung/NMGAME
void Item::checkifOutofScreen()
{
	if (this->getStatus() != eStatus::NORMAL)
		return;
	auto viewport = ((PlayScene*)SceneManager::getInstance()->getCurrentScene())->getViewport();
	RECT screenBound = viewport->getBounding();
	GVector2 position = this->getPosition();
	if (position.y < screenBound.bottom)
	{
		this->setStatus(eStatus::DESTROY);
	}
}
示例#3
0
文件: MlCache.cpp 项目: ahmidou/aphid
bool MlCache::doCopy(const std::string & name)
{
	std::cout<<"copy cache to "<<name;

	useDocument();
	openEntry("/ang");
	int nang = entrySize("/ang");

	if(nang < 1) return false;
	
	std::vector<std::string> sliceNames;
	unsigned numSlices = cacheSliceNames("/ang", sliceNames);
	std::cout<<" n slice "<<numSlices<<"in /ang\n";
	if(numSlices < 2) return false;
	
	openEntry("/tang");
	int tsize = entrySize("/tang");
	openEntry("/p");
	int ptsize = entrySize("/p");
	
	MlCache tgt;
	if(!tgt.create(name)) return false;
	
	tgt.useDocument();
	tgt.openEntry("/info");
	HBase *info = tgt.getNamedEntry("/info");
	info->addStringAttr(".scene", m_sceneName.size());
	info->writeStringAttr(".scene", m_sceneName);
	info->addIntAttr(".range", 2);
	info->writeIntAttr(".range", m_bakeRange);
	tgt.closeEntry("/info");
	
	tgt.openEntry("/ang");
	tgt.saveEntrySize("/ang", nang);
	
	tgt.openEntry("/tang");
	tgt.saveEntrySize("/tang", tsize);
	
	tgt.openEntry("/p");
	tgt.saveEntrySize("/p", ptsize);
	
	const unsigned blockL = 4096;
	float * b = new float[blockL];
	Vector3F * bp = new Vector3F[blockL];
	Matrix33F * bm = new Matrix33F[blockL];
	
	BoundingBox box;
	Vector3F center;
	unsigned i, j, start, count;
	for(i = 0; i < sliceNames.size(); i++) {
		std::string aslice = HObject::PartialPath("/ang", sliceNames[i]);
		if(aslice == "-9999") continue;
		
		useDocument();
		openSliceFloat("/ang", aslice);
		openSliceVector3("/p", aslice);
		openSliceMatrix33("/tang", aslice);
		
		tgt.useDocument();
		tgt.openSliceFloat("/ang", aslice);
		tgt.openSliceVector3("/p", aslice);
		tgt.openSliceMatrix33("/tang", aslice);
		
		start = 0;
		count = blockL;
		for(j = 0; j <= nang/blockL; j++) {
			if(j== nang/blockL)
				count = nang%blockL;
				
			start = j * blockL;

			useDocument();
			readSliceFloat("/ang", aslice, start, count, b);
		
			tgt.useDocument();
			tgt.writeSliceFloat("/ang", aslice, start, count, b);
		}
		
		start = 0;
		count = blockL;
		for(j = 0; j <= tsize/blockL; j++) {
			if(j== tsize/blockL)
				count = tsize%blockL;
				
			start = j * blockL;	
			useDocument();
			readSliceVector3("/p", aslice, start, count, bp);
			readSliceMatrix33("/tang", aslice, start, count, bm);
			
			tgt.useDocument();
			tgt.writeSliceVector3("/p", aslice, start, count, bp);
			tgt.writeSliceMatrix33("/tang", aslice, start, count, bm);

		}
		
		useDocument();
		closeSlice("/ang", aslice);
		closeSlice("/tang", aslice);
		closeSlice("/p", aslice);
		tgt.useDocument();
		tgt.closeSlice("/ang", aslice);
		tgt.closeSlice("/tang", aslice);
		tgt.closeSlice("/p", aslice);
		
		getBounding(aslice, box);
		getTranslation(aslice, center);
		
		tgt.setBounding(aslice, box);
		tgt.setTranslation(aslice, center);
		tgt.flush();
	}
	delete[] b;
	delete[] bp;
	delete[] bm;
	
	useDocument();
	closeEntry("/ang");
	closeEntry("/tang");
	closeEntry("/p");
	
	tgt.useDocument();
	tgt.closeEntry("/ang");
	tgt.closeEntry("/tang");
	tgt.closeEntry("/p");
	
	tgt.close();
	return true;
}