Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[c++] irrlicht | ITexture * image

Ostatnio zmodyfikowano 2013-06-02 21:41
Autor Wiadomość
megatron
Temat założony przez niniejszego użytkownika
[c++] irrlicht | ITexture * image
» 2013-05-30 21:06:38
Witam. Mam problem, który napotkałem poraz pierwszy z silnikiem irrlicht. Chcę wyświetlić obrazek na ekranie za pomocą takiego kodu:
C/C++
ITexture * image = video->getTexture( adres_obrazka );
video->draw2DImage( image, position2d < s32 >( 300, 300 ), rect < s32 >( 0, 0, 240, 600 ), 0, SColor( 255, 255, 255, 255 ), true );
I "według konsoli" obrazek się wczytuje, ale go nie pokazuje.
Zauważyłem, że jak dodam:
menage->setActiveCamera( false );
 to obrazek się pojawia, ale obraz kamery robi się biały i widać 'tylko' obrazek. Naprawdę dziwi mnie to, ponieważ zawsze wyświetlany w ten sposób obrazek działał. Jeśli ktoś miał już ten problem, wie jak temu zaradzić albo po prostu ma jakiś pomysł, to bardzo proszę pisać.
Z góry dziękuję za pomoc.
P-84407
DejaVu
» 2013-06-02 00:22:16
http://irrlicht.sourceforge.net/forum/viewtopic.php?t=37525

Może w powyższym temacie znajdziesz odpowiedź :)
P-84594
RazzorFlame
» 2013-06-02 18:14:14
Możliwe że wyświetlasz obrazek przed wyświetleniem sceny. Wtedy obrazek jest zakrywany przez scenę.
P-84671
megatron
Temat założony przez niniejszego użytkownika
» 2013-06-02 19:23:56
video->draw2DImage( image, position2d < s32 >( 300, 300 ), rect < s32 >( 0, 0, 240, 600 ), 0, SColor( 255, 255, 255, 255 ), true );
to jest część odpowiedzialna za wyświetlanie i powinna być w pętli po rozpoczęciu sceny; i tak właśnie mam
P-84677
maly
» 2013-06-02 20:12:12
Jeśli obraz ma być na wierzchu to powinieneś to dać na samym końcu, plus/minus przed endScene().
P-84679
megatron
Temat założony przez niniejszego użytkownika
» 2013-06-02 20:26:12
no tak i tak robie... dlatgo mnie to tak dziwi że nie działa... :/
P-84681
maly
» 2013-06-02 20:58:19
Bez kodu trudno cokolwiek wywnioskować ale jeśli twierdzisz że robiąc setActiveCamera(false) jakotako działa to podejrzewam że masz coś spaprane z kamerą.
P-84684
megatron
Temat założony przez niniejszego użytkownika
» 2013-06-02 21:14:31
co tu da podanie kodu???
to jest sam plik Game.cpp
C/C++
#include "Event.h"

Game::Game()
{
    video = NULL;
    menage = NULL;
    guienv = NULL;
    device = createDevice( EDT_NULL );
    selectedSceneNode = NULL;
}

