Пример #1
0
void GfxBody::setAllBonesManuallyControlled (bool v)
{
    if (dead) THROW_DEAD(className);
    for (unsigned i=0 ; i<manualBones.size() ; ++i) {
        manualBones[i] = v;
    }
    updateBones();
}
Пример #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);
}
Пример #3
0
void AudioBody::destroy (void)
{
    if (destroyed) THROW_DEAD(className);
    destroyed = true;
    resource->unregisterReloadWatcher(this);
    alDeleteSources(1, &alSourceLeft);
    alDeleteSources(1, &alSourceRight);
    resource = nullptr;
}
Пример #4
0
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());
    }
}
Пример #5
0
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);
    }
}
Пример #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);
}
Пример #7
0
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;
}
Пример #8
0
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;
}
Пример #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());
        }
    }
}
Пример #10
0
Degree GfxLight::getCoronaOuterAngle (void)
{
    if (dead) THROW_DEAD(className);
    return coronaOuterAngle;
}
Пример #11
0
void GfxLight::setOuterAngle (Degree v)
{
    if (dead) THROW_DEAD(className);
    light->setSpotlightOuterAngle(to_ogre(v));
}
Пример #12
0
Degree GfxLight::getOuterAngle (void)
{
    if (dead) THROW_DEAD(className);
    return from_ogre(light->getSpotlightOuterAngle());
}
Пример #13
0
void GfxLight::setRange (float v)
{
    if (dead) THROW_DEAD(className);
    light->setAttenuation(v, 0, 0, 0);
}
Пример #14
0
float GfxLight::getCoronaSize (void)
{
    if (dead) THROW_DEAD(className);
    return coronaSize;
}
Пример #15
0
void GfxLight::setFade (float f)
{
    if (dead) THROW_DEAD(className);
    fade = f;
    updateVisibility();
}
Пример #16
0
void GfxLight::setEnabled (bool v)
{
    if (dead) THROW_DEAD(className);
    enabled = v;
    updateVisibility();
}
Пример #17
0
Vector3 GfxLight::getSpecularColour (void)
{
    if (dead) THROW_DEAD(className);
    return specular;
}
Пример #18
0
Vector3 GfxLight::getCoronaColour (void)
{
    if (dead) THROW_DEAD(className);
    return coronaColour;
}
Пример #19
0
void GfxLight::setCoronaColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    coronaColour = v;
}
Пример #20
0
void GfxLight::setCoronaLocalPosition (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    coronaLocalPos = v;
}
Пример #21
0
Vector3 GfxLight::getCoronaLocalPosition (void)
{
    if (dead) THROW_DEAD(className);
    return coronaLocalPos;
}
Пример #22
0
void GfxLight::setCoronaSize (float v)
{
    if (dead) THROW_DEAD(className);
    coronaSize = v;
}
Пример #23
0
void GfxLight::setCoronaOuterAngle (Degree v)
{
    if (dead) THROW_DEAD(className);
    coronaOuterAngle = v;
}
Пример #24
0
void GfxLight::setDiffuseColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    diffuse = v;
    updateVisibility();
}
Пример #25
0
bool GfxLight::isEnabled (void)
{
    if (dead) THROW_DEAD(className);
    return enabled;
}
Пример #26
0
void GfxLight::setSpecularColour (const Vector3 &v)
{
    if (dead) THROW_DEAD(className);
    specular = v;
    updateVisibility();
}
Пример #27
0
float GfxLight::getFade (void)
{
    if (dead) THROW_DEAD(className);
    return fade;
}
Пример #28
0
float GfxLight::getRange (void)
{
    if (dead) THROW_DEAD(className);
    return light->getAttenuationRange();
}
Пример #29
0
Vector3 GfxLight::getDiffuseColour (void)
{
    if (dead) THROW_DEAD(className);
    return diffuse;
}
Пример #30
0
void AudioBody::stop (void)
{
    if (destroyed) THROW_DEAD(className);
    alSourceStop(alSourceLeft);
    alSourceStop(alSourceRight);
}