Ejemplo n.º 1
0
void Hero::render()
{
    CAnimatedMeshSceneNode::render();

    video::SMaterial debug_mat;
    debug_mat.Lighting = false;
    debug_mat.AntiAliasing=0;
    gRender->setMaterial(debug_mat);

    gRender->setTransform(ETS_WORLD, IdentityMatrix);
    gRender->draw3DBox(getTransformedBoundingBox(), video::SColor(255,0,255,0));
    gRender->draw3DBox(getAttackArea(), video::SColor(255,255,0,0));
}
Ejemplo n.º 2
0
    /// Move forward the simulation of this sim object by a time delta
    /// @param dt the amount of time to simulate forward
    void SceneObject::ProcessTick( float32_t dt )
    {
        Assert( mSharedData );

        // set the position and rotation of our object
        if( mSceneNode )
        {
            // Note: jsheblak 28July2007
            // Setting the position of some large meshes in irrlicht every frame
            // causes them to flicker or disappear. Compare the position first and
            // update if necessary.
            if( mSharedData->IsDirty(SimEntityData::kDB_Position) )
            {
                // convert from open nero's coordinate system to irrlicht's
                SetPosition( mSharedData->GetPosition() );
                // the position is set here, but it might change after drawAll because of collisions etc
                // thus, the next time we see this sceneNode, we should make sure to get the position back
                // to the state.
            }

            if( mSharedData->IsDirty(SimEntityData::kDB_Rotation) )
            {
                // Irrlicht expects a left handed basis with the x-z plane being horizontal and y being up
                // OpenNero uses a right handed basis with x-y plane being horizontal and z being up
                SetRotation( mSharedData->GetRotation() );

            }

            if ( mSharedData->IsDirty(SimEntityData::kDB_Scale) )
            {
                // set the node scale
                Vector3f scale = mSceneObjectTemplate->mScale;
                /// we can optionally multiply by a custom scale
                scale.X = scale.X * mSharedData->GetScale().X;
                scale.Y = scale.Y * mSharedData->GetScale().Y;
                scale.Z = scale.Z * mSharedData->GetScale().Z;
                // convert from open nero's coordinate system to irrlicht's
                mSceneNode->setScale( ConvertNeroToIrrlichtPosition(scale) );
            }

            if ( mSharedData->IsDirty(SimEntityData::kDB_Label) && mSceneObjectTemplate->mDrawLabel )
            {
                SetText(mSharedData->GetLabel());
            }

            if ( mSharedData->IsDirty(SimEntityData::kDB_Color) )
            {
                if (mAniSceneNode) {
                    // The above workaround is not necessary anymore in Irrlicht 1.5
                    mAniSceneNode->getMaterial(0).DiffuseColor = mSharedData->GetColor();
                }
            }

            // add our bounding box to the lineset
            if( mSceneNode && mSceneObjectTemplate->mDrawBoundingBox )
            {
                BBoxf bbox = getTransformedBoundingBox();
                DrawBBox(bbox, LineSet::LineColor(255,0,255,0));
            }

            if (mFPSCamera && !mCamera)
            {
                Kernel::GetSimContext()->getActiveCamera()->attach(this->GetEntity(), mFPSCamera);
            }

            mSharedData->ClearDirtyBits();
        }
    }