void Game::RunGame()
{
    RunLoad();
   
    desktopResolution = device->getVideoModeList()->getDesktopResolution();
    device = createDevice( EDT_OPENGL, desktopResolution, 32, true, true, true, & event );
   
    device->setWindowCaption( L"Mysterious Islands D" );
    video = device->getVideoDriver();
    menage = device->getSceneManager();
    guienv = device->getGUIEnvironment();
   
    RunSKeyMap();
    kam[ 0 ] = menage->addCameraSceneNodeFPS( 0, 100.0f, speed_kam, - 1, smap, 10, true, 3.f );
    kam[ 0 ]->setFarValue( 10000.f );
    kam[ 0 ]->setPosition( vector3df( kam_pos ) );
    kam[ 0 ]->setRotation( vector3df( 0, 0, 0 ) );
   
    device->getCursorControl()->setVisible( false );
   
   
    //obiekty i tekstury
   
    ///TEREN
    IAnimatedMesh * pomieszczenie = menage->getMesh( "obiekty/map1/map.3ds" );
    pom = menage->addAnimatedMeshSceneNode( pomieszczenie );
    pom->setScale( core::vector3df( 12, 12, 12 ) );
    pom->setPosition( core::vector3df( 0, 0, 0 ) );
    pom->setMaterialFlag( video::EMF_LIGHTING, true );
   
   
    ITriangleSelector * selectoras = menage->createOctTreeTriangleSelector( pomieszczenie->getMesh( 0 ), pom, 0 );
    scene::ISceneNodeAnimator * animas = menage->createCollisionResponseAnimator( selectoras, kam[ 0 ], core::vector3df( 10, 12, 10 ), core::vector3df( 0, - 10, 0 ), core::vector3df( 1, 10, 1 ) );
    selectoras->drop();
    kam[ 0 ]->addAnimator( animas );
    animas->drop();
   
    IAnimatedMesh * okno = menage->getMesh( "obiekty/okno.3ds" );
    IAnimatedMeshSceneNode * okn = menage->addAnimatedMeshSceneNode( okno );
    okn->setScale( core::vector3df( 12, 12, 12 ) );
    okn->setPosition( core::vector3df( 0, 0, 0 ) );
    okn->setMaterialFlag( video::EMF_LIGHTING, true );
    okn->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
   
   
    ///POSTACIE
   
    IAnimatedMesh * postac = menage->getMesh( "obiekty/postac/kulka.3ds" );
    pos = menage->addAnimatedMeshSceneNode( postac );
    pos->setScale( core::vector3df( 0.4, 0.4, 0.4 ) );
    pos->setMaterialFlag( video::EMF_LIGHTING, true );
    pos->setPosition( core::vector3df( - 900, 50, 2600 ) );
    pos->addShadowVolumeSceneNode();
    menage->setShadowColor( video::SColor( 50, 0, 0, 0 ) );
   
    ITriangleSelector * selectorpo = menage->createOctTreeTriangleSelector( postac->getMesh( 0 ), pos, 0 );
    scene::ISceneNodeAnimator * animpo = menage->createCollisionResponseAnimator( selectorpo, kam[ 0 ], core::vector3df( 10, 10, 10 ), core::vector3df( 0, 0, 0 ), core::vector3df( 0, 10, 0 ) );
    selectorpo->drop();
    kam[ 0 ]->addAnimator( animpo );
    animpo->drop();
   
    ITriangleSelector * selectorpo1 = menage->createOctTreeTriangleSelector( pomieszczenie->getMesh( 0 ), pom, 0 );
    scene::ISceneNodeAnimator * animpo1 = menage->createCollisionResponseAnimator( selectorpo1, pos, core::vector3df( 10, 10, 10 ), core::vector3df( 0, - 10, 0 ), core::vector3df( 0, 10, 0 ) );
    selectorpo1->drop();
    pos->addAnimator( animpo1 );
    animpo1->drop();
   
    IAnimatedMesh * kon = menage->getMesh( "obiekty/postacie/kon/kon.3ds" );
    ko = menage->addAnimatedMeshSceneNode( kon );
    ko->setScale( core::vector3df( 2, 2, 2 ) );
    ko->setMaterialFlag( video::EMF_LIGHTING, true );
   
   
   
    ///Chmury
   
    IAnimatedMeshSceneNode * anms1 = menage->addAnimatedMeshSceneNode( menage->getMesh( "obiekty/chmury/chmura2.3ds" ) );
    anms1->setScale( core::vector3df( 10.1, 10.1, 10.1 ) );
    anms1->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
   
    IAnimatedMeshSceneNode * anms2 = menage->addAnimatedMeshSceneNode( menage->getMesh( "obiekty/chmury/chmura2.3ds" ) );
    anms2->setScale( core::vector3df( 10.1, 10.1, 10.1 ) );
    anms2->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
   
    IAnimatedMeshSceneNode * anms3 = menage->addAnimatedMeshSceneNode( menage->getMesh( "obiekty/chmury/chmura2.3ds" ) );
    anms3->setScale( core::vector3df( 10.1, 10.1, 10.1 ) );
    anms3->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
   
    IAnimatedMeshSceneNode * anms4 = menage->addAnimatedMeshSceneNode( menage->getMesh( "obiekty/chmury/chmura2.3ds" ) );
    anms4->setScale( core::vector3df( 10.1, 10.1, 10.1 ) );
    anms4->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
   
   
    if( anms1 || anms2 || anms3 )
    {
        anms1->setMaterialFlag( video::EMF_LIGHTING, true );
        ISceneNodeAnimator * anim1 = menage->createFlyStraightAnimator( core::vector3df( - 220, 2300, - 22000 ), core::vector3df( 522, 2300, 99600 ), 1912350, true );
        anms1->addAnimator( anim1 );
        anim1->drop();
       
        anms2->setMaterialFlag( video::EMF_LIGHTING, true );
        ISceneNodeAnimator * anim2 = menage->createFlyStraightAnimator( core::vector3df( - 8220, 2400, - 82000 ), core::vector3df( 8522, 2400, 89600 ), 1952350, true );
        anms2->addAnimator( anim2 );
        anim2->drop();
       
        anms3->setMaterialFlag( video::EMF_LIGHTING, true );
        ISceneNodeAnimator * anim3 = menage->createFlyStraightAnimator( core::vector3df( - 12220, 2300, - 30200 ), core::vector3df( 3522, 2300, 129600 ), 1912300, true );
        anms3->addAnimator( anim3 );
        anim3->drop();
       
        anms4->setMaterialFlag( video::EMF_LIGHTING, true );
        ISceneNodeAnimator * anim4 = menage->createFlyStraightAnimator( core::vector3df( - 22200, 2300, - 32000 ), core::vector3df( 35202, 2300, 129000 ), 19123000, true );
        anms4->addAnimator( anim4 );
        anim4->drop();
    };
   
   
    /// WYWOLANIE FUNKCJI
    RunTree();
    RunWater();
    RunFire();
    RunWeather();
    RunApi();
    RunStat();
    RunFPS();
   
    narzedzia = menage->addAnimatedMeshSceneNode( menage->getMesh( "obiekty/narzedzia/wedka.x" ), menage->getActiveCamera(), 10, vector3df( 0, - 2, 2 ), vector3df( 0, 180, 0 ) );
    narzedzia->setMaterialFlag( video::EMF_LIGHTING, false );
    narzedzia->setFrameLoop( 55, 55 );
    narzedzia->setAnimationSpeed( 15 );
   
   
    ILightSceneNode * light = 0;
    SLight light_data1;
    light = menage->addLightSceneNode( 0, core::vector3df( 18, 40, - 8 ), video::SColorf( 1.0f, 1.0f, 1.f, 2.0f ), 300.f );
   
   
    /// GLOWNA PETLA
   
    scene::ISceneCollisionManager * collMan = menage->getSceneCollisionManager();
   
    ITexture * image = video->getTexture( "obiekty/tekstures/obrazek.png" ); <-----------tu tworz ę obrazek
   
    while( device->run() && video && exite == false )
    if( device->isWindowActive() )
    {
        kam_pos = kam[ 0 ]->getPosition();
        kam_rot = kam[ 0 ]->getRotation();
       
        video->beginScene();
       
        video->draw2DImage( image, position2d < s32 >( 300, 300 ), rect < s32 >( 0, 0, 240, 600 ), 0, SColor( 255, 255, 255, 255 ), true ); <------------a tu go wy ś wietlam
       
        core::line3d < f32 > ray;
        ray.start = kam[ 0 ]->getPosition();
        ray.end = ray.start +( kam[ 0 ]->getTarget() - ray.start ).normalize() * 150.0f;
        if( ray.end.X > 20 && ray.end.Y > 20 && ray.end.Z > 20 )
             amount_wood = false;
       
        vector3df intersection;
        triangle3df hitTriangle;
        selectedSceneNode = collMan->getSceneNodeAndCollisionPointFromRay( ray, intersection, hitTriangle, 0 );
       
       
        /// FUNKCJE
       
        RunAi();
        RunEvent();
        RunTree_odl();
        view_status();
        RunFishing();
        RunFisherman();
        RunHorse();
       
        position2d < s32 > m = device->getCursorControl()->getPosition();
        video->draw2DRectangle( SColor( 100, 255, 255, 255 ), rect < s32 >( m.X - 20, m.Y - 20, m.X + 20, m.Y + 20 ) );
       
        menage->drawAll();
        guienv->drawAll();
        video->endScene();
       
        cout << kam_pos.X << ".X" << endl;
        cout << kam_pos.Y << ".Y" << endl;
        cout << kam_pos.Z << ".Z" << endl;
       
    }
    device->drop();
}
P-84685
« 1 » 2
  Strona 1 z 2 Następna strona