Historique des modifications - Message

Message #5967

Sujet: Probleme de placement de repère avec une scene


Type Date Auteur Contenu
Création du message 04-02-2009 18:45:06 Djinner
Merci pour ta réponse, j'ai fais ce que tu m'as dis, et le problème n'est toujours pas résolu malheureusement.... Je te file tout le code du coup.... Dsl si ce n'est pas très très propre

#include <irr/irrlicht.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

bool _bExit;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace std;

    ISceneNode *cube1;
    ISceneNode *cube2;
    ISceneNode *sphere1;
    ISceneNode *sphere2;
    ISceneNode *cube3;

    int x = 10;
    int y = 10;
    int z = 10;
    int u = -5;
    int v = -5;
    int w = -5;



class MyEventReceiver : public IEventReceiver
{
private:
    ISceneNode* element;

public:
    bool OnEvent(const SEvent& event)
	{
		if (event.EventType == irr::EET_KEY_INPUT_EVENT )
		{
			switch(event.KeyInput.Key)
			{
				case KEY_ESCAPE:
				{
					_bExit = true;
					return true;
				}
				case KEY_KEY_Q:
				{
                    x = 0;
                    y = -5;
                    z = 0;
                    u = 0;
                    v = 10;
                    w = 0;


					return true;
				}
				case KEY_KEY_W:
				{
                    x = 10;
                    y = 0;
                    z = 0;
                    u = -5;
                    v = 0;
                    w = 0;

					return true;
				}

			}
		}

		/*if (event.Eventype == irr::EMIE_LMOUSE_PRESSED_DOWN )
		{

		    if (event.Eventype == irr::EMIE_MOUSE_MOVED){
                element -> setPosition(vector3df(MOUSEEVENTF_XUP, MOUSEEVENTF_XDOWN)
		    }
		}*/
		return false;
	}
};

int main(){

    MyEventReceiver    _EventReceiver;


   /* cout << "Bonjour, quelle vue désirez vous pour cette exemple ? \
(a) selon l'axe Ox \
(b) selon l'axe Oy \
(c) selon l'axe Oz \
(autre) quitter" <<endl;

    char choix;

    cin >> choix;

    switch(choix)
	{
		case 'a': x = 10; break;
		case 'b': y = 10; break;
		case 'c': z = 10; break;
		default: return 0;
	}*/

	IrrlichtDevice *device = createDevice( video::EDT_OPENGL,
											dimension2d<s32>(640, 480),
											32,
											false,
											false,
											true,
											&_EventReceiver);


	/*
		petite redifinition du titre de la fenetre.
	*/
	device->setWindowCaption(L"Tuto_Node - Premier nodes");


	/*
			une fois le device créé, on va récupérer un certain nombre
			de pointeur qui vont nous être utile pour la suite.
			Entre-autre: video driver, SceneManager et GUI.
	*/
	IVideoDriver* driver		= device->getVideoDriver();
	ISceneManager* scenegraph	= device->getSceneManager();





    //Création des éléments de notre graphe de scene
    cube1 = scenegraph->addCubeSceneNode(0.5f, 0);
    cube1->setPosition(vector3df(5,5,5));


    //On ajoute les textures à nos éléments du graphe
	if (cube1)
	{	cube1->setMaterialFlag(EMF_LIGHTING,false);
		cube1->setMaterialTexture( 0, driver->getTexture("C:/irrlicht/media/stones.jpg") );
	}
	if (cube2)
	{	cube2->setMaterialFlag(EMF_LIGHTING,false);
		cube2->setMaterialTexture( 0, driver->getTexture("C:/irrlicht/media/irrlichtlogo.bmp") );
	}
	if (sphere1)
	{	sphere1->setMaterialFlag(EMF_LIGHTING,false);
		sphere1->setMaterialTexture( 0, driver->getTexture("C:/irrlicht/media/irrlichtlogo.bmp") );
	}
	/*if (sphere2)
	{	sphere2->setMaterialFlag(EMF_LIGHTING, false);
		sphere2->setMaterialTexture( 0, driver->getTexture("C:/irrlicht/media/irrlichtlogo.bmp") );
	}*/

    ICameraSceneNode* cam = scenegraph->addCameraSceneNode(0, core::vector3df(5,5,5), core::vector3df(5,5,-5));
    matrix4 orthoMatrix;
    orthoMatrix.buildProjectionMatrixOrthoLH(20.f, 15.f, 5.f, 100.f);
    cam->setProjectionMatrix(orthoMatrix,true);

    int frame =0;

	while(device->run()){
        driver->beginScene(true, true, SColor(255,100,101,140));
	    scenegraph->drawAll();
	    //Création de la caméra selon un angle précis

        //cam->setIsOrthogonal(true);
	    //On dessine les traits du repere
        video::SMaterial m;
        m.Lighting = false;
        driver->setMaterial(m);

        driver->draw3DLine(core::vector3df(0, 0, 0), core::vector3df(20, 0, 0), video::SColor(0, 255, 0, 0));
        driver->draw3DLine(core::vector3df(0, 0, 0), core::vector3df(0, 20, 0), video::SColor(0, 0, 255, 0));
        driver->draw3DLine(core::vector3df(0, 0, 0), core::vector3df(0, 0, 20), video::SColor(0, 0, 0, 255));

	    driver->endScene();

	}

	device->drop();

	return 0;
}

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
113 invités en ligne
membre en ligne: -
RSS Feed