Hamilton

Game username : Hamilton Server : Myatar Legends // Dragon's Den Posts : 394 Join date : 2011-10-20 Age : 32 Location : everywhere
 | Subject: Opimizing Multi-body source Sat Mar 24, 2018 11:44 pm | |
| This tutorial is relevant only if you already have a working multi-body source. This will be a brief run-down of setting up your multi-body source so that you can have different bodies with their own set of heads/manes/etc. such as having feline parts all separate from canine parts If you haven't already, adjust your GMAX counts for your new meshes. tip- take a few extra minutes to organize your mesh numbers in a document or spread sheet so you know which parts go to which bodies. You will first want to set up the mesh restrictions. It originally shows in the code as the restrictions preventing certain manes from being equipped on certain heads. it's located in externaldefinitions.h and will look like: - Quote :
- bool isRestricted(const short &headID, const short &maneID)
{ if(headID==0 || headID==4) { if(maneID==2||maneID==4||maneID==7||maneID==8||maneID==9||maneID==10||maneID==14||maneID==15||maneID==16||maneID==17||maneID==18||maneID==19||maneID==20||maneID==21||maneID==22||maneID==23||maneID==24)return true; } else if(headID==1 || headID==2 || headID==3 || headID==5) { if(maneID==1||maneID==3||maneID==5||maneID==6||maneID==11||maneID==12||maneID==13||maneID==21||maneID==23)return true; } return false;
it's basically saying that if a certain head is selected, that those manes should be skipped by the selector. you can either edit over this or comment it out and start fresh. if you are using the original set of meshes, i don't know what to say. perhaps a better programmer (like hyper. very skilled) could get multiple restrictions on a single mesh. but i cant. it's either these new restrictions of not :\ you will want all the same basic parts. - Quote :
- bool isRestricted(const short &, const short &)
{ if() { if()return true; } else if() { if()return true; } return false;
First add in all the parts you want to restrict - Quote :
- bool isRestricted(const short &bodyID, const short &headID, const short &maneID, const short &tailID, const short &wingID, const short &tuftID)
{ if() { if()return true; } else if() { if()return true; } return false;
if you have added new meshes, be sure to include them now. next, add your bodies. - Quote :
- bool isRestricted(const short &bodyID, const short &headID, const short &maneID, const short &tailID, const short &wingID, const short &tuftID)
{ if(bodyID==0) { if()return true; } else if(bodyID==1) { if()return true; } return false;
if you have more unique bodies, add them as an extra 'else if' - Quote :
- bool isRestricted(const short &bodyID, const short &headID, const short &maneID, const short &tailID, const short &wingID, const short &tuftID)
{ if(bodyID==0) { if()return true; } else if(bodyID==1) { if()return true; } else if(bodyID==2) { if()return true; } return false;
if you have more bodies but they use the same skeleton, you can add them as just additional meshes - Quote :
- bool isRestricted(const short &bodyID, const short &headID, const short &maneID, const short &tailID, const short &wingID, const short &tuftID)
{ if(bodyID==0 || bodyID==1) { if()return true; } else if(bodyID==2 || bodyID==3 || bodyID==4) { if()return true; } return false;
like so. NEXT add in the parts you want the game to SKIP for each body. Any part not listed will be visible. - Quote :
- bool isRestricted(const short &bodyID, const short &headID, const short &maneID, const short &tailID, const short &wingID, const short &tuftID)
{ if(bodyID==0) { if(headID==1||headID==2||headID==3||headID==5||maneID==2||maneID==4||maneID==7||maneID==8||maneID==9||maneID==10|| maneID==14||maneID==15||maneID==16||maneID==17||maneID==18||maneID==19||maneID==20||maneID==21||maneID==22|| maneID==23||maneID==24||tailID==0||tailID==2||tailID==5||tailID==6||wingID==1||wingID==2||tuftID==3|| tuftID==4||tuftID==7||tuftID==8||tuftID==11)return true; } else if(bodyID==1) { if(headID==0||headID==4||maneID==1||maneID==3||maneID==5||maneID==6||maneID==11||maneID==12||maneID==13||tailID==3|| tailID==4||tailID==7||wingID==3||tuftID==1||tuftID==2||tuftID==5||tuftID==6||tuftID==9||tuftID==10)return true; } return false;
if it helps (i know it does me) you can organize it somewhat by pressing enter in places where the mesh type switches. essentially making the heads, manes, etc have their own line. Just don't forget the || between them. Now you have to make it all those meshes recognize this. move on to the file charscreenmanager.h find - Quote :
- //tail
else if(iID==3) { tailID += (increment?1:-1); if(tailID<0)tailID = mDef->maxTails-1; if(tailID>=mDef->maxTails)tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID),(page==PAGE_PRESET1||page==PAGE_PRESET2||page==PAGE_PRESET3)); } //wings else if(iID==4) { wingID += (increment?1:-1); if(wingID<0)wingID = mDef->maxWings-1; if(wingID>=mDef->maxWings)wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID),(page==PAGE_PRESET1||page==PAGE_PRESET2||page==PAGE_PRESET3)); }
the rest of the parts in this area already have the line but you still need to add it to these two. add in an applyRestrictions to them so they now look like - Quote :
- //tail
else if(iID==3) { tailID += (increment?1:-1); if(tailID<0)tailID = mDef->maxTails-1; if(tailID>=mDef->maxTails)tailID = 0; applyRestrictions("Tail",increment); mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID),(page==PAGE_PRESET1||page==PAGE_PRESET2||page==PAGE_PRESET3)); } //wings else if(iID==4) { wingID += (increment?1:-1); if(wingID<0)wingID = mDef->maxWings-1; if(wingID>=mDef->maxWings)wingID = 0; applyRestrictions("Wing",increment); mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID),(page==PAGE_PRESET1||page==PAGE_PRESET2||page==PAGE_PRESET3)); }
Scroll a bit down to find - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
Our next changes are a bit bigger. We need to add in an entire segment for what happens when the bodies are changed. You will ham-fist that biz between the first { and if(partChanged=="Head"). so the space between will go from - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Head") { //back to maneless maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); return; }
to being this - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Body") { //reset heads if(bodyID==0) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==1) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } return; }
Just like with earlier, if you have more unique bodies, add them in as a new "else if". - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Body") { //reset heads if(bodyID==0) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==1) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==2) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } return; }
and if you have more bodies but they use the same skeleton, add them with || - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Body") { //reset heads if(bodyID==0 || bodyID==1) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==2 || bodyID==3 || bodyID==4) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } return; }
notice all those meshID numbers? this is where you tell the game which mesh you want it to default to when switching bodies. for instance - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Body") { //reset heads if(bodyID==0) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 3; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==1) { headID = 1; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } return; }
with those values, when you switch from body0 to body1, the head will switch to head1 and the rest of the meshes will default to 0 (which for this particular source are blank or non-equiped slots [wingless/tuftless/tailless/etc]) and switching back to body0 will reset the head to the original one while forcing tail3 to equip. NEXT in this same code section, we need to tell the game to look for the restrictions we defined earlier. so lets add that. to every mesh. change - Quote :
- if(partChanged=="Head")
{ //back to maneless maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); return; }
to - Quote :
- if(partChanged=="Head")
{ while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { headID += (increment?1:-1); if(headID<0)headID = mDef->maxHeads-1; if(headID>=mDef->maxHeads)headID = 0; } return; }
Add in code for tails, wings. if you want to keep everything in order, squeeze them between the last } for manes and if(partChanged=="Tuft") - Quote :
- if(partChanged=="Tail")
{ while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { tailID += (increment?1:-1); if(tailID<0)tailID = mDef->maxTails-1; if(tailID>=mDef->maxTails)tailID = 0; } return; } if(partChanged=="Wing") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { wingID += (increment?1:-1); if(wingID<0)wingID = mDef->maxWings-1; if(wingID>=mDef->maxWings)wingID = 0; } return; }
Now change the restictions that manes and tuft already have so that the lines - Quote :
- while(mDef->isRestricted(headID,maneID))
and - Quote :
- while(mDef->isRestrictedTuft(tuftID))
will now both be - Quote :
- while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID))
done right, the entire section should look something akin to - Quote :
- void applyRestrictions(const String &partChanged, bool increment)
{ if(partChanged=="Body") { //reset heads if(bodyID==0) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } else if(bodyID==1) { headID = 0; mUnit->replaceHeadMesh(mSceneMgr,meshName("Head",headID)); //reset manes maneID = 0; mUnit->replaceManeMesh(mSceneMgr,meshName("Mane",maneID)); //reset tails tailID = 0; mUnit->replaceTailMesh(mSceneMgr,meshName("Tail",tailID)); //reset wings wingID = 0; mUnit->replaceWingMesh(mSceneMgr,meshName("Wing",wingID)); //reset tufts tuftID = 0; mUnit->replaceTuftMesh(mSceneMgr,meshName("Tuft",tuftID)); } return; } if(partChanged=="Head") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { headID += (increment?1:-1); if(headID<0)headID = mDef->maxHeads-1; if(headID>=mDef->maxHeads)headID = 0; } return; } if(partChanged=="Mane") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { maneID += (increment?1:-1); if(maneID<0)maneID = mDef->maxManes-1; if(maneID>=mDef->maxManes)maneID = 0; } return; } if(partChanged=="Tail") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { tailID += (increment?1:-1); if(tailID<0)tailID = mDef->maxTails-1; if(tailID>=mDef->maxTails)tailID = 0; } return; } if(partChanged=="Wing") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { wingID += (increment?1:-1); if(wingID<0)wingID = mDef->maxWings-1; if(wingID>=mDef->maxWings)wingID = 0; } return; } if(partChanged=="Tuft") { while(mDef->isRestricted(bodyID,headID,maneID,tailID,wingID,tuftID)) { tuftID += (increment?1:-1); if(tuftID<0)tuftID = mDef->maxTufts-1; if(tuftID>=mDef->maxTufts)tuftID = 0; } return; } }
Don't forget that if you have new meshes added, and want them restricted, to add them to this section too. Build that and give it a test. It was a while ago that i worked on this, so it's possible something got forgotten about. If so, let me know. |
|