Re: [Plib-users] ssgSelector question
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2002-07-19 21:07:53
|
I find your code extremely confusing to read - I can't tell what you *intended* to do - so it's hard to be precise about what you did wrong. However, I don't think you understand what an ssgSelector does. I suspect you should be declaring a single ssgSelector, loading two models and attaching them both as children of that selector, then doing a 'selectStep(0)' or a 'selectStep(1)' to decide which of them will be rendered...but it's not clear that this is what you actually wanted to do. Allen Yang wrote: > ssgTransform *COSBranch::ReplaceShipMode(BOOL &shipMode) > { > if(m_OS == NULL) > m_OS = new ssgTransform; > > ssgModelPath ( "../data" ) ; > ssgTexturePath ( "../data" ) ; > > if (m_pStateSub == NULL ) > m_pStateSub = new ssgSelector[2]; ^^^^^^^^^^^^^^^^^^^ Do you really want TWO ssgSelectors? > OS_obj = ssgLoad3ds ("latestSEAWOLF.3DS"); > OS_obj2 = ssgLoad3ds ("02carrier.3DS"); > > > m_pStateSub[0].addKid(OS_obj); > m_pStateSub[1].addKid(OS_obj2); So now you've added one child object into each of those two selectors. Hence, you have two selectors - each with one child node. > if (!shipMode) > { > m_pStateSub->selectStep(1); ^^^^^^^^^^^^^^^^ This doesn't look right...shouldn't you be selecting one element of the array? I'd expect you to have written: m_pStateSub[0].selectStep( <something> ) ; But selectStep(1) selects a step that doesn't exist - because only step 0 has been set up for each selector??!?! > m_OS->addKid(&m_pStateSub[1]); So now you've added just one of the two selector nodes into the transform - and hence only one is every connected into the scene graph and you wasted all that effort loading the other file unnecessarily. > } > else { > m_pStateSub->selectStep(0); > > m_OS->addKid(&m_pStateSub[0]); > } > > return m_OS; > } If you only intend to load one or the other model into the scene, you don't need an ssgSelector - but if you switch between the two models at runtime, then you need to add both models into one ssgSelector - so why did you declare two of them?? I'm very confused about what you want to do. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |