Hi,
Hatte leider wegen der Schule nich viel Zeit an dem Projekt weiterzuarbeiten.
Bin jetzt auf ein Problem gestoßen: Ich weiss nicht genau wie ich den aktuellen Scenemanager rendern soll.
Hier ist ein teil vom code mit dem ich versuche zwischen den verschiedenen Systemen zu wechseln. Es funktioniert leider nicht.(lässt sich zwar compilieren aber wechselt leider nicht zwischen den verschiedenen Systemen. Es wird nur der Sternenhintergrund angezeigt da dieser erst kurz vor der gameschleife mit der Camera erstellt wird.)
galaxys.cpp
Code:
#include "galaxys.h" // class's header file
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
// class constructor
Galaxys::Galaxys()
{
// allKeysUp();
// allMouseKeysUp();
System =4;
// insert your code here
}
// class destructor
Galaxys::~Galaxys()
{
// insert your code here
}
int Galaxys::Init(){
InputReceiverEnabled = true;
System=1;
GameMain::Init();
return 0;
}
int Galaxys::Exit(){
GameMain::Exit();
return 0;
}
int Galaxys::Render(){
Actualscene();
switch(System){
case 1: GameMain::Render(smgr1);
break;
case 2: GameMain::Render(smgr2);
break;
case 3: GameMain::Render(smgr3);
break;
case 4: GameMain::Render(smgr4);
break;
}
//GameMain::Render(m_smgr);
return 0;
}
void Galaxys::Actualscene(){
switch(System){
case 1: Actual_smgr = smgr1;
break;
case 2: Actual_smgr = smgr2;
break;
case 3: Actual_smgr = smgr3;
break;
case 4: Actual_smgr = smgr4;
break;
}
}
void Galaxys::Systems(){
printf("LOADING...\n");
smgr1 = m_smgr->createNewSceneManager();
smgr2 = m_smgr->createNewSceneManager();
smgr3 = m_smgr->createNewSceneManager();
smgr4 = m_smgr->createNewSceneManager();
IMesh * sun = smgr1->getMesh("meshes/Sonne/sun_bjs3d.3DS");
IMeshSceneNode * sunnode = smgr1->addMeshSceneNode(sun,0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(6,6,6));
if(sunnode)
{
sunnode->setMaterialFlag(EMF_LIGHTING,false);
sunnode->setMaterialTexture(0,m_driver->getTexture("meshes/Sonne/Sun.jpg"));
sunnode->setMaterialTexture(0,m_driver->getTexture("meshes/Sonne/SunIllum.jpg"));
ILightSceneNode*light = m_smgr->addLightSceneNode(sunnode,vector3df(0,0,0),SColorf(0.9f,0.8f,0.2f,1.0f),2000.0f,-1);
light->setLightType(ELT_POINT);
light->enableCastShadow(true);
}
IAnimatedMesh* Ship1 =smgr1->getMesh("meshes/Starfighter01/Starfighter01.obj");
IMeshSceneNode * S1Node = smgr1->addMeshSceneNode(Ship1,0,-1,vector3df(1020,500,100));
if(S1Node)
{
S1Node->setScale(irr::core::vector3df(0.3f,0.3f,0.3f));
S1Node->getMaterial(4).EmissiveColor.set(40);
}
IAnimatedMesh* Ship2 = smgr1->getMesh("meshes/Starfighter02/Starfighter02.obj");
IMeshSceneNode * S2Node = smgr1->addMeshSceneNode(Ship2,0,-1,vector3df(1000,500,100));
if(S2Node)
{
S2Node->setScale(vector3df(0.3f,0.3f,0.3f));
}
IAnimatedMesh* Bom1 = smgr2->getMesh("meshes/Bomber01/Bomber01.obj");
IMeshSceneNode * B1Node = smgr2->addMeshSceneNode(Bom1,0,-1,vector3df(1040,500,100));
if(B1Node)
{
B1Node->setScale(vector3df(0.1f,0.1f,0.1f));
}
IAnimatedMesh* Fre1 = smgr2->getMesh("meshes/Fregatte01/Fregatte01.obj");
IMeshSceneNode * F1Node = smgr2->addMeshSceneNode(Fre1,0,-1,vector3df(1300,500,300));
if(F1Node)
{
F1Node->setScale(vector3df(0.8f,0.8f,0.8f));
}
IAnimatedMesh* Fre2 = smgr2->getMesh("meshes/Fregatte02/Fregatte02.obj");
IMeshSceneNode * F2Node = smgr2->addMeshSceneNode(Fre2,0,-1,vector3df(500,500,150));
if(F2Node)
{
F2Node->setScale(vector3df(0.8f,0.8f,0.8f));
}
IAnimatedMesh* RS1 = smgr2->getMesh("meshes/Raumstation/Raumstation.obj");
IMeshSceneNode * RS1Node = smgr2->addMeshSceneNode(RS1,0,-1,vector3df(800,500,100));
if(RS1Node)
{
RS1Node->setScale(vector3df(1.3f,1.3f,1.3f));
}
IAnimatedMesh* Sl1 = smgr3->getMesh("meshes/Schlachtschiff01/Schlachtschiff01.obj");
IMeshSceneNode * Sl1Node = smgr3->addMeshSceneNode(Sl1,0,-1,vector3df(1120,500,0));
if(Sl1Node)
{
}
IAnimatedMesh* Sat1 = smgr3->getMesh("meshes/Lasersatellit/Lasersatellit.obj");
IMeshSceneNode * Sat1Node = smgr3->addMeshSceneNode(Sat1,0,-1,vector3df(1000,500,-100));
if(Sat1Node)
{
Sat1Node->setScale(vector3df(0.3f,0.3f,0.3f));
}
IAnimatedMesh* Sat2 = smgr4->getMesh("meshes/Raketensatellit/Raketensatellit.obj");
IMeshSceneNode * Sat2Node = smgr4->addMeshSceneNode(Sat2,0,-1,vector3df(1000,500,-200));
if(Sat2Node)
{
Sat2Node->setScale(vector3df(0.3f,0.3f,0.3f));
}
}
bool Galaxys::OnEvent(const irr::SEvent &event)
{
if (!InputReceiverEnabled)
return false;
if(event.EventType == EET_MOUSE_INPUT_EVENT)
{
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
MouseKeys[0] = true;
break;
case EMIE_RMOUSE_PRESSED_DOWN:
MouseKeys[2] = true;
break;
case EMIE_MMOUSE_PRESSED_DOWN:
MouseKeys[1] = true;
break;
case EMIE_LMOUSE_LEFT_UP:
MouseKeys[0] = false;
break;
case EMIE_RMOUSE_LEFT_UP:
MouseKeys[2] = false;
break;
case EMIE_MMOUSE_LEFT_UP:
MouseKeys[1] = false;
break;
case EMIE_MOUSE_MOVED:
return true;
break;
case EMIE_MOUSE_WHEEL:
break;
}
return true;
}
if(event.EventType == EET_KEY_INPUT_EVENT)
{
Keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
if(isKeyDown(KEY_RCONTROL) && isKeyDown(KEY_KEY_1)){
System = 1;
}
if(isKeyDown(KEY_RCONTROL) && isKeyDown(KEY_KEY_2)){
System = 2;
}
if(isKeyDown(KEY_RCONTROL) && isKeyDown(KEY_KEY_3)){
System =3;
}
if(isKeyDown(KEY_RCONTROL) && isKeyDown(KEY_KEY_4)){
System =4;
}
cout<<System<<endl;
Actualscene();
return true;
}
return false;
}
void Galaxys::setInputReceiverEnabled(bool enabled)
{
InputReceiverEnabled = enabled;
}
bool Galaxys::isInputReceiverEnabled() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return InputReceiverEnabled;
}
bool Galaxys::isKeyDown(s32 key)
{
return Keys[key];
}
bool Galaxys::isMouseKeyDown(s32 key)
{
return MouseKeys[key];
}
void Galaxys::allKeysUp()
{
for(int i = 0;i < KEY_KEY_CODES_COUNT;i++)
Keys[i] = false;
}
void Galaxys::allMouseKeysUp()
{
for (s32 i=0; i<3; ++i)
MouseKeys[i] = false;
}
Danke für die Hilfe!