Upload
ezekiel-ping
View
214
Download
0
Embed Size (px)
Citation preview
Kezdeti teendőkLetöltés: OgreBillboardParticles.zipKicsomagolFuttat: OgreBillboardParticles.slnInclude és library útvonalak beállításaWorking directory beállításaFordítFuttat
Próba
Ú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++;}
};
Új material file: Tree.materialmaterial TreeBillboard{
technique{
pass{
lighting offtexture_unit{
texture tree.pngfiltering anisotropic
}}
}}
OgreBillboardParticles.cppVoid setupScene(){…
sceneManager->setSkyBox(true, "Sky", 10, true);
new BillboardTree(Vector3::ZERO, sceneManager);
}
Próba
material TreeBillboard{
technique{
pass{
lighting offscene_blend alpha_blendtexture_unit{
texture tree.pngfiltering anisotropic
}}
}}
Próba
Sok fanew 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);}
Próba
material TreeBillboard{
technique{
pass{
depth_write offlighting offscene_blend alpha_blendtexture_unit{
texture tree.pngfiltering anisotropic
}}
}}
Próba
Átlátszó objektumok rendezéseOldjuk 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-benAlakítsuk át a kódot úgy, hogy csak egy
billboardset legyen és ebbe fűzzük az összes plakátot. Figyelni kell:RendezésCullingPool (billboardset maximális mérete)
Megoldásclass 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;
Próba
Bonyolultabb faclass 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);}
Tree.material: új anyagjellemzőmaterial TreeTrunk{
technique{
pass{
lighting offtexture_unit{
texture oakbark.jpgfiltering anisotropic
}}
}}
Próba
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++;}
Tree.material: új anyagjellemzőmaterial TreeLeaves{
technique{
pass{
depth_write offlighting offscene_blend alpha_blendcull_hardware nonetexture_unit{
texture leaves.tgafiltering none
}}
}}
Próba
Részecske Rendszerek
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");
#elseogreRoot->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
Ú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++;
}
};
Ú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 }}
Új material file: Particles.materialmaterial Flare{
technique{
pass{
scene_blend addlighting offdepth_write offtexture_unit{
texture flare.png}
}}
}
OgreBillboardParticles.cpp…#include ” Particles.h”…
void setupScene(){
…new SysFromScript(Vector3(0,0,25),sceneManager,"Example1");
}
Próba
Feladat
Játszunk a scriptel…:
Emitter-ekAffector-ok
Segít az Ogre manual!!!
Pl.:
particle_system Example1{ material Flare particle_width 5 particle_height 5 quota 1000 billboard_type point
emitter Box {
width 120depth 5height 120position 0 2.5 0angle 0emission_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 1alpha2 -1
}}
material Flare{
technique{
pass{
scene_blend src_alpha onelighting offdepth_write offtexture_unit{
texture flare.png
}}
}}