Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kezdeti teendők Letöltés: OgreBillboardParticles.zip Kicsomagol Futtat: OgreBillboardParticles.sln Include és library útvonalak beállítása Working directory.

Similar presentations


Presentation on theme: "Kezdeti teendők Letöltés: OgreBillboardParticles.zip Kicsomagol Futtat: OgreBillboardParticles.sln Include és library útvonalak beállítása Working directory."— Presentation transcript:

1

2 Kezdeti teendők Letöltés: OgreBillboardParticles.zip Kicsomagol Futtat: OgreBillboardParticles.sln Include és library útvonalak beállítása Working directory beállítása Fordít Futtat

3 Próba

4 Új file: Tree.h #include "Ogre.h" using namespace Ogre; class BillboardTree { public: BillboardTree(Vector3 position, SceneManager* sm) { static int id = 0; SceneNode* billboardNode = sm->getRootSceneNode()->createChildSceneNode(); BillboardSet *treeBillboardSet = sm->createBillboardSet( "treeBillboard" + StringConverter::toString(id), 1); billboardNode->attachObject(treeBillboardSet); treeBillboardSet->setDefaultDimensions(47,66); treeBillboardSet->setBillboardType(BBT_ORIENTED_COMMON); treeBillboardSet->setBillboardOrigin(BBO_BOTTOM_CENTER); treeBillboardSet->setCommonDirection(Vector3::UNIT_Y); Billboard* bb = treeBillboardSet->createBillboard(position); treeBillboardSet->setMaterialName("TreeBillboard"); id++; } };

