HUDNavigation
Moderator: PPS-Leaders
HUDNavigation
hi there,
after another 4 hours on the HUDNavigation.cc file in /src/modules/overlays/hud in the hudelements branch im coming here now to get some help.
target: to solve the problem caused by beeing killed in game. if the humancontroller is killed and respawns the ogre-overlays for navmarkers an distance-text are not reappearing.
idea: in the constructor-method of HUDnavigation ive created a loop over all existing radarviewables currently active. i excluded the humanship itself by testing the ->isHuman_ member of the radarviewables in each turn. if the current object is not a humanplayer it should be added to the existing activeObjectList_ (which is of type map).
apparently something doesnt work so far, because the game crashes with a sigfault after the spawn-contdown reaches '1'.
it would be nice if someone of the team had a quick look on it and would contact me here ore via skype 'sfluecki'.
thanks a lot.
sebastian
after another 4 hours on the HUDNavigation.cc file in /src/modules/overlays/hud in the hudelements branch im coming here now to get some help.
target: to solve the problem caused by beeing killed in game. if the humancontroller is killed and respawns the ogre-overlays for navmarkers an distance-text are not reappearing.
idea: in the constructor-method of HUDnavigation ive created a loop over all existing radarviewables currently active. i excluded the humanship itself by testing the ->isHuman_ member of the radarviewables in each turn. if the current object is not a humanplayer it should be added to the existing activeObjectList_ (which is of type map).
apparently something doesnt work so far, because the game crashes with a sigfault after the spawn-contdown reaches '1'.
it would be nice if someone of the team had a quick look on it and would contact me here ore via skype 'sfluecki'.
thanks a lot.
sebastian
Re: HUDNavigation
as i already told you this monday you cannot do this in the constructor. (the reason is that you don't know yet which owner you have. right after the contructor of HUDNavigation "someone" calls the setOwner function and correctly sets the owner. after this the changedOwner function gets called. this is where you have to collect your radarviewables. you already have that function (changedOwner) implemented, but commented out. undo the commenting and implement the function gatherObjects (just move in the parts which you already have in you constructor).
if you still have problems you can look at HUDRadar which does exactly the same.
i hope this was understandable?!
if you still have problems you can look at HUDRadar which does exactly the same.
i hope this was understandable?!
There are only 10 types of people in the world: Those who understand binary, and those who don't.
Re: HUDNavigation
all right
es funktioniert - alle pfeile werden angezeigt, und aktualisiert,
und beim respawn korrekt neu initialisiert.
weiter im text:
problem: die textoverlays erscheinen nicht obwohl parallel mit den pfeiloverlays initialisiert.
vermutung: könnte es daran liegen, dass die setCaption funktion erst in der tick aufgerufen wird un nicht in addObject schon direkt? am ende von addOBject passiert background->addChild(text), text->setCaption wurde aber noch nicht ausgeführt.
versuch: ich habe mit:
versucht den text in der addObject funktion welche mit dem Radarviewable* 'object' aufgerufen wird zu berechnen. allerdings hat das nicth funktioniert (zum sigFault geführt), meiner meinung nach weil der Pawn noch nicht existiert und es somit ein pure virtual call ist (wird so auch von strace dokumentiert).
frage: wie muss ich das ding nun angehen so dass ich die distanz in der addOBject funktion berechnen und notieren kann so dass dies am ende funktioniert, ODER übersehe ich einen grund, weshalb die textoverlays nicht angezeigt werden?
lg seba
ps: hab den branch grad geSVNt, sollte also jetz bei euch sichtbar sein.
es funktioniert - alle pfeile werden angezeigt, und aktualisiert,
und beim respawn korrekt neu initialisiert.
weiter im text:
problem: die textoverlays erscheinen nicht obwohl parallel mit den pfeiloverlays initialisiert.
vermutung: könnte es daran liegen, dass die setCaption funktion erst in der tick aufgerufen wird un nicht in addObject schon direkt? am ende von addOBject passiert background->addChild(text), text->setCaption wurde aber noch nicht ausgeführt.
versuch: ich habe mit:
Code: Select all
int dist = (int)(object->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
text->setCaption(multi_cast<std::string>(dist));
frage: wie muss ich das ding nun angehen so dass ich die distanz in der addOBject funktion berechnen und notieren kann so dass dies am ende funktioniert, ODER übersehe ich einen grund, weshalb die textoverlays nicht angezeigt werden?
lg seba
ps: hab den branch grad geSVNt, sollte also jetz bei euch sichtbar sein.
Re: HUDNavigation
if i run it, i can see something that maybe should be the font ^^ i see some strange artifacts and i guess this is because you are setting some parameters wrong (x,width, whatever)
at the time when addObject gets called from Radar the object position and orientation and so on are not yet available. this is why you have to set these things in the tick function
i saw that you are using a bool wasOutOfView_ membervariable. you cannot use a single variable if you have multiple objects. if you want to do this, then you have to create another map/vector/list or whatever OR (better) create a struct where you have 2 pointers to the overlayelement a bool for outofview and maybe other information about radarviewables and use this struct instead of the std::pair you use now in you radarobjectmap
hope this helps
btw: i cleaned up some things in your code (you need to correctly destroy the overlayelements when you remove an object)
at the time when addObject gets called from Radar the object position and orientation and so on are not yet available. this is why you have to set these things in the tick function
i saw that you are using a bool wasOutOfView_ membervariable. you cannot use a single variable if you have multiple objects. if you want to do this, then you have to create another map/vector/list or whatever OR (better) create a struct where you have 2 pointers to the overlayelement a bool for outofview and maybe other information about radarviewables and use this struct instead of the std::pair you use now in you radarobjectmap
hope this helps
btw: i cleaned up some things in your code (you need to correctly destroy the overlayelements when you remove an object)
There are only 10 types of people in the world: Those who understand binary, and those who don't.
Re: HUDNavigation
hi there,
thanks for the cleaning part =)
with the bool outOfView i am pretty
shure to be on the right part here. if
you watch the code:
this is all in my big for(iterating throught map) so the vector pos is
in each turn set for the new radarvieable position. which now means for
each radarViewable i use a different pos-vector. the whole position setup
is in my for-loop so this should absolutely not be the problem.
what sort of grafix did u mean? i cant see any - except for somtimes i
got the feeling that the arrows are not actually arrows i guess best is
if we have a closer look on monday on this.
thx so far,
sebastian
thanks for the cleaning part =)
with the bool outOfView i am pretty
shure to be on the right part here. if
you watch the code:
Code: Select all
Vector3 pos = transform * tempRadarViewable->first->getRVWorldPosition();
bool outOfView;
if (pos.z > 1.0)
in each turn set for the new radarvieable position. which now means for
each radarViewable i use a different pos-vector. the whole position setup
is in my for-loop so this should absolutely not be the problem.
what sort of grafix did u mean? i cant see any - except for somtimes i
got the feeling that the arrows are not actually arrows i guess best is
if we have a closer look on monday on this.
thx so far,
sebastian
Re: HUDNavigation
i must went throught what you wrote into the destructor:
does this make sense? in the map
key: radarvieable,
value: pair<paneloverlay, textoverlay>
the expression it->first will in my opinion point on the key itself type radarviewable, so you are going to destroy that? i guess this is redundant with activeObjectList.clear() which also erases all objects of the map?
if yo uwant to destroy the overlay i would say we have to point to
and afterwards clean up the objects out of the map with map.clear().
if i am wrong please correct me... but as the code is now i dont see the sensee in it.
thanks for the help
sebastian
Code: Select all
activeObjectListType::iterator it;
for( it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it )
{
removeObject(it->first);
}
activeObjectList_.clear();
key: radarvieable,
value: pair<paneloverlay, textoverlay>
the expression it->first will in my opinion point on the key itself type radarviewable, so you are going to destroy that? i guess this is redundant with activeObjectList.clear() which also erases all objects of the map?
if yo uwant to destroy the overlay i would say we have to point to
Code: Select all
it->second->first (object->value.paneloverlay)
it->second->second (object->value.textoverlay)
if i am wrong please correct me... but as the code is now i dont see the sensee in it.
thanks for the help
sebastian
Re: HUDNavigation
i can't really help you there, but just a note: if you store pointers in a map and you destroy (or clear) the map, the pointers will be lost, but the "real" objects (in this case the overlays) won't be deleted. so you have to delete the objects before you clear the map.
Fabian 'x3n' Landau, Orxonox developer
Re: HUDNavigation
but i dont want to delete the objects?? i have a number of enemy ships and the pointers pointx3n wrote:i can't really help you there, but just a note: if you store pointers in a map and you destroy (or clear) the map, the pointers will be lost, but the "real" objects (in this case the overlays) won't be deleted. so you have to delete the objects before you clear the map.
to them. there is no reason in deleting the ships themselves i just want to kill the pointers.
anyways: i just testet ingame and have a question. what exactly did you mean by cleaning up the code?
because since that new svn update i have with each respawn a ugly huge arrow-shaped overlay
pointing to the human ship itselv covering 15% of my screen.
this was not there before your commit - any chance of knowing where it came from?
cheers
sebastian
Re: HUDNavigation
well I guess you (and oli) worked on this today, but i still want to give you an answer on this.sfluecki wrote:but i dont want to delete the objects?? i have a number of enemy ships and the pointers pointx3n wrote:i can't really help you there, but just a note: if you store pointers in a map and you destroy (or clear) the map, the pointers will be lost, but the "real" objects (in this case the overlays) won't be deleted. so you have to delete the objects before you clear the map.
to them. there is no reason in deleting the ships themselves i just want to kill the pointers.
your map looks like this:
Code: Select all
typedef std::map<RadarViewable*, objectStruct > activeObjectListType;
activeObjectListType activeObjectList_;
Code: Select all
struct objectStruct{
Ogre::PanelOverlayElement* panel_;
Ogre::TextAreaOverlayElement* text_;
bool outOfView_;
bool wasOutOfView_;
};
and now look what the function "removeObject" in your destructor does: it deletes panel_ and text_. that's exactly what i just said and therefore it works as intended. it->first (the SpaceShip) isn't deleted - it's just the key for the map.
however there's still a problem in the code, because removeObject calls "activeObjectList_.erase(viewable);" while the for-loop in the destructor iterates through the list. this is wrong and can lead to a crash. this should fix it:
Code: Select all
HUDNavigation::~HUDNavigation()
{
if (this->isInitialized())
{
for (activeObjectListType::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); )
removeObject((it++)->first);
}
}
Code: Select all
HUDNavigation::~HUDNavigation()
{
if (this->isInitialized())
{
while (activeObjectList_.size() > 0)
removeObject(activeObjectList_.begin()->first);
}
}
Fabian 'x3n' Landau, Orxonox developer
Re: HUDNavigation
I fixed that it++ issue this afternoon.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Re: HUDNavigation
that's interesting, because the issue is still there. looks like revision 6914 reverted this particular change.1337 wrote:I fixed that it++ issue this afternoon.
Fabian 'x3n' Landau, Orxonox developer
Re: HUDNavigation
So, somebody has overridden my changes I guess. How did that happen? It cannot be SVN, it has to be done forcefully.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Re: HUDNavigation
maybe there was a conflict when updating to the current version which hasn't been solved thoroughly... i don't think this was deliberately
There are only 10 types of people in the world: Those who understand binary, and those who don't.
Re: HUDNavigation
Certainly not actually deliberate. But accidentally delibrate ^^
SVN would not just allow such an action just like that, that's all I wanted to say.
SVN would not just allow such an action just like that, that's all I wanted to say.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Re: HUDNavigation
Fixed it again.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Who is online
Users browsing this forum: No registered users and 1 guest