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

Copper cube i tworzenie sceny

Ostatnio zmodyfikowano 2013-07-08 16:59
Autor Wiadomość
klonyyy
Temat założony przez niniejszego użytkownika
» 2013-03-10 18:38:31
Nie ma modeli, po prostu białe ściany ;)
Ja po prostu do kodu z lekcji dodawanie sceny dodałem zamiast "mojirr" moją scenę, i co się pojawiło to skrzynka i białe ściany. Ale nawet po włązceniu programu ze sceną mojirr program nie może otworzyć niektórych plików nawet nie wiem dlaczego, a ściągnąłem je i nawet popakowałem w ten sam sposób do folderów o tych samych nazwach
P-78059
klonyyy
Temat założony przez niniejszego użytkownika
» 2013-07-08 11:04:44
Witam!

Kilka ostatnich dni poświęciłem na pisanie w Irrlichcie, i chciałbym zrobić coś takiego, że np gdy nacisnę przycisk "A" to ma się odtworzyć animacja strzału na pistolecie, który jest już załadowany w programie. Używam pliku gun.md2 z folderu "media" z irrlichta, ale po zaladowaniu animacj strzela cały czas, wykonując przy tym chyba przeładowanie, co jest jak najbardziej normalne,ale jak mam zrobić by odtwarzać tylko animację strzału po naciśnięciu klawisza? Czy powniniem wyexportować ten plik do coppercuba i tam coś z nim zrobić ?

pozdrawiam
P-87237
megatron
» 2013-07-08 14:15:40
musisz użyc tego
if( event.IsKeyDown( KEY_KEY_A ) )
 oraz
postac->setFrameLoop( cage_on, cage_off );
P-87243
klonyyy
Temat założony przez niniejszego użytkownika
» 2013-07-08 15:10:24
Super właśnie o to mi chodziło ;)A mam jeszcze jedno pytanie - czy istnieje jakiś temat jak używać biblioteki irrKlang, albo poradnik ?

Jeszcze raz dzięki bardzo mi pomogłeś ;)
P-87245
megatron
» 2013-07-08 15:24:02
ambiera
sam korzystałem z tego kursu i jest świetny
P-87248
klonyyy
Temat założony przez niniejszego użytkownika
» 2013-07-08 16:18:51
No kurcze już chciałem wypróbować Twój kawałek kodu, a tu nagle przestała mi działać kamera fps,  korzystam z debug, nie release, więc razem z aplikacją wyświetla mi się ładna konsola w której jest które mesh'e się załadowały itp idt, do tego poszła ta konsola - jest kompletnie pusta, utworzyłem nowy projekt, dalej nic, już sam nie wiem. kod :

C/C++
#include <irrlicht.h>
#include "driverChoice.h"
//#include <irrKlang.h>
#pragma comment(lib, "irrklang.lib")

using namespace irr;

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif

enum
{
    // I use this ISceneNode ID to indicate a scene node that is
    // not pickable by getSceneNodeAndCollisionPointFromRay()
    ID_IsNotPickable = 0,
   
    // I use this flag in ISceneNode IDs to indicate that the
    // scene node can be picked by ray selection.
    IDFlag_IsPickable = 1 << 0,
   
    // I use this flag in ISceneNode IDs to indicate that the
    // scene node can be highlighted.  In this example, the
    // homonids can be highlighted, but the level mesh can't.
    IDFlag_IsHighlightable = 1 << 1
};

bool up = false;
bool klikp = false;

class MyEventReceiver
    : public IEventReceiver
{
public:
    virtual bool OnEvent( const SEvent & event )
    {
        if( event.EventType == EET_KEY_INPUT_EVENT )
        {
            switch( event.KeyInput.Key )
            {
            case KEY_KEY_M:
                up = event.KeyInput.PressedDown;
                break;
               
            case KEY_KEY_A:
                klikp = event.KeyInput.PressedDown;
                break;
            }
            //return true;
        }
    }
    /*
           if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
            {
   
             switch(event.MouseInput.Event)
                {
                case EMIE_LMOUSE_PRESSED_DOWN:
                    klikp= true;
                    break;
   
                default:
                    // We won't use the wheel
                    break;
                }
            }*/
   
    //return false;
   
};



