当前位置: 首页>>代码示例>>C++>>正文


C++ EntityBase类代码示例

本文整理汇总了C++中EntityBase的典型用法代码示例。如果您正苦于以下问题:C++ EntityBase类的具体用法?C++ EntityBase怎么用?C++ EntityBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EntityBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PointInThreeSpace

ExprVector ConstraintBase::PointInThreeSpace(hEntity workplane,
                                             Expr *u, Expr *v)
{
    EntityBase *w = SK.GetEntity(workplane);

    ExprVector ub = w->Normal()->NormalExprsU();
    ExprVector vb = w->Normal()->NormalExprsV();
    ExprVector ob = w->WorkplaneGetOffsetExprs();

    return (ub.ScaledBy(u)).Plus(vb.ScaledBy(v)).Plus(ob);
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:11,代码来源:constrainteq.cpp

示例2: S_NOTIFY_FIXED_UPDATE

 void PacketProcess::S_NOTIFY_FIXED_UPDATE(PK_S_NOTIFY_FIXED_UPDATE rowPacket)
 {
     EntityBase* ret = _gameMgr->getEntityFromID((int)rowPacket.validID);
     if (ret ==nullptr || ret->getEntityType() != EntityType::ENTITY_HUMAN ) return;
     
     EntityHuman* player = (EntityHuman*)ret;
     
     log("S_NOTIFY_FIXED_UPDATE %f %f", rowPacket.position.x, rowPacket.position.y);
     player->setWorldPosition(rowPacket.position);
     
     //_gameMgr->getGameWorld()->getGameCamera()->setCameraPos(rowPacket.position);
 }
开发者ID:Thomas2070,项目名称:THE_DEAD_FOREST,代码行数:12,代码来源:PacketProcess.cpp

示例3: S_BROADCAST_BEZEL_MOVE_KEYDOWN

 void PacketProcess::S_BROADCAST_BEZEL_MOVE_KEYDOWN(Packet* rowPacket)
 {
     PK_S_BROADCAST_BEZEL_MOVE_KEYDOWN* broadcastPacket = (PK_S_BROADCAST_BEZEL_MOVE_KEYDOWN*)rowPacket;
     
     EntityBase* ret = _gameMgr->getEntityFromID((int)broadcastPacket->validID);
     
     if (ret ==nullptr || ret->getEntityType() != EntityType::ENTITY_HUMAN ) return;
     
     EntityHuman* player = (EntityHuman*)ret;
     
     player->setTargetHeading(broadcastPacket->heading);
     
 }
开发者ID:Thomas2070,项目名称:THE_DEAD_FOREST,代码行数:13,代码来源:PacketProcess.cpp

示例4: S_BROADCAST_JOYSTICK_MOVE_KEYUP

 void PacketProcess::S_BROADCAST_JOYSTICK_MOVE_KEYUP(Packet* rowPacket)
 {
     PK_S_BROADCAST_JOYSTICK_MOVE_KEYUP* broadcastPacket = (PK_S_BROADCAST_JOYSTICK_MOVE_KEYUP*)rowPacket;
     
     EntityBase* ret = _gameMgr->getEntityFromID((int)broadcastPacket->validID);
     if (ret ==nullptr || ret->getEntityType() != EntityType::ENTITY_HUMAN ) return;
     
     EntityHuman* player = (EntityHuman*)ret;
     
     //player->setPosition(broadcastPacket->position);
     
     player->removeInputMask(JoystickMessageTypes::MOVE);
     delete broadcastPacket;
 }
开发者ID:Thomas2070,项目名称:THE_DEAD_FOREST,代码行数:14,代码来源:PacketProcess.cpp

示例5: S_BROADCAST_JOYSTICK_MOVING_CHANGE

 void PacketProcess::S_BROADCAST_JOYSTICK_MOVING_CHANGE(Packet* rowPacket)
 {
     PK_S_BROADCAST_JOYSTICK_MOVING_CHANGE* broadcastPacket = (PK_S_BROADCAST_JOYSTICK_MOVING_CHANGE*)rowPacket;
     
     EntityBase* ret = _gameMgr->getEntityFromID((int)broadcastPacket->validID);
     if (ret ==nullptr || ret->getEntityType() != EntityType::ENTITY_HUMAN ) return;
     
     EntityHuman* player = (EntityHuman*)ret;
     
     player->setMoving(broadcastPacket->moving);
     player->setTargetHeading(broadcastPacket->heading);
     
     delete broadcastPacket;
 }
开发者ID:Thomas2070,项目名称:THE_DEAD_FOREST,代码行数:14,代码来源:PacketProcess.cpp

示例6: ssassert

Expr *ConstraintBase::Distance(hEntity wrkpl, hEntity hpa, hEntity hpb) {
    EntityBase *pa = SK.GetEntity(hpa);
    EntityBase *pb = SK.GetEntity(hpb);
    ssassert(pa->IsPoint() && pb->IsPoint(),
             "Expected two points to measure projected distance between");

    if(wrkpl.v == EntityBase::FREE_IN_3D.v) {
        // This is true distance
        ExprVector ea, eb, eab;
        ea = pa->PointGetExprs();
        eb = pb->PointGetExprs();
        eab = ea.Minus(eb);

        return eab.Magnitude();
    } else {
        // This is projected distance, in the given workplane.
        Expr *au, *av, *bu, *bv;

        pa->PointGetExprsInWorkplane(wrkpl, &au, &av);
        pb->PointGetExprsInWorkplane(wrkpl, &bu, &bv);

        Expr *du = au->Minus(bu);
        Expr *dv = av->Minus(bv);

        return ((du->Square())->Plus(dv->Square()))->Sqrt();
    }
}
开发者ID:blondegeek,项目名称:solvespace-1,代码行数:27,代码来源:constrainteq.cpp

示例7: Update

void GameStateGame::Update(const sf::Time& time)
{
    SharedContext* context = m_stateMgr->GetContext();
    EntityBase   * player  = context->entityManager->Find("Player");
    if (!player)
    {
        std::cout << "Respawning player..." << std::endl;
        context->entityManager->Add(EntityType::Player, "Player");
        player = context->entityManager->Find("Player");
        player->SetPosition(m_gameMap->GetPlayerStart());
        std::cout << "Player respawned..." << std::endl;
    }
    else
    {
        m_view.setCenter(player->GetPosition());
        context->window->GetRenderWindow()->setView(m_view);
    }

    sf::FloatRect viewSpace = context->window->GetViewSpace();

    if (viewSpace.left <= 0)
    {
        m_view.setCenter(viewSpace.width / 2.0f, m_view.getCenter().y);
        context->window->GetRenderWindow()->setView(m_view);
    }
    else if (viewSpace.left + viewSpace.width > (m_gameMap->GetMapSize().x) * TILE_SIZE)
    {
        m_view.setCenter(((m_gameMap->GetMapSize().x) * TILE_SIZE) - (viewSpace.width / 2.0f),
                         m_view.getCenter().y);
        context->window->GetRenderWindow()->setView(m_view);
    }

    if (viewSpace.top <= 0)
    {
        m_view.setCenter(m_view.getCenter().x, viewSpace.height / 2.0f);
        context->window->GetRenderWindow()->setView(m_view);
    }
    else if (viewSpace.top + viewSpace.height >
             (m_gameMap->GetMapSize().y) * TILE_SIZE)
    {
        m_view.setCenter(m_view.getCenter().x,
                         ((m_gameMap->GetMapSize().y) *
                          TILE_SIZE) - (viewSpace.height / 2.0f));
        context->window->GetRenderWindow()->setView(m_view);
    }

    m_gameMap->Update(time.asSeconds());
    m_stateMgr->GetContext()->entityManager->Update(time.asSeconds());
}
开发者ID:notrallon,项目名称:Gutland-Liberatus,代码行数:49,代码来源:GameStateGame.cpp

示例8: switch

ExprVector EntityBase::PointGetExprs(void) {
    ExprVector r;
    switch(type) {
        case POINT_IN_3D:
            r = ExprVector::From(param[0], param[1], param[2]);
            break;

        case POINT_IN_2D: {
            EntityBase *c = SK.GetEntity(workplane);
            ExprVector u = c->Normal()->NormalExprsU();
            ExprVector v = c->Normal()->NormalExprsV();
            r = c->WorkplaneGetOffsetExprs();
            r = r.Plus(u.ScaledBy(Expr::From(param[0])));
            r = r.Plus(v.ScaledBy(Expr::From(param[1])));
            break;
        }
        case POINT_N_TRANS: {
            ExprVector orig = ExprVector::From(numPoint);
            ExprVector trans = ExprVector::From(param[0], param[1], param[2]);
            r = orig.Plus(trans.ScaledBy(Expr::From(timesApplied)));
            break;
        }
        case POINT_N_ROT_TRANS: {
            ExprVector orig = ExprVector::From(numPoint);
            ExprVector trans = ExprVector::From(param[0], param[1], param[2]);
            ExprQuaternion q =
                ExprQuaternion::From(param[3], param[4], param[5], param[6]);
            orig = q.Rotate(orig);
            r = orig.Plus(trans);
            break;
        }
        case POINT_N_ROT_AA: {
            ExprVector orig = ExprVector::From(numPoint);
            ExprVector trans = ExprVector::From(param[0], param[1], param[2]);
            ExprQuaternion q = GetAxisAngleQuaternionExprs(3);
            orig = orig.Minus(trans);
            orig = q.Rotate(orig);
            r = orig.Plus(trans);
            break;
        }
        case POINT_N_COPY:
            r = ExprVector::From(numPoint);
            break;

        default: oops();
    }
    return r;
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:48,代码来源:entity.cpp

示例9: SnapToGrid

Vector GraphicsWindow::SnapToGrid(Vector p) {
    if(!LockedInWorkplane()) return p;

    EntityBase *wrkpl = SK.GetEntity(ActiveWorkplane()),
               *norm  = wrkpl->Normal();
    Vector wo = SK.GetEntity(wrkpl->point[0])->PointGetNum(),
           wu = norm->NormalU(),
           wv = norm->NormalV(),
           wn = norm->NormalN();

    Vector pp = (p.Minus(wo)).DotInToCsys(wu, wv, wn);
    pp.x = floor((pp.x / SS.gridSpacing) + 0.5)*SS.gridSpacing;
    pp.y = floor((pp.y / SS.gridSpacing) + 0.5)*SS.gridSpacing;
    pp.z = 0;

    return pp.ScaleOutOfCsys(wu, wv, wn).Plus(wo);
}
开发者ID:jariou,项目名称:solvespace,代码行数:17,代码来源:graphicswin.cpp

示例10: S_BROADCAST_JOYSTICK_DOUBLE_MOVE_KEYDOWN

 void PacketProcess::S_BROADCAST_JOYSTICK_DOUBLE_MOVE_KEYDOWN(Packet* rowPacket)
 {
     PK_S_BROADCAST_JOYSTICK_DOUBLE_MOVE_KEYDOWN* broadcastPacket = (PK_S_BROADCAST_JOYSTICK_DOUBLE_MOVE_KEYDOWN*)rowPacket;
     
     EntityBase* ret = _gameMgr->getEntityFromID((int)broadcastPacket->validID);
     if (ret ==nullptr || ret->getEntityType() != EntityType::ENTITY_HUMAN ) return;
     
     
     EntityHuman* player = (EntityHuman*)ret;
     
     player->setMoving(broadcastPacket->moving);
     player->setTargetHeading(broadcastPacket->moving);
     
     player->setInputMask(JoystickMessageTypes::RUN);
     
     delete broadcastPacket;
 }
开发者ID:Thomas2070,项目名称:THE_DEAD_FOREST,代码行数:17,代码来源:PacketProcess.cpp

示例11: return

//-----------------------------------------------------------------------------
// Return the cosine of the angle between two vectors. If a workplane is
// specified, then it's the cosine of their projections into that workplane.
//-----------------------------------------------------------------------------
Expr *ConstraintBase::DirectionCosine(hEntity wrkpl,
                                      ExprVector ae, ExprVector be)
{
    if(wrkpl.v == EntityBase::FREE_IN_3D.v) {
        Expr *mags = (ae.Magnitude())->Times(be.Magnitude());
        return (ae.Dot(be))->Div(mags);
    } else {
        EntityBase *w = SK.GetEntity(wrkpl);
        ExprVector u = w->Normal()->NormalExprsU();
        ExprVector v = w->Normal()->NormalExprsV();
        Expr *ua = u.Dot(ae);
        Expr *va = v.Dot(ae);
        Expr *ub = u.Dot(be);
        Expr *vb = v.Dot(be);
        Expr *maga = (ua->Square()->Plus(va->Square()))->Sqrt();
        Expr *magb = (ub->Square()->Plus(vb->Square()))->Sqrt();
        Expr *dot = (ua->Times(ub))->Plus(va->Times(vb));
        return dot->Div(maga->Times(magb));
    }
}
开发者ID:blondegeek,项目名称:solvespace-1,代码行数:24,代码来源:constrainteq.cpp

示例12: PointGetExprsInWorkplane

void EntityBase::PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v) {
    if(type == POINT_IN_2D && workplane.v == wrkpl.v) {
        // They want our coordinates in the form that we've written them,
        // very nice.
        *u = Expr::From(param[0]);
        *v = Expr::From(param[1]);
    } else {
        // Get the offset and basis vectors for this weird exotic csys.
        EntityBase *w = SK.GetEntity(wrkpl);
        ExprVector wp = w->WorkplaneGetOffsetExprs();
        ExprVector wu = w->Normal()->NormalExprsU();
        ExprVector wv = w->Normal()->NormalExprsV();

        // Get our coordinates in three-space, and project them into that
        // coordinate system.
        ExprVector ev = PointGetExprs();
        ev = ev.Minus(wp);
        *u = ev.Dot(wu);
        *v = ev.Dot(wv);
    }
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:21,代码来源:entity.cpp

示例13: ZERO


//.........这里部分代码省略.........
                c.entityA = l0->h;
                c.type = SYMMETRIC_LINE;
            } else if(SS.GW.LockedInWorkplane()
                        && gs.lineSegments == 1 && gs.points == 2 && gs.n == 3)
            {
                c.ptA = gs.point[0];
                c.ptB = gs.point[1];
                c.entityA = gs.entity[0];
                c.type = SYMMETRIC_LINE;
            } else {
                Error("Bad selection for symmetric constraint. This constraint "
                      "can apply to:\n\n"
                      "    * two points or a line segment "
                          "(symmetric about workplane's coordinate axis)\n"
                      "    * line segment, and two points or a line segment "
                          "(symmetric about line segment)\n"
                      "    * workplane, and two points or a line segment "
                          "(symmetric about workplane)\n");
                return;
            }
            if(c.type != 0) {
                // Already done, symmetry about a line segment in a workplane
            } else if(c.entityA.v == Entity::NO_ENTITY.v) {
                // Horizontal / vertical symmetry, implicit symmetry plane
                // normal to the workplane
                if(c.workplane.v == Entity::FREE_IN_3D.v) {
                    Error("Must be locked in to workplane when constraining "
                          "symmetric without an explicit symmetry plane.");
                    return;
                }
                Vector pa = SK.GetEntity(c.ptA)->PointGetNum();
                Vector pb = SK.GetEntity(c.ptB)->PointGetNum();
                Vector dp = pa.Minus(pb);
                EntityBase *norm = SK.GetEntity(c.workplane)->Normal();;
                Vector u = norm->NormalU(), v = norm->NormalV();
                if(fabs(dp.Dot(u)) > fabs(dp.Dot(v))) {
                    c.type = SYMMETRIC_HORIZ;
                } else {
                    c.type = SYMMETRIC_VERT;
                }
                if(gs.lineSegments == 1) {
                    // If this line segment is already constrained horiz or
                    // vert, then auto-remove that redundant constraint.
                    DeleteAllConstraintsFor(HORIZONTAL, (gs.entity[0]),
                        Entity::NO_ENTITY);
                    DeleteAllConstraintsFor(VERTICAL, (gs.entity[0]),
                        Entity::NO_ENTITY);

                }
            } else {
                // Symmetry with a symmetry plane specified explicitly.
                c.type = SYMMETRIC;
            }
            AddConstraint(&c);
            break;

        case GraphicsWindow::MNU_VERTICAL:
        case GraphicsWindow::MNU_HORIZONTAL: {
            hEntity ha, hb;
            if(c.workplane.v == Entity::FREE_IN_3D.v) {
                Error("Select workplane before constraining horiz/vert.");
                return;
            }
            if(gs.lineSegments == 1 && gs.n == 1) {
                c.entityA = gs.entity[0];
                Entity *e = SK.GetEntity(c.entityA);
开发者ID:astarasikov,项目名称:solvespace,代码行数:67,代码来源:constraint.cpp

示例14: switch

void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) const {
    Expr *exA = Expr::From(valA);

    switch(type) {
        case Type::PT_PT_DISTANCE:
            AddEq(l, Distance(workplane, ptA, ptB)->Minus(exA), 0);
            return;

        case Type::PROJ_PT_DISTANCE: {
            ExprVector pA = SK.GetEntity(ptA)->PointGetExprs(),
                       pB = SK.GetEntity(ptB)->PointGetExprs(),
                       dp = pB.Minus(pA);

            ExprVector pp = SK.GetEntity(entityA)->VectorGetExprs();
            pp = pp.WithMagnitude(Expr::From(1.0));

            AddEq(l, (dp.Dot(pp))->Minus(exA), 0);
            return;
        }

        case Type::PT_LINE_DISTANCE:
            AddEq(l,
                PointLineDistance(workplane, ptA, entityA)->Minus(exA), 0);
            return;

        case Type::PT_PLANE_DISTANCE: {
            ExprVector pt = SK.GetEntity(ptA)->PointGetExprs();
            AddEq(l, (PointPlaneDistance(pt, entityA))->Minus(exA), 0);
            return;
        }

        case Type::PT_FACE_DISTANCE: {
            ExprVector pt = SK.GetEntity(ptA)->PointGetExprs();
            EntityBase *f = SK.GetEntity(entityA);
            ExprVector p0 = f->FaceGetPointExprs();
            ExprVector n = f->FaceGetNormalExprs();
            AddEq(l, (pt.Minus(p0)).Dot(n)->Minus(exA), 0);
            return;
        }

        case Type::EQUAL_LENGTH_LINES: {
            EntityBase *a = SK.GetEntity(entityA);
            EntityBase *b = SK.GetEntity(entityB);
            AddEq(l, Distance(workplane, a->point[0], a->point[1])->Minus(
                     Distance(workplane, b->point[0], b->point[1])), 0);
            return;
        }

        // These work on distance squared, since the pt-line distances are
        // signed, and we want the absolute value.
        case Type::EQ_LEN_PT_LINE_D: {
            EntityBase *forLen = SK.GetEntity(entityA);
            Expr *d1 = Distance(workplane, forLen->point[0], forLen->point[1]);
            Expr *d2 = PointLineDistance(workplane, ptA, entityB);
            AddEq(l, (d1->Square())->Minus(d2->Square()), 0);
            return;
        }
        case Type::EQ_PT_LN_DISTANCES: {
            Expr *d1 = PointLineDistance(workplane, ptA, entityA);
            Expr *d2 = PointLineDistance(workplane, ptB, entityB);
            AddEq(l, (d1->Square())->Minus(d2->Square()), 0);
            return;
        }

        case Type::LENGTH_RATIO: {
            EntityBase *a = SK.GetEntity(entityA);
            EntityBase *b = SK.GetEntity(entityB);
            Expr *la = Distance(workplane, a->point[0], a->point[1]);
            Expr *lb = Distance(workplane, b->point[0], b->point[1]);
            AddEq(l, (la->Div(lb))->Minus(exA), 0);
            return;
        }

        case Type::LENGTH_DIFFERENCE: {
            EntityBase *a = SK.GetEntity(entityA);
            EntityBase *b = SK.GetEntity(entityB);
            Expr *la = Distance(workplane, a->point[0], a->point[1]);
            Expr *lb = Distance(workplane, b->point[0], b->point[1]);
            AddEq(l, (la->Minus(lb))->Minus(exA), 0);
            return;
        }

        case Type::DIAMETER: {
            EntityBase *circle = SK.GetEntity(entityA);
            Expr *r = circle->CircleGetRadiusExpr();
            AddEq(l, (r->Times(Expr::From(2)))->Minus(exA), 0);
            return;
        }

        case Type::EQUAL_RADIUS: {
            EntityBase *c1 = SK.GetEntity(entityA);
            EntityBase *c2 = SK.GetEntity(entityB);
            AddEq(l, (c1->CircleGetRadiusExpr())->Minus(
                      c2->CircleGetRadiusExpr()), 0);
            return;
        }

        case Type::EQUAL_LINE_ARC_LEN: {
            EntityBase *line = SK.GetEntity(entityA),
                       *arc  = SK.GetEntity(entityB);
//.........这里部分代码省略.........
开发者ID:blondegeek,项目名称:solvespace-1,代码行数:101,代码来源:constrainteq.cpp

示例15: createEntity

entid_t EntityMgr::createEntity(const char * type, entid_t idParent, Object * param) {

    if (NULL==type) throw Exception("core: Invalid entity type [NULL]");
    if (-1!=idParent) checkId(idParent);
    // Get component
    ComponentMgr * comgr = SingleComponentMgr::getInstance();
    IComponent * c = comgr->getComponentForType(type);
    // Try to create entity
    EntityBase * e = NULL;
    try {
        // Find creator
        const EntityTypeInfo * t = c->getTypeInfo();
        for (; t && t->typeName; ++t) {
            if (stricmp(t->typeName, type)==0) {
                if (t->creator==NULL) break;
                e = t->creator();
                break;
            }
        }
        if (NULL==e) throw Exception("core: Unable to find entity creator");
    }
    catch(const Exception& e) {
        SingleCore::getInstance()->logMessage("core: Exception while creating entity '%s' -->>\n%s", type, (const char*)e);
        throw;
    }
    catch(...) {
        SingleCore::getInstance()->logMessage("core: Unknown exception while creating entity '%s'", type);
        throw;
    }
    if (e==NULL) throw Exception("core: Error creating entity %s", type);
    // Find type chunk if the one exists; if not, create it
    typeid_t typeId = -1;
    MapTypeId::const_iterator it=mapTypeId.find(type);
    if (it==mapTypeId.end()) {
        typeId = createChunkType(c, type);
        mapTypeId[type]=typeId;
    }
    else typeId = it->second;
    // Add entity information
    entid_t id = createChunkEntity(e, typeId);
    chunkType[typeId].instances.push_back(id);
    if (-1!=idParent) {
        EntityChunk& ecParent=chunkEntity[idParent];
        ecParent.children.back()=id;
        ecParent.children.push_back(-1);
        const_cast<const entid_t*&>(ecParent.entity->childId) = &ecParent.children[0];
    }
    EntityChunk& ec = chunkEntity[id];
    const_cast<entid_t&>(e->entityId) = id;
    const_cast<entid_t&>(e->parentId) = idParent;
    const_cast<const entid_t*&>(e->childId) = &ec.children[0];
    const_cast<ICore*&>(e->icore) = SingleCore::getInstance();
    // Try to init entity
    bool init=false;
    try {
        e->entityInit(param);
        init=true;
    }
    catch(const Exception& e) {
        SingleCore::getInstance()->logMessage("core: Exception in %s::entityInit() -->>\n%s", type, (const char*)e);
        destroyEntity(id);
        throw;
    }
    catch(...) {
        SingleCore::getInstance()->logMessage("core: Unknown exception in %s::entityInit()", type);
        destroyEntity(id);
        throw;
    }
    // Notify subscribers that entity has been created
    TrigEntityLife::Param trigParam;
    trigParam.eid = id;
    trigParam.lifeTime = entityCreated;
    trigParam.param = param;
    trigParam.entityType = chunkType[chunkEntity[id].typeId].name;
    getCore()->activate(TrigEntityLife::tid,&trigParam);
    return id;
}
开发者ID:Jan123457,项目名称:d3basejumper,代码行数:77,代码来源:EntityMgr.cpp


注:本文中的EntityBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。