示例#1
0
文件: ccSphere.cpp 项目: jebd/trunk
void ccSphere::drawNameIn3D(CC_DRAW_CONTEXT& context)
{
	if (!context._win)
		return;

	//we display it in the 2D layer in fact!
    ccBBox bBox = getBB(true,false,m_currentDisplay);
	if (bBox.isValid())
	{
		const double* MM = context._win->getModelViewMatd(); //viewMat
		const double* MP = context._win->getProjectionMatd(); //projMat
		int VP[4];
		context._win->getViewportArray(VP);

		GLdouble xp,yp,zp;
		CCVector3 C = bBox.getCenter();
		gluProject(C.x,C.y,C.z,MM,MP,VP,&xp,&yp,&zp);

		//we want to display this name next to the sphere, and not above it!
		const ccViewportParameters& params = context._win->getViewportParameters();
		int dPix = (int)ceil(params.zoom * m_radius/params.pixelSize);

		int bkgBorder = QFontMetrics(context._win->getTextDisplayFont()).height()/4+4;
		context._win->displayText(getName(),(int)xp+dPix+bkgBorder,(int)yp,ccGenericGLDisplay::ALIGN_HLEFT | ccGenericGLDisplay::ALIGN_VMIDDLE,75);
	}
}
示例#2
0
ccBBox ccDrawableObject::getFitBB(ccGLMatrix& trans)
{
	//Default behavior: returns axis aligned bounding box!
	trans.toIdentity();
	return getBB(true,false,m_currentDisplay);

}
示例#3
0
void ccHObject::drawNameIn3D(CC_DRAW_CONTEXT& context)
{
	if (!context._win)
		return;

	//we display it in the 2D layer in fact!
	ccBBox bBox = getBB(false,false,m_currentDisplay);
	if (bBox.isValid())
	{
		const double* MM = context._win->getModelViewMatd(); //viewMat
		const double* MP = context._win->getProjectionMatd(); //projMat
		int VP[4];
		context._win->getViewportArray(VP);

		GLdouble xp,yp,zp;
		CCVector3 C = bBox.getCenter();
		gluProject(C.x,C.y,C.z,MM,MP,VP,&xp,&yp,&zp);

		QFont font = context._win->getTextDisplayFont(); //takes rendering zoom into account!
		context._win->displayText(	getName(),
									static_cast<int>(xp),
									static_cast<int>(yp),
									ccGenericGLDisplay::ALIGN_HMIDDLE | ccGenericGLDisplay::ALIGN_VMIDDLE,
									0.75f,
									0,
									&font);
	}
}
示例#4
0
void PlayerMelee::tick()
{
    Game& core = Game::getInstance();

    for (auto& p : core.level->getCollisions(getBB()))
    {
        if (p.first->isBreakable())
        {
            core.level->setTile(p.second.left/8.0+0.5,p.second.bottom/8.0+0.5, 0);
            core.addEntity(new SmokeEffect(Coord(p.second.left+4.0,p.second.bottom+4.0)));
        }
    }

    pos += getVel();

    if (life>0) --life;
    if (life == 0) dead = true;
}
示例#5
0
void ccHObject::drawNameIn3D(CC_DRAW_CONTEXT& context)
{
    if (!context._win)
        return;

    //we display it in the 2D layer in fact!
    ccBBox bBox = getBB(true,false,m_currentDisplay);
    if (bBox.isValid())
    {
        const double* MM = context._win->getModelViewMatd(); //viewMat
        const double* MP = context._win->getProjectionMatd(); //projMat
        int VP[4];
        context._win->getViewportArray(VP);

        GLdouble xp,yp,zp;
        CCVector3 C = bBox.getCenter();
        gluProject(C.x,C.y,C.z,MM,MP,VP,&xp,&yp,&zp);

        context._win->displayText(getName(),(int)xp,(int)yp,ccGenericGLDisplay::ALIGN_HMIDDLE | ccGenericGLDisplay::ALIGN_VMIDDLE,75);
    }
}
示例#6
0
CCVector3 ccHObject::getBBCenter()
{
	ccBBox box = getBB(true,false,m_currentDisplay);

	return box.getCenter();
}
示例#7
0
void ccDrawableObject::drawBB(const colorType col[])
{
    getBB(true,false,m_currentDisplay).draw(col);
}
示例#8
0
void MDPhi::dump(Region * rg, UseDefMgr * mgr)
{
    ASSERT0(rg);
    ASSERT0(is_phi());
    if (g_tfile == NULL) { return; }

    List<IRBB*> preds;
    IR_CFG * cfg = rg->getCFG();
    ASSERT0(cfg);
    cfg->get_preds(preds, getBB());
    IRBB * pred = preds.get_head();

    ASSERT0(getResult());
    fprintf(g_tfile, "Phi: MD%dV%d <- ",
        getResult()->mdid(), getResult()->version());
    for (IR const* opnd = getOpndList(); opnd != NULL; opnd = opnd->get_next()) {
        if (opnd != getOpndList()) {
            fprintf(g_tfile, ", ");
        }

        switch (opnd->get_code()) {
        case IR_CONST:
            fprintf(g_tfile, "Const");
            break;
        case IR_LDA:
            fprintf(g_tfile, "Lda");
            break;
        case IR_ID:
            {
                VMD * vopnd = getOpndVMD(opnd, mgr);
                fprintf(g_tfile, "MD%dV%d(id:%d)",
                    vopnd->mdid(), vopnd->version(), opnd->id());
            }
            break;
        default: UNREACH();
        }

        ASSERT0(pred);
        fprintf(g_tfile, "(BB%d)", pred->id());
        pred = preds.get_next();
    }

    VMD * res = getResult();
    ASSERT0(res);
    fprintf(g_tfile, "|UsedBy:");
    SEGIter * vit = NULL;
    bool first = true;
    for (INT i2 = res->getOccSet()->get_first(&vit);
        i2 >= 0; i2 = res->getOccSet()->get_next(i2, &vit)) {
        if (first) {
            first = false;
        } else {
            fprintf(g_tfile, ",");
        }

        IR const* use = rg->getIR(i2);
        ASSERT0(use && (use->isMemoryRef() || use->is_id()));
        fprintf(g_tfile, "%s(id:%d)", IRNAME(use), use->id());
    }

    fflush(g_tfile);
}