Header
Code: Select all
#ifndef CCLOUDFACTORY_H
#define CCLOUDFACTORY_H
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class CCloudFactory
{
public:
CCloudFactory(scene::ISceneNode* virtualZeroNode, scene::ISceneManager *mgr, core::vector3df posMinAbsolute, core::vector3df posMaxAbsolute, int maxCount, f32 minSize, f32 maxSize, char* imageName, int imageCount, char* imageExtension);
virtual ~CCloudFactory();
core::vector3df GetposMinAbsolute() { return posMinAbsolute; }
void SetposMinAbsolute(core::vector3df val) { posMinAbsolute = val; }
core::vector3df GetposMaxAbsolute() { return posMaxAbsolute; }
void SetposMaxAbsolute(core::vector3df val) { posMaxAbsolute = val; }
int GetmaxCount() { return maxCount; }
void SetmaxCount(int val) { maxCount = val; }
f32 GetminSize() { return minSize; }
void SetminSize(f32 val) { minSize = val; }
f32 GetmaxSize() { return maxSize; }
void SetmaxSize(f32 val) { maxSize = val; }
char* GetimageName() { return imageName; }
void SetimageName(char* val) { imageName = val; }
int GetimageCount() { return imageCount; }
void SetimageCount(int val) { imageCount = val; }
char* GetimageExtension() { return imageExtension; }
void SetimageExtension(char* val) { imageExtension = val; }
public:
private:
core::vector3df posMinAbsolute;
core::vector3df posMaxAbsolute;
int maxCount;
f32 minSize;
f32 maxSize;
char* imageName;
int imageCount;
char* imageExtension;
};
#endif // CCLOUDFACTORY_HCode: Select all
#include "../include/CCloudFactory.h"
CCloudFactory::CCloudFactory(scene::ISceneNode* virtualZeroNode, scene::ISceneManager *mgr, core::vector3df posMinAbsolute, core::vector3df posMaxAbsolute, int maxCount, f32 minSize, f32 maxSize, char* imageName, int imageCount, char* imageExtension)
{
IVideoDriver* driver = mgr->getVideoDriver();
//Wir brauchen ein Array welches die Billboards aufnimmt
scene::ISceneNode* billBoardStore[maxCount];
int i;
for(i=1; i < maxCount; i++)
{
//Random für Grösse Definieren
int iMinSize = static_cast<int>(minSize);
int iMaxSize = static_cast<int>(maxSize);
int randomSize = rand() % (iMaxSize - iMinSize);
f32 randomFloat = minSize + (float) randomSize;
//Billboard erstellen
billBoardStore[i] = mgr->addBillboardSceneNode(virtualZeroNode, core::dimension2d<f32>(randomFloat, randomFloat));
//Random für X-Position erstellen
int xMin = static_cast<int>(posMinAbsolute.X);
int xMax = static_cast<int>(posMaxAbsolute.X);
int randomX = rand() % (xMax - xMin);
f32 randomXFloat = posMinAbsolute.X + (float) randomX;
//Random für Y-Position erstellen
int yMin = static_cast<int>(posMinAbsolute.Y);
int yMax = static_cast<int>(posMaxAbsolute.Y);
int randomY = rand() % (yMax - yMin);
f32 randomYFloat = posMinAbsolute.Y + (float) randomY;
//Random für Z-Position erstellen
int zMin = static_cast<int>(posMinAbsolute.Z);
int zMax = static_cast<int>(posMaxAbsolute.Z);
int randomZ = rand() % (zMax - zMin);
f32 randomZFloat = posMinAbsolute.Z + (float) randomZ;
//Billboard Position erstellen
billBoardStore[i]->setPosition(core::vector3df(randomXFloat, randomYFloat, randomZFloat));
//Die BillboardTextur generieren und zuweisen
char mixedImageArray[100];
sprintf(mixedImageArray, "%s%d%s", imageName, rand() % imageCount + 1, imageExtension);
billBoardStore[i]->setMaterialTexture(0, driver->getTexture(mixedImageArray));
//Textureigenschaften einstellen
billBoardStore[i]->setMaterialFlag(EMF_LIGHTING, false);
billBoardStore[i]->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
billBoardStore[i]->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
}
}
CCloudFactory::~CCloudFactory()
{
//dtor
}
Code: Select all
#include "include/CCloudFactory.h"
//! Some code
//!CloudFactory
CCloudFactory* cloudf = new CCloudFactory(smgr->getRootSceneNode( ), smgr, core::vector3df (200,200,200), core::vector3df (1000,1000,1000), 60, 100, 1000, "../../media/clouds/set", 8, ".png");
AND there is surely crap inside those lines of code bit it is a small basic class that might be help someone others new to here.
greetz
