示例#1
0
void AvatarManager::updateOtherAvatars(float deltaTime) {
    bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
    PerformanceWarning warn(showWarnings, "Application::updateAvatars()");

    Application* applicationInstance = Application::getInstance();
    glm::vec3 mouseOrigin = applicationInstance->getMouseRayOrigin();
    glm::vec3 mouseDirection = applicationInstance->getMouseRayDirection();

    // simulate avatars
    AvatarHash::iterator avatarIterator = _avatarHash.begin();
    while (avatarIterator != _avatarHash.end()) {
        Avatar* avatar = static_cast<Avatar*>(avatarIterator.value().data());
        if (avatar == static_cast<Avatar*>(_myAvatar.data())) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            //updateMyAvatar(deltaTime);
            ++avatarIterator;
            continue;
        }
        if (avatar->getOwningAvatarMixer()) {
            // this avatar's mixer is still around, go ahead and simulate it
            avatar->simulate(deltaTime);
            avatar->setMouseRay(mouseOrigin, mouseDirection);
            ++avatarIterator;
        } else {
            // the mixer that owned this avatar is gone, give it to the vector of fades and kill it
            avatarIterator = erase(avatarIterator);
        }
    }
    
    // simulate avatar fades
    simulateAvatarFades(deltaTime);
}
示例#2
0
void AvatarManager::updateOtherAvatars(float deltaTime) {
    if (_avatarHash.size() < 2 && _avatarFades.isEmpty()) {
        return;
    }
    bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
    PerformanceWarning warn(showWarnings, "Application::updateAvatars()");

    PerformanceTimer perfTimer("otherAvatars");
    
    // simulate avatars
    AvatarHash::iterator avatarIterator = _avatarHash.begin();
    while (avatarIterator != _avatarHash.end()) {
        AvatarSharedPointer sharedAvatar = avatarIterator.value();
        Avatar* avatar = reinterpret_cast<Avatar*>(sharedAvatar.data());
        
        if (sharedAvatar == _myAvatar || !avatar->isInitialized()) {
            // DO NOT update _myAvatar!  Its update has already been done earlier in the main loop.
            // DO NOT update uninitialized Avatars
            ++avatarIterator;
            continue;
        }
        if (!shouldKillAvatar(sharedAvatar)) {
            // this avatar's mixer is still around, go ahead and simulate it
            avatar->simulate(deltaTime);
            ++avatarIterator;
        } else {
            // the mixer that owned this avatar is gone, give it to the vector of fades and kill it
            avatarIterator = erase(avatarIterator);
        }
    }
    
    // simulate avatar fades
    simulateAvatarFades(deltaTime);
}
示例#3
0
void FaceModel::simulate(float deltaTime) {
    if (!isActive()) {
        return;
    }
    Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
    glm::vec3 neckPosition;
    glm::vec3 modelTranslation;
    if (!owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) {
        neckPosition = owningAvatar->getSkeleton().joint[AVATAR_JOINT_NECK_BASE].position;
        const glm::vec3 OLD_SKELETON_MODEL_TRANSLATION(0.0f, -60.0f, 40.0f);
        modelTranslation = OLD_SKELETON_MODEL_TRANSLATION;
    }
    setTranslation(neckPosition);
    glm::quat neckRotation;
    if (!owningAvatar->getSkeletonModel().getNeckRotation(neckRotation)) {
        neckRotation = owningAvatar->getSkeleton().joint[AVATAR_JOINT_NECK_BASE].absoluteRotation *
            glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
    }
    setRotation(neckRotation);
    const float MODEL_SCALE = 0.0006f;
    setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale() * MODEL_SCALE);
    setOffset(modelTranslation - _geometry->getFBXGeometry().neckPivot);
    
    setPupilDilation(_owningHead->getPupilDilation());
    setBlendshapeCoefficients(_owningHead->getBlendshapeCoefficients());
    
    Model::simulate(deltaTime);
}
static duk_ret_t Avatar_SetName_String(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    String name = duk_require_string(ctx, 0);
    thisObj->SetName(name);
    return 0;
}
static duk_ret_t Avatar_SetTemporary_bool(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool enable = duk_require_boolean(ctx, 0);
    thisObj->SetTemporary(enable);
    return 0;
}
static duk_ret_t Avatar_Id(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    component_id_t ret = thisObj->Id();
    duk_push_number(ctx, ret);
    return 1;
}
static duk_ret_t Avatar_SetUpdateMode_AttributeChange__Type(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    AttributeChange::Type defaultmode = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->SetUpdateMode(defaultmode);
    return 0;
}
static duk_ret_t Avatar_UpdateMode(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    AttributeChange::Type ret = thisObj->UpdateMode();
    duk_push_number(ctx, ret);
    return 1;
}
static duk_ret_t Avatar_NumStaticAttributes(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    int ret = thisObj->NumStaticAttributes();
    duk_push_number(ctx, ret);
    return 1;
}
示例#10
0
static duk_ret_t Avatar_IsUnacked(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool ret = thisObj->IsUnacked();
    duk_push_boolean(ctx, ret);
    return 1;
}
示例#11
0
static duk_ret_t Avatar_SetParentEntity_Entity(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    Entity* entity = GetWeakObject<Entity>(ctx, 0);
    thisObj->SetParentEntity(entity);
    return 0;
}
示例#12
0
void FaceModel::simulate(float deltaTime, bool fullUpdate) {
    updateGeometry();

    Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
    glm::vec3 neckPosition;
    if (!owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) {
        neckPosition = owningAvatar->getPosition();
    }
    setTranslation(neckPosition);
    glm::quat neckParentRotation;
    if (!owningAvatar->getSkeletonModel().getNeckParentRotationFromDefaultOrientation(neckParentRotation)) {
        neckParentRotation = owningAvatar->getOrientation();
    }
    setRotation(neckParentRotation);
    setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale());

    setPupilDilation(_owningHead->getPupilDilation());
    setBlendshapeCoefficients(_owningHead->getBlendshapeCoefficients());

    // FIXME - this is very expensive, we shouldn't do it if we don't have to
    //invalidCalculatedMeshBoxes();

    if (isActive()) {
        setOffset(-_geometry->getFBXGeometry().neckPivot);
        Model::simulateInternal(deltaTime);
    }
}
示例#13
0
static duk_ret_t Avatar_Name(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    const String & ret = thisObj->Name();
    duk_push_string(ctx, ret.CString());
    return 1;
}
示例#14
0
static duk_ret_t Avatar_ComponentChanged_AttributeChange__Type(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    AttributeChange::Type change = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->ComponentChanged(change);
    return 0;
}
示例#15
0
static duk_ret_t Avatar_AvatarDesc(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    AvatarDescAssetPtr ret = thisObj->AvatarDesc();
    PushWeakObject(ctx, ret.Get());
    return 1;
}
示例#16
0
static duk_ret_t Avatar_TypeId(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    u32 ret = thisObj->TypeId();
    duk_push_number(ctx, ret);
    return 1;
}
示例#17
0
static duk_ret_t Avatar_ParentEntity(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    Entity * ret = thisObj->ParentEntity();
    PushWeakObject(ctx, ret);
    return 1;
}
示例#18
0
文件: Head.cpp 项目: Chris7/hifi
void Head::applyCollision(CollisionInfo& collision) {
    // HACK: the collision proxies for the FaceModel are bad.  As a temporary workaround
    // we collide against a hard coded collision proxy.
    // TODO: get a better collision proxy here.
    const float HEAD_RADIUS = 0.15f;
    const glm::vec3 HEAD_CENTER = _position;

    // collide the contactPoint against the collision proxy to obtain a new penetration
    // NOTE: that penetration is in opposite direction (points the way out for the point, not the sphere)
    glm::vec3 penetration;
    if (findPointSpherePenetration(collision._contactPoint, HEAD_CENTER, HEAD_RADIUS, penetration)) {
        // compute lean angles
        Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
        glm::quat bodyRotation = owningAvatar->getOrientation();
        glm::vec3 neckPosition;
        if (owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) {
            glm::vec3 xAxis = bodyRotation * glm::vec3(1.f, 0.f, 0.f);
            glm::vec3 zAxis = bodyRotation * glm::vec3(0.f, 0.f, 1.f);
            float neckLength = glm::length(_position - neckPosition);
            if (neckLength > 0.f) {
                float forward = glm::dot(collision._penetration, zAxis) / neckLength;
                float sideways = - glm::dot(collision._penetration, xAxis) / neckLength;
                addLean(sideways, forward);
            }
        }
    } 
}
示例#19
0
static duk_ret_t Avatar_SupportsDynamicAttributes(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool ret = thisObj->SupportsDynamicAttributes();
    duk_push_boolean(ctx, ret);
    return 1;
}
示例#20
0
static duk_ret_t Avatar_AvatarProperty_String(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    String name = duk_require_string(ctx, 0);
    String ret = thisObj->AvatarProperty(name);
    duk_push_string(ctx, ret.CString());
    return 1;
}
示例#21
0
static duk_ret_t Avatar_GetAttribute_String(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    String id = duk_require_string(ctx, 0);
    Variant ret = thisObj->GetAttribute(id);
    PushVariant(ctx, ret);
    return 1;
}
示例#22
0
void LayerBaCayAvatar::setVisibleLayerInvite(int pos, bool isShow)
{
	Avatar *user = this->getUserByPos(pos);
	if (user != NULL)
	{
		user->setVisibleLayerInvite(isShow);
	}
}
示例#23
0
static duk_ret_t Avatar_EmitAttributeChanged_String_AttributeChange__Type(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    String attributeName = duk_require_string(ctx, 0);
    AttributeChange::Type change = (AttributeChange::Type)(int)duk_require_number(ctx, 1);
    thisObj->EmitAttributeChanged(attributeName, change);
    return 0;
}
示例#24
0
static duk_ret_t Avatar_ShouldBeSerialized_bool_bool(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool serializeTemporary = duk_require_boolean(ctx, 0);
    bool serializeLocal = duk_require_boolean(ctx, 1);
    bool ret = thisObj->ShouldBeSerialized(serializeTemporary, serializeLocal);
    duk_push_boolean(ctx, ret);
    return 1;
}
示例#25
0
static duk_ret_t Avatar_SetAttribute_String_Variant_AttributeChange__Type(duk_context* ctx)
{
    int numArgs = duk_get_top(ctx);
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    String id = duk_require_string(ctx, 0);
    Variant value = GetVariant(ctx, 1);
    AttributeChange::Type change = numArgs > 2 ? (AttributeChange::Type)(int)duk_require_number(ctx, 2) : AttributeChange::Default;
    thisObj->SetAttribute(id, value, change);
    return 0;
}
void Pattern1Square::setAvatars(PersonStats *ps, bool isEnter) {
  //  co ut << "Pattern1Square::setAvatars with grp " << PeopleStats::curAvatarGroup << endl;
//	Avatar *a = new AV1Square(ps, ps->inpterps);
	Avatar *a = AvatarCreatorHash::theACHash->create("1Square", ps, ps->inpterps);
  //UNDONE CHANGE TO VARS
  a->setPillarMode(pilDir);
//  a->setTrailDelay(tailDelay);
  
  ps->addAvatar(a, PeopleStats::curAvatarGroup);
}
示例#27
0
文件: talkable.cpp 项目: leewood/kadu
Avatar Talkable::avatar() const
{
	Avatar avatar;
	if (Talkable::ItemBuddy == Type)
		avatar = toBuddy().buddyAvatar();

	if (!avatar || avatar.pixmap().isNull())
		avatar = toContact().avatar(true);

	return avatar;
}
示例#28
0
/*
* Copy constructor for the Avatar class
*/
Avatar::Avatar(const Avatar &a) :
Actor(),
_name(a.GetName()),
_level(a.GetLevel()),
_health(a.GetHealth()),
_class(a.GetClass()),
_sprite_image(a._sprite_image)
{
	_sprite_texture.loadFromImage(_sprite_image);
	_sprite = sf::Sprite(_sprite_texture);
}
示例#29
0
void PatternA::setAvatars(PersonStats *ps, bool isEnter) {
    Avatar *a = new AVHuge(ps, ps->inpterps);

    //UNDONE CHANGE TO VARS
    a->setPillarMode(1);
//  a->setTrailDelay(tailDelay);

    ps->addAvatar(a, PeopleStats::curAvatarGroup);

//  co ut << "PatternA::setAvatars with grp " << PeopleStats::curAvatarGroup << endl;
//  ps->addAvatar(new AVHuge(ps, ps->inpterps), PeopleStats::curAvatarGroup);
}
示例#30
0
glm::quat Head::getCameraOrientation() const {
    // NOTE: Head::getCameraOrientation() is not used for orienting the camera "view" while in Oculus mode, so
    // you may wonder why this code is here. This method will be called while in Oculus mode to determine how
    // to change the driving direction while in Oculus mode. It is used to support driving toward where you're 
    // head is looking. Note that in oculus mode, your actual camera view and where your head is looking is not
    // always the same.
    if (qApp->isHMDMode()) {
        return getOrientation();
    }
    Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
    return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.0f, 0.0f)));
}