void GfxBody::setAllBonesManuallyControlled (bool v)
{
    if (dead) THROW_DEAD(className);
    for (unsigned i=0 ; i<manualBones.size() ; ++i) {
        manualBones[i] = v;
    }
    updateBones();
}
Exemple #2
0
void AudioBody::setVelocity (const Vector3& v)
{
    if (destroyed) THROW_DEAD(className);
    if (ambient) return;
    velocity = v;
    alSource3f(alSourceLeft, AL_VELOCITY, v.x, v.y, v.z);
    alSource3f(alSourceRight, AL_VELOCITY, v.x, v.y, v.z);
}
Exemple #3
0
void AudioBody::destroy (void)
{
    if (destroyed) THROW_DEAD(className);
    destroyed = true;
    resource->unregisterReloadWatcher(this);
    alDeleteSources(1, &alSourceLeft);
    alDeleteSources(1, &alSourceRight);
    resource = nullptr;
}
void GfxBody::checkBone (unsigned n) const
{
    if (dead) THROW_DEAD(className);
    if (manualBones.size()==0) GRIT_EXCEPT("GfxBody has no skeleton");
    if (n >= manualBones.size()) {
        std::stringstream ss;
        ss << "Bone " << n << " out of range [0," << manualBones.size() << ")";
        GRIT_EXCEPT(ss.str());
    }
}
void GfxBody::setFirstPerson (bool v)
{
    if (dead) THROW_DEAD(className);
    if (firstPerson == v) return;
    firstPerson = v;
    if (firstPerson) {
        first_person_bodies.insert(this);
    } else {
        first_person_bodies.erase(this);
    }
}
Exemple #6
0
void AudioBody::updatePositions (void)
{
    if (destroyed) THROW_DEAD(className);
    if (ambient) return;
    // put them on top of each other if not stereo
    float off = resource->getStereo() ? separation/2 : 0;

    Vector3 v_l = position + orientation * Vector3(-off,0,0);
    Vector3 v_r = position + orientation * Vector3( off,0,0);
    alSource3f(alSourceLeft, AL_POSITION, v_l.x, v_l.y, v_l.z);
    alSource3f(alSourceRight, AL_POSITION, v_r.x, v_r.y, v_r.z);
}
std::vector<std::string> GfxBody::getAnimationNames (void)
{
    std::vector<std::string> r;

    if (dead) THROW_DEAD(className);

    if (skeleton == NULL) GRIT_EXCEPT("GfxBody has no skeleton");
    
    Ogre::AnimationStateIterator it = animationState.getAnimationStateIterator();

    while (it.hasMoreElements()) r.push_back(it.getNext()->getAnimationName());

    return r;
}
void GfxLight::update (const Vector3 &cam_pos)
{
    if (dead) THROW_DEAD(className);
    light->setPosition(to_ogre(getWorldTransform().pos));
    light->setDirection(to_ogre(getWorldTransform().removeTranslation()*Vector3(0,1,0)));
    corona->pos = getWorldTransform() * coronaLocalPos;
    Vector3 col = enabled ? fade * coronaColour : Vector3(0,0,0);
    corona->dimensions = Vector3(coronaSize, coronaSize, coronaSize);

    Vector3 light_dir_ws = (cam_pos - getWorldTransform().pos).normalisedCopy();
    Vector3 light_aim_ws_ = getWorldTransform().removeTranslation() * Vector3(0,1,0);

    float angle = light_aim_ws_.dot(light_dir_ws);
    float inner = gritcos(coronaInnerAngle);
    float outer = gritcos(coronaOuterAngle);
    if (outer != inner) {
            float occlusion = std::min(std::max((angle-inner)/(outer-inner), 0.0f), 1.0f);
            col *= (1-occlusion);
    }
    corona->diffuse = Vector3(0, 0, 0);
    corona->emissive = col;
}
Exemple #9
0
void AudioBody::reinitialise (void)
{
    if (destroyed) THROW_DEAD(className);
    alSourcei(alSourceLeft, AL_BUFFER, AL_NONE);
    alSourcei(alSourceRight, AL_BUFFER, AL_NONE);

    if (!resource->isLoaded()) {
        CERR << "Cannot create an AudioBody for an unloaded audio resource: "
             << resource->getName() << std::endl;
        return;
    }

    if (ambient) {
        // will be mono or stereo, whatever the wav file was
        alSourcei(alSourceLeft, AL_BUFFER, resource->getALBufferAll());
    } else {
        // get the two channels separate for two separate sources
        alSourcei(alSourceLeft, AL_BUFFER, resource->getALBufferLeft());
        if (resource->getStereo()) {
            alSourcei(alSourceRight, AL_BUFFER, resource->getALBufferLeft());
        }
    }
}
Exemple #10
0
Degree GfxLight::getCoronaOuterAngle (void)
{
    if (dead) THROW_DEAD(className);
    return coronaOuterAngle;
}
Exemple #11
0
void GfxLight::setOuterAngle (Degree v)
{
    if (dead) THROW_DEAD(className);
    light->setSpotlightOuterAngle(to_ogre(v));
}
Exemple #12
0
Degree GfxLight::getOuterAngle (void)
{
    if (dead) THROW_DEAD(className);
    return from_ogre(light->getSpotlightOuterAngle());
}
Exemple #13
0
void GfxLight::setRange (float v)
{
    if (dead) THROW_DEAD(className);
    light->setAttenuation(v, 0, 0, 0);
}
Exemple #14
0
float GfxLight::getCoronaSize (void)
{
    if (dead) THROW_DEAD(className);
    return coronaSize;
}
Exemple #15
0
void GfxLight::setFade (float f)
{
    if (dead) THROW_DEAD(className);
    fade = f;
    updateVisibility();
}
Exemple #16
0
void GfxLight::setEnabled (bool v)
{
    if (dead) THROW_DEAD(className);
    enabled = v;
    updateVisibility();
}
Exemple #17
0
Vector3 GfxLight::getSpecularColour (void)
{
    if (dead) THROW_DEAD(className);
    return specular;
}
Exemple #18
0
Vector3 GfxLight::getCoronaColour (void)
{
    if (dead) THROW_DEAD(className);
    return coronaColour;
}
Exemple #19
0
void GfxLight::setCoronaColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    coronaColour = v;
}
Exemple #20
0
void GfxLight::setCoronaLocalPosition (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    coronaLocalPos = v;
}
Exemple #21
0
Vector3 GfxLight::getCoronaLocalPosition (void)
{
    if (dead) THROW_DEAD(className);
    return coronaLocalPos;
}
Exemple #22
0
void GfxLight::setCoronaSize (float v)
{
    if (dead) THROW_DEAD(className);
    coronaSize = v;
}
Exemple #23
0
void GfxLight::setCoronaOuterAngle (Degree v)
{
    if (dead) THROW_DEAD(className);
    coronaOuterAngle = v;
}
Exemple #24
0
void GfxLight::setDiffuseColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    diffuse = v;
    updateVisibility();
}
Exemple #25
0
bool GfxLight::isEnabled (void)
{
    if (dead) THROW_DEAD(className);
    return enabled;
}
Exemple #26
0
void GfxLight::setSpecularColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    specular = v;
    updateVisibility();
}
Exemple #27
0
float GfxLight::getFade (void)
{
    if (dead) THROW_DEAD(className);
    return fade;
}
Exemple #28
0
float GfxLight::getRange (void)
{
    if (dead) THROW_DEAD(className);
    return light->getAttenuationRange();
}
Exemple #29
0
Vector3 GfxLight::getDiffuseColour (void)
{
    if (dead) THROW_DEAD(className);
    return diffuse;
}
Exemple #30
0
void AudioBody::stop (void)
{
    if (destroyed) THROW_DEAD(className);
    alSourceStop(alSourceLeft);
    alSourceStop(alSourceRight);
}