how to use progressive mesh?
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
how to use progressive mesh?
hi,
is there an example on how i can make use of ogre::progressivemesh class?
i'd like to try it out. please help.
gab
is there an example on how i can make use of ogre::progressivemesh class?
i'd like to try it out. please help.
gab
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
attempt
hi,
thanks. i read the documentation. i tried with the following code but when i run the envmap sample, it crashed after a long wait. what code be wrong?
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
MeshPtr mesh = ent->getMesh();
Mesh::LodDistanceList lodDList;
lodDList.push_back(50);
lodDList.push_back(100);
lodDList.push_back(150);
mesh->generateLodLevels(lodDList, ProgressiveMesh::VertexReductionQuota::VRQ_PROPORTIONAL, 100);
thanks. i read the documentation. i tried with the following code but when i run the envmap sample, it crashed after a long wait. what code be wrong?
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
MeshPtr mesh = ent->getMesh();
Mesh::LodDistanceList lodDList;
lodDList.push_back(50);
lodDList.push_back(100);
lodDList.push_back(150);
mesh->generateLodLevels(lodDList, ProgressiveMesh::VertexReductionQuota::VRQ_PROPORTIONAL, 100);
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
discrete lod
hi,
it worked now. but when i tried manually creating lod, there's an exception error saying something like "did you build you manual lod after creating the entity?"
what could be wrong? thanks for your help.
here's my code:
// Discrete LOD
Entity *ent1 = mSceneMgr->createEntity("MLOD", "hires.mesh");
MeshPtr mesh1 = ent1->getMesh();
mesh1->createManualLodLevel(50, "hires.mesh");
mesh1->createManualLodLevel(150, "lowres.mesh");
it worked now. but when i tried manually creating lod, there's an exception error saying something like "did you build you manual lod after creating the entity?"
what could be wrong? thanks for your help.
here's my code:
// Discrete LOD
Entity *ent1 = mSceneMgr->createEntity("MLOD", "hires.mesh");
MeshPtr mesh1 = ent1->getMesh();
mesh1->createManualLodLevel(50, "hires.mesh");
mesh1->createManualLodLevel(150, "lowres.mesh");
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
help on manual LOD
hi,
can anyone offer any advice on what's wrong with my code that the engine complains "did you build you manual lod after creating the entity?"
appreciate your help very much!
// Discrete LOD
Entity *ent1 = mSceneMgr->createEntity("MLOD", "hires.mesh");
MeshPtr mesh1 = ent1->getMesh();
mesh1->createManualLodLevel(50, "hires.mesh");
mesh1->createManualLodLevel(150, "lowres.mesh");
// anything else to be done other than adding it to the root node?
can anyone offer any advice on what's wrong with my code that the engine complains "did you build you manual lod after creating the entity?"
appreciate your help very much!
// Discrete LOD
Entity *ent1 = mSceneMgr->createEntity("MLOD", "hires.mesh");
MeshPtr mesh1 = ent1->getMesh();
mesh1->createManualLodLevel(50, "hires.mesh");
mesh1->createManualLodLevel(150, "lowres.mesh");
// anything else to be done other than adding it to the root node?
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Umm, did you even read that error message? The message says:
If you read your code, that's exactly what you did. So don't - create the LOD before creating an entity. Please take the time to read the error messages raised, most of the time they're pretty self-explanatory."did you build you manual lod after creating the entity?"
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
i encountered this problem because i followed the exact logic flow for creating automatic/progressive LOD.
i can create manual LODs before creating the entity as suggested but the question i have is how do i "associate" these manual LODs thereafter to the entity i've created. i did read up mesh, entity class information, there doesn't seem to be a public function that does that.
// automatic LOD
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
MeshPtr mesh = ent->getMesh();
Mesh::LodDistanceList lodDList;
lodDList.push_back(50);
lodDList.push_back(100);
lodDList.push_back(150);
mesh->generateLodLevels(lodDList, ProgressiveMesh::VertexReductionQuota::VRQ_PROPORTIONAL, 0.2);
// discrete/manual LOD
... // creates a mesh
mesh->createManualLodLevel(50, "hires.mesh");
mesh->createManualLodLevel(150, "lowres.mesh");
...// how to add this mesh to an entity??
i can create manual LODs before creating the entity as suggested but the question i have is how do i "associate" these manual LODs thereafter to the entity i've created. i did read up mesh, entity class information, there doesn't seem to be a public function that does that.
// automatic LOD
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
MeshPtr mesh = ent->getMesh();
Mesh::LodDistanceList lodDList;
lodDList.push_back(50);
lodDList.push_back(100);
lodDList.push_back(150);
mesh->generateLodLevels(lodDList, ProgressiveMesh::VertexReductionQuota::VRQ_PROPORTIONAL, 0.2);
// discrete/manual LOD
... // creates a mesh
mesh->createManualLodLevel(50, "hires.mesh");
mesh->createManualLodLevel(150, "lowres.mesh");
...// how to add this mesh to an entity??
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Code: Select all
Entity *ent = mSceneMgr->createEntity("head", mesh);
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
Code: Select all
Entity *ent = mSceneMgr->createEntity("head", mesh);
this won't work because if you read from the class info, createEntity doesn't take "mesh" as argument. it takes the name of the mesh, a string. according to the info, it needs a meshname, but from many examples, i see that it means a mesh's filename rather.
can anyone else offer advice on this? i'm sure using LOD is a common practice in most games. once this gets through i'll post a tutorial on manual and automatic LOD for the newbies... *sigh*
Code: Select all
// the code again
MeshPtr mesh1;
mesh1->createManualLodLevel(50, "ogrehead.mesh"); // it crashes here, anything i need to initialize the pointer with?
mesh1->createManualLodLevel(150, "fish.mesh");
// still unknown how to associate this mesh to an entity
Entity *ent1 = mSceneMgr->createEntity("MLOD", ???);
[/code]
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Sorry, I gave you bad advice.
You should load your mesh using Meshmanager::load - do the LOD - and then load it again with mSceneMgr->createEntity("name", "mesh.name");
If the resource exsists, the instance will be returned and all is well.
I think.
You should load your mesh using Meshmanager::load - do the LOD - and then load it again with mSceneMgr->createEntity("name", "mesh.name");
If the resource exsists, the instance will be returned and all is well.
I think.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
i tried this:
question: i have only 1 mesh to start with, how can this "group" be created and associated with my mesh?
Code: Select all
// Discrete LOD
MeshPtr mesh1 = MeshManager::getSingleton().load("ogrehead.mesh", "group", HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::HBU_STATIC_WRITE_ONLY, true, true);
// crashes here - execption complains of unknown "group"
mesh1->createManualLodLevel(50, "ogrehead.mesh");
mesh1->createManualLodLevel(150, "fish.mesh");
Entity *ent1 = mSceneMgr->createEntity("MLOD", "ogrehead.mesh");
question: i have only 1 mesh to start with, how can this "group" be created and associated with my mesh?
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
The Ogre head already has LOD (generated), so you can't add manual LOD to it without removing all the existing LOD. It's also entirely pointless adding the ogre head to itself as a manual LOD level!!
I don't understand your question. What group? The mesh holds LOD information, and an Entity just points at that definition. You don't need anything else.
I don't understand your question. What group? The mesh holds LOD information, and an Entity just points at that definition. You don't need anything else.
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
The ogrehead is just a dummy file acting as one of LOD level. How would one know beforehand that the ogrehand has generated LODs?
In simple, I'm trying to create a model that can be loaded with multiple discrete LODs at different view distances. For example, intuitively I could code something like this in another scenegraph:
But how can this be done in ogre?
In simple, I'm trying to create a model that can be loaded with multiple discrete LODs at different view distances. For example, intuitively I could code something like this in another scenegraph:
Code: Select all
// ...
lod1.load( "hi-res.model");
lod2.load( "low-res.model");
sg::LOD lodNode = new sg::LOD;
lodNode.addChild(lod1, 1, 50);
lodNode.addChild(lod2, 51, 100);
// ... then attach the LOD node to the root/scene node
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
It's quite simple - just call Mesh::getNumLodLevels. But you shouldn't need to anyway - LOD is something that you typically prepare ahead of time as part of content creation, that's why LOD information is stored in the .mesh file and is already part of several meshes that come with OGRE. Clearly if you planned to use LOD another way you would set up your own meshes appropriately.The ogrehead is just a dummy file acting as one of LOD level. How would one know beforehand that the ogrehand has generated LODs?
It's very easy to use manual LODs in OGRE, using the same code you used above, provided the mesh doesn't already have LOD of a different type. You can even use the MeshSerializer to write the setup out to an updated .mesh so you don't have to set it up in code more than once.
You seem to have preconceptions as to the way this should work (perhaps based on your previous engine) which is why you're having problems. It really isn't very difficult - just read the API spec once in a while. You're getting exceptions because you're using a resource group which doesn't exist. ResourceGroupManager controls resource groups; but really, stick to the general resource group until you know what you're doing - you don't need multiple resource groups for most things.
Code: Select all
// Discrete LOD
MeshPtr mesh1 = MeshManager::getSingleton().load("something.mesh"); // level 0
mesh1->createManualLodLevel(50, "level1.mesh");
mesh1->createManualLodLevel(150, "level2.mesh");
Entity *ent1 = mSceneMgr->createEntity("MLOD", "something.mesh");
// or, if you want to save it for next time
MeshSerializer ser;
ser.exportMesh(mesh1.get(), "something_withlod.mesh");
// then you can just createEntity("MLOD", "something_withlod.mesh"); and skip all the setup next time
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
thanks
thanks sinbad! appreciate your help.
yes, usually preconceptions we have due to past experiences with other engines can obscure our understanding of new things.
since trying out ogre a few days back, i grow to like it very much because of its OO and clean/neat nature. however, in my opinion, having elaborately documented classes may not be able to help newbies in using the engine. see, they only help to describe the functionalities but not how the workflow should be. the wiki tutorials are doing a job in some areas.
at the same time i understand open-source engines that can come such a long way like ogre need a lot of resources to have very nice and understandable documentation. perhaps you can look into a publisher to support the efforts of an ogre programming manual/engine book.
i'll continue to fiddle with ogre and perhaps use it for some of my bigger projects. keep up the good work!!
yes, usually preconceptions we have due to past experiences with other engines can obscure our understanding of new things.
since trying out ogre a few days back, i grow to like it very much because of its OO and clean/neat nature. however, in my opinion, having elaborately documented classes may not be able to help newbies in using the engine. see, they only help to describe the functionalities but not how the workflow should be. the wiki tutorials are doing a job in some areas.
at the same time i understand open-source engines that can come such a long way like ogre need a lot of resources to have very nice and understandable documentation. perhaps you can look into a publisher to support the efforts of an ogre programming manual/engine book.
i'll continue to fiddle with ogre and perhaps use it for some of my bigger projects. keep up the good work!!
-
- Kobold
- Posts: 31
- Joined: Tue May 31, 2005 7:10 am
hi,
the MeshManager's load method does not take 1 argument. so i tried with this:
but then there's an exception error thrown, telling me that "resource with name 01_-_ already exits"... i believe there's some resource which is duplicated and caused the conflict.
strange thing is thereafter, when i reverted the code back to its original state (which is environmap.h), rebuilt it from scratch, the same exception is being thrown.
any advice?
the MeshManager's load method does not take 1 argument. so i tried with this:
Code: Select all
MeshPtr mesh1 = MeshManager::getSingleton().load("something.mesh", "group", HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::HBU_STATIC_WRITE_ONLY, true, true);
strange thing is thereafter, when i reverted the code back to its original state (which is environmap.h), rebuilt it from scratch, the same exception is being thrown.
any advice?
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
You can get away with 2 parameters, sorry I forgot the group name wasn't defaulted. The standard group is ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.
I think you have other issues in whatever code you're using to test this, or in the environment you're testing it in (scripts etc). There's no way you should get "resource with name 01_-_ already exits" if you were trying to load "something.mesh". Where is "01_-_" coming from? Unless you know, I suggest clearing down everything, including any changes you've made to any code or scripts, before testing again. You have dodgy things knocking about in your test environment which is clouding this issue I'm sure - and if you don't know what they are, I sure as hell don't .
I think you have other issues in whatever code you're using to test this, or in the environment you're testing it in (scripts etc). There's no way you should get "resource with name 01_-_ already exits" if you were trying to load "something.mesh". Where is "01_-_" coming from? Unless you know, I suggest clearing down everything, including any changes you've made to any code or scripts, before testing again. You have dodgy things knocking about in your test environment which is clouding this issue I'm sure - and if you don't know what they are, I sure as hell don't .
-
- Gnoblar
- Posts: 1
- Joined: Wed Oct 04, 2006 12:10 pm
- Location: Russia
- Contact:
Strange behaviour
Code: Select all
// blah-blah-blah
MeshPtr base=MeshManager::getSingleton().load(bodyData->Mesh,ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
for(LodsList::iterator it=bodyData->Lods.begin(),end=bodyData->Lods.end();it!=end;++it) {
base->createManualLodLevel(it->dist,it->mesh);
}
shipEntity=EmperiumEngine::getSingleton().getSceneManager().createEntity(StringConverter::toString(shipID)+"_ship",bodyData->Mesh);
shipSceneNode->attachObject(shipEntity);
// blah-blah-blah
However, after commenting that code, everything works well.
HEELP! Please! What i'm doing wrong?