5 Új material file: Tree.material material TreeBillboard { technique { pass { lighting off texture_unit { texture tree.png filtering anisotropic }

6 OgreBillboardParticles.cpp Void setupScene() { … sceneManager->setSkyBox(true, "Sky", 10, true); new BillboardTree(Vector3::ZERO, sceneManager); }

7 Próba

8 material TreeBillboard { technique { pass { lighting off scene_blend alpha_blend texture_unit { texture tree.png filtering anisotropic }

9 Próba

10 Sok fa new BillboardTree(Vector3::ZERO, sceneManager); Helyett: for(int i = 0; i < 30; i ++) { Vector3 pos = Vector3(Math::RangeRandom(-60,60), 0, Math::RangeRandom(-60,60)); new BillboardTree(pos, sceneManager); }

11 Próba

12 material TreeBillboard { technique { pass { depth_write off lighting off scene_blend alpha_blend texture_unit { texture tree.png filtering anisotropic }

13 Próba

14 Átlátszó objektumok rendezése Oldjuk meg hogy ne legyen hiba a rendezésben: A fa színtérgráf-csomópontját toljuk el és ne a plakátot a billboardset-ben Alakítsuk át a kódot úgy, hogy csak egy billboardset legyen és ebbe fűzzük az összes plakátot. Figyelni kell: Rendezés Culling Pool (billboardset maximális mérete)

15 Megoldás class BillboardTree { static BillboardSet* treeBillboardSet; public: BillboardTree(Vector3 position, SceneManager* sm) { if(treeBillboardSet == 0) { treeBillboardSet = sm->createBillboardSet("treeBillboards", 20); treeBillboardSet->setMaterialName("TreeBillboard"); SceneNode* billboardSetNode = sm->getRootSceneNode()->createChildSceneNode(); billboardSetNode->attachObject(treeBillboardSet); treeBillboardSet->setDefaultDimensions(47,66); treeBillboardSet->setBillboardType(BBT_ORIENTED_COMMON); treeBillboardSet->setBillboardOrigin(BBO_BOTTOM_CENTER); treeBillboardSet->setCommonDirection(Vector3::UNIT_Y); treeBillboardSet->setCullIndividually(true); treeBillboardSet->setSortingEnabled(true); treeBillboardSet->setAutoextend(true); } Billboard* bb = treeBillboardSet->createBillboard(position); } }; BillboardSet* BillboardTree::treeBillboardSet = 0;

16 Próba

17 Bonyolultabb fa class BillBoardCloudTree { public: BillBoardCloudTree(Vector3 position, SceneManager* sm) { static int id = 0; SceneNode* treeNode = sm->getRootSceneNode()->createChildSceneNode(); treeNode->setPosition(position); treeNode->rotate(Vector3::UNIT_Y, Radian(Math::RangeRandom(0,Math::PI * 2))); Entity* trunk = sm->createEntity("treetrunk"+StringConverter::toString(id), "treetrunk.mesh"); treeNode->attachObject(trunk); id++; } }; for(int i = 0; i < 30; i ++) { Vector3 pos = Vector3(Math::RangeRandom(-60,60), 0, Math::RangeRandom(-60,60)); new BillBoardCloudTree(pos, sceneManager); }

18 Tree.material: új anyagjellemző material TreeTrunk { technique { pass { lighting off texture_unit { texture oakbark.jpg filtering anisotropic }

19 Próba

20 BillBoardCloudTree(Vector3 position, SceneManager* sm) { static int id = 0; SceneNode* treeNode = sm->getRootSceneNode()->createChildSceneNode(); treeNode->setPosition(position); treeNode->rotate(Vector3::UNIT_Y, Radian(Math::RangeRandom(0,Math::PI * 2))); Entity* trunk = sm->createEntity("treetrunk"+StringConverter::toString(id), "treetrunk.mesh"); treeNode->attachObject(trunk); BillboardSet* billboardCloud = sm->createBillboardSet("treebbcloud"+StringConverter::toString(id)); treeNode->attachObject(billboardCloud); billboardCloud->setBillboardType(BBT_PERPENDICULAR_SELF); billboardCloud->setMaterialName("TreeLeaves"); billboardCloud->setSortingEnabled(true); for(int i = 0; i < 10; i++) { float h = Math::RangeRandom(25,60); Vector3 pos(0,h,0); Vector3 dir(Math::RangeRandom(-0.6f,0.6f),1,Math::RangeRandom(-0.6f,0.6f)); dir.normalise(); Billboard* bb = billboardCloud->createBillboard(pos); bb->setDimensions(90.0f - h, 90.0f - h); bb->mDirection = dir; } id++; }

21 Tree.material: új anyagjellemző material TreeLeaves { technique { pass { depth_write off lighting off scene_blend alpha_blend cull_hardware none texture_unit { texture leaves.tga filtering none }

22 Próba

23 Részecske Rendszerek

24 int _tmain(int argc, _TCHAR* argv[]) { ogreRoot = new Root("",""); #ifdef _DEBUG ogreRoot->loadPlugin("RenderSystem_Direct3D9_d"); ogreRoot->loadPlugin("Plugin_OctreeSceneManager_d"); ogreRoot->loadPlugin("Plugin_ParticleFX_d"); #else ogreRoot->loadPlugin("RenderSystem_Direct3D9"); ogreRoot->loadPlugin("Plugin_OctreeSceneManager"); ogreRoot->loadPlugin("Plugin_ParticleFX"); #endif Plugin_ParticleFX.dll és Plugin_ParticleFX_d.dll másolása bin-be OgreSDK/bin-ből

25 Új file: Particles.h #include "Ogre.h" using namespace Ogre; class PSysFromScript { public: PSysFromScript(Vector3 position, SceneManager* sm, String scriptname) { static int id = 0; SceneNode* sysNode = sm->getRootSceneNode()->createChildSceneNode(); ParticleSystem* psys = sm->createParticleSystem("psys"+StringConverter::toString(id), scriptname); sysNode->attachObject(psys); sysNode->setPosition(position); id++; } };

26 Új file a media-ba: example.particle particle_system Example1 { material Flare particle_width 10 particle_height 10 quota 10000 billboard_type point emitter Point { angle 15 emission_rate 75 time_to_live 2 direction 0 1 0 velocity_min 50 velocity_max 100 colour_range_start 1 0 0 colour_range_end 0 0 1 }

27 Új material file: Particles.material material Flare { technique { pass { scene_blend add lighting off depth_write off texture_unit { texture flare.png }

28 OgreBillboardParticles.cpp … #include ” Particles.h” … void setupScene() { … new SysFromScript(Vector3(0,0,25),sceneManager,"Example1"); }

29 Próba

30 Feladat Játszunk a scriptel…: Emitter-ek Affector-ok Segít az Ogre manual!!!

31 Pl.: particle_system Example1 { material Flare particle_width 5 particle_height 5 quota 1000 billboard_type point emitter Box { width 120 depth 5 height 120 position 0 2.5 0 angle 0 emission_rate 75 time_to_live 2 direction 0 1 0 velocity_min 5 velocity_max 10 colour_range_start 1 0 0 0 colour_range_end 0 0 1 0 } affector ColourFader2 { state_change 1 alpha1 1 alpha2 -1 } material Flare { technique { pass { scene_blend src_alpha one lighting off depth_write off texture_unit { texture flare.png }

32


Download ppt "Kezdeti teendők Letöltés: OgreBillboardParticles.zip Kicsomagol Futtat: OgreBillboardParticles.sln Include és library útvonalak beállítása Working directory."

Similar presentations


Ads by Google