float bc = 0;

int main()
{
   
   
    MyEventReceiver receiver;
   
    IrrlichtDevice * device =
    createDevice( video::EDT_OPENGL, core::dimension2d < u32 >( 640, 480 ), 16, false, false, false, & receiver );
   
    if( device == 0 )
         return 1; // could not create selected driver.
   
    video::IVideoDriver * driver = device->getVideoDriver();
    scene::ISceneManager * smgr = device->getSceneManager();
   
    device->getFileSystem()->addFileArchive( "C:/media/map-20kdm2.pk3" );
   
    scene::IAnimatedMesh * q3levelmesh = smgr->getMesh( "20kdm2.bsp" );
    scene::IMeshSceneNode * q3node = 0;
   
    // The Quake mesh is pickable, but doesn't get highlighted.
    if( q3levelmesh )
         q3node = smgr->addOctreeSceneNode( q3levelmesh->getMesh( 0 ), 0, IDFlag_IsPickable );
   
    scene::ITriangleSelector * selector = 0;
   
    if( q3node )
    {
        q3node->setPosition( core::vector3df( - 1350, - 130, - 1400 ) );
       
        selector = smgr->createOctreeTriangleSelector(
        q3node->getMesh(), q3node, 128 );
        q3node->setTriangleSelector( selector );
        // We're not done with this selector yet, so don't drop it.
    }
    scene::ICameraSceneNode * camera =
    smgr->addCameraSceneNodeFPS( 0, 100.0f,.3f, ID_IsNotPickable, 0, 0, true, 3.f );
    camera->setPosition( core::vector3df( 50, 50, - 60 ) );
    camera->setTarget( core::vector3df( - 70, 30, - 60 ) );
   
   
    scene::IAnimatedMeshSceneNode * node = 0;
   
    video::SMaterial material;
   
   
    // This X files uses skeletal animation, but without skinning.
   
   
   
    if( selector )
    {
        scene::ISceneNodeAnimator * anim = smgr->createCollisionResponseAnimator(
        selector, camera, core::vector3df( 30, 50, 30 ), //??????????
        core::vector3df( 0, - 10, 0 ), core::vector3df( 0, 50, 0 ) );
        selector->drop(); // As soon as we're done with the selector, drop it.
        camera->addAnimator( anim ); //?????????????
        anim->drop(); // And likewise, drop the animator when we're done referring to it.
    }
   
    device->getCursorControl()->setVisible( false );
   
    // Add the billboard.
    scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
    bill->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
    bill->setMaterialTexture( 0, driver->getTexture( "C:/media/particle.bmp" ) );
    bill->setMaterialFlag( video::EMF_LIGHTING, false );
    bill->setMaterialFlag( video::EMF_ZBUFFER, false );
    bill->setSize( core::dimension2d < f32 >( 20.0f, 20.0f ) );
    bill->setID( ID_IsNotPickable ); // This ensures that we don't accidentally ray-pick it
   
    //smgr->loadScene("C:/media/bron4.irr");
    //scene::IAnimatedMesh* mesh = smgr->getMesh("C:/media/bone.3ds");
   
   
    node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "C:/media/gun.md2" ), 0, IDFlag_IsPickable | IDFlag_IsHighlightable );
   
    node->setMaterialFlag( video::EMF_LIGHTING, false );
    node->setMaterialTexture( 0, driver->getTexture( "C:/media/gun.jpg" ) );
   
    node->setPosition( core::vector3df( - 70, - 66, - 30 ) ); // Put its feet on the floor.
    node->setRotation( core::vector3df( 0, 0, 0 ) ); // And turn it towards the camera.///0,-90,0
    node->setAnimationSpeed( 20.f );
    //node->getMaterial(0).Lighting = true;
    selector = smgr->createTriangleSelector( node );
    node->setTriangleSelector( selector );
    node->setScale( core::vector3df( 3.0f ) );
    selector->drop();
   
    material.setTexture( 0, 0 );
    material.Lighting = false;
   
    // Add a light, so that the unselected nodes aren't completely dark.
    scene::ILightSceneNode * light = smgr->addLightSceneNode( 0, core::vector3df( - 60, 100, 400 ),
    video::SColorf( 1.0f, 1.0f, 1.0f, 1.0f ), 600.0f );
    light->setID( ID_IsNotPickable ); // Make it an invalid target for selection.
   
    // Remember which scene node is highlighted
    scene::ISceneNode * highlightedSceneNode = 0;
    scene::ISceneCollisionManager * collMan = smgr->getSceneCollisionManager();
    int lastFPS = - 1;
   
    // draw the selection triangle only as wireframe
    material.Wireframe = true;
   
    while( device->run() )
    if( device->isWindowActive() )
    {
        core::vector3df v = camera->getPosition();
        core::vector3df b = camera->getRotation();
       
       
        node->setPosition( core::vector3df( v.X, v.Y, v.Z ) );
        node->setRotation( core::vector3df( 0, b.Y - 90, b.Z ) ); //0,+180,0
       
        if( up )
        {
            camera->setPosition( core::vector3df( v.X, v.Y + 1.5, v.Z ) );
        }
        if( klikp )
        {
            node->setFrameLoop( 20, 30 );
        }
       
        driver->beginScene( true, true, 0 );
        smgr->drawAll();
       
        // Unlight any currently highlighted scene node
        if( highlightedSceneNode )
        {
            highlightedSceneNode->setMaterialFlag( video::EMF_LIGHTING, true );
            highlightedSceneNode = 0;
        }
       
        // All intersections in this example are done with a ray cast out from the camera to
        // a distance of 1000.  You can easily modify this to check (e.g.) a bullet
        // trajectory or a sword's position, or create a ray from a mouse click position using
        // ISceneCollisionManager::getRayFromScreenCoordinates()
        core::line3d < f32 > ray;
        ray.start = camera->getPosition();
        ray.end = ray.start +( camera->getTarget() - ray.start ).normalize() * 1000.0f;
       
       
        core::vector3df intersection;
       
        core::triangle3df hitTriangle;
       
       
        scene::ISceneNode * selectedSceneNode =
        collMan->getSceneNodeAndCollisionPointFromRay(
        ray,
        intersection, // This will be the position of the collision
        hitTriangle, // This will be the triangle hit in the collision
        IDFlag_IsPickable, // This ensures that only nodes that we have
        // set up to be pickable are considered
        0 ); // Check the entire scene (this is actually the implicit default)
       
        if( selectedSceneNode )
        {
            bill->setPosition( intersection );
           
           
            driver->setTransform( video::ETS_WORLD, core::matrix4() );
            driver->setMaterial( material );
            driver->draw3DTriangle( hitTriangle, video::SColor( 0, 255, 0, 0 ) );
           
            if(( selectedSceneNode->getID() & IDFlag_IsHighlightable ) == IDFlag_IsHighlightable )
            {
                highlightedSceneNode = selectedSceneNode;
               
                highlightedSceneNode->setMaterialFlag( video::EMF_LIGHTING, false );
            }
        }
       
        // We're all done drawing, so end the scene.
        driver->endScene();
       
        int fps = driver->getFPS();
       
        if( lastFPS != fps )
        {
            core::stringw str = L"Collision detection example - Irrlicht Engine [";
            str += driver->getName();
            str += "] FPS:";
            str += fps;
           
            device->setWindowCaption( str.c_str() );
            lastFPS = fps;
        }
    }
   
    device->drop();
   
    return 0;
}
Oczywiście w programie normalnie są wcięcia, ale tu jakoś zniknęły.

Tak czy inaczej dzięki za linka ;)

pozdrawiam
P-87251
megatron
» 2013-07-08 16:20:42
ponieważ musisz pobrać dodatek... zakładam że masz nową wersję kompilatora mingw gcc
http://www.ambiera.at​/downloads​/irrklang-1.4.0-gcc4.7.zip
P-87252
klonyyy
Temat założony przez niniejszego użytkownika
» 2013-07-08 16:23:47
A tak mam najnowszą - o jaki dodatek chodzi, czy jest to w ogóle możliwe by chodziło dobrze i nagle zniknęło ?.

Edit Ale nie nie chodzi o dźwięk, chodzi o strzelanie ;)Może ściągnę starszego Code::blocks'a ?
P-87253
1 « 2 » 3
Poprzednia strona Strona 2 z 3 Następna strona