Exemplo n.º 1
0
void CreatureWeaponAnimation::showCarriedLeft(bool show)
{
    if (show != mShowCarriedLeft)
    {
        mShowCarriedLeft = show;
        updateParts();
    }
}
Exemplo n.º 2
0
void QtnPropertyWidget::setParts(QtnPropertyWidgetParts newParts)
{
    if (m_parts == newParts)
        return;

    m_parts = newParts;
    updateParts();
}
Exemplo n.º 3
0
void CreatureWeaponAnimation::showWeapons(bool showWeapon)
{
    if (showWeapon != mShowWeapons)
    {
        mShowWeapons = showWeapon;
        updateParts();
    }
}
Exemplo n.º 4
0
void NpcAnimation::runAnimation(float timepassed)
{
    if(timeToChange > .2)
    {
        timeToChange = 0;
        updateParts();
    }
    timeToChange += timepassed;

    Animation::runAnimation(timepassed);
}
Exemplo n.º 5
0
void GunTower::onUpdate(float frametime)
{
	move(-EntityManager::FOREGROUND_SPEED * frametime, 0.f);
	updateParts(frametime);

	// Rotate turret toward player
	Part& turret = getPartAt(0);
	if (!turret.isDead())
	{
		turret.setRotation(180 - math::to_degrees(math::angle(getPosition(), m_target->getPosition())));
		m_weapon.shoot(m_target->getCenter());
	}
}
void ViewSimple2D::simulate( float dt )
{
	int i;

	GameView::simulate( dt );

	// update display text
	if (m_lastComboAge < COMBO_DISPLAY_TIME) {
		m_lastComboAge += dt;
	}

	// update animated pumpkins	-- TODO: make this its own func.
	std::vector<PumpkinAnim> keep;
	for (i = 0; i < m_panim.size(); i++) {
		m_panim[i].m_pos += m_panim[i].m_vel * dt;
		m_panim[i].m_vel += vec2f( 0.0, -400.0) * dt; // gravity

		// remove offscreen panim
		if ( (m_panim[i].m_pos[0] < -100) ||
			 (m_panim[i].m_pos[0] > 900) ||
			 (m_panim[i].m_pos[1] < -100) ||
			 (m_panim[i].m_pos[1] > 800) ) {
			// don't keep
		} else {
			keep.push_back( m_panim[i] );
		}
	}

	// Add some burny bits
	m_burntime += dt;
	if (m_burntime > BURN_ADD_TIME) {
		m_burntime -= BURN_ADD_TIME;
		for (int i=0; i < MACHINE_SLOTS; i++) {
			if (m_game->getPumpkin(i).m_burning) {
				emitParts( 4, calcPosFromNdx( i ), PART_FIRE );
			}
		}
	}

	// update particles
	updateParts( dt );

	m_panim = keep;
}
Exemplo n.º 7
0
/*
 * StatusWndSetSeparators - set the separator list
 */
void StatusWndSetSeparators( statwnd *sw, int num_items, status_block_desc *list )
{
    int     i;

    if( num_items > MAX_SECTIONS ) {
        num_items = MAX_SECTIONS;
    }
    for( i = 0; i < num_items; i++ ) {
        sw->sectionDesc[i] = list[i];
    }
    sw->numSections = num_items;

#ifdef __NT__
    if( IsCommCtrlLoaded() && sw->win != NULL ) {
        updateParts( sw );
    }
#endif

} /* StatusWndSetSeparators */
Exemplo n.º 8
0
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
{
    if(mTimeToChange <= 0.0f)
    {
        mTimeToChange = 0.2f;
        updateParts();
    }
    mTimeToChange -= timepassed;

    Ogre::Vector3 ret = Animation::runAnimation(timepassed);
    const Ogre::SkeletonInstance *skelsrc = mEntityList.mSkelBase->getSkeleton();
    for(size_t i = 0;i < sPartListSize;i++)
    {
        Ogre::Entity *ent = mEntityParts[i].mSkelBase;
        if(!ent) continue;
        updateSkeletonInstance(skelsrc, ent->getSkeleton());
        ent->getAllAnimationStates()->_notifyDirty();
    }
    return ret;
}
Exemplo n.º 9
0
CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const std::string& model, Resource::ResourceSystem* resourceSystem)
    : Animation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), resourceSystem)
    , mShowWeapons(false)
    , mShowCarriedLeft(false)
{
    MWWorld::LiveCellRef<ESM::Creature> *ref = mPtr.get<ESM::Creature>();

    if(!model.empty())
    {
        setObjectRoot(model, true, false, true);

        if((ref->mBase->mFlags&ESM::Creature::Bipedal))
            addAnimSource("meshes\\xbase_anim.nif");
        addAnimSource(model);

        mPtr.getClass().getInventoryStore(mPtr).setListener(this, mPtr);

        updateParts();
    }

    mWeaponAnimationTime = boost::shared_ptr<WeaponAnimationTime>(new WeaponAnimationTime(this));
}
Exemplo n.º 10
0
CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr)
    : Animation(ptr, ptr.getRefData().getBaseNode())
    , mShowWeapons(false)
    , mShowCarriedLeft(false)
{
    MWWorld::LiveCellRef<ESM::Creature> *ref = mPtr.get<ESM::Creature>();

    std::string model = ptr.getClass().getModel(ptr);
    if(!model.empty())
    {
        setObjectRoot(model, false);
        setRenderProperties(mObjectRoot, RV_Actors, RQG_Main, RQG_Alpha);

        if((ref->mBase->mFlags&ESM::Creature::Bipedal))
            addAnimSource("meshes\\base_anim.nif");
        addAnimSource(model);

        mPtr.getClass().getInventoryStore(mPtr).setListener(this, mPtr);

        updateParts();
    }
}
Exemplo n.º 11
0
void NpcAnimation::forceUpdate ()
{
    updateParts();
}
Exemplo n.º 12
0
	TYPE_CASE_(action, SymbolPartAction) {
		symbol_preview.up_to_date = false;
		// some part changed, but we don't know which one, assume it is the selection
		updateParts(selection.get());
		return;
	}
Exemplo n.º 13
0
 virtual void equipmentChanged() { updateParts(); }
Exemplo n.º 14
0
double partwwwPot(struct parameters *par,struct systemPos pos,int *part, int *atomsInPart,int calcForces,int updatePart,int returnRealPot,double updateTreshold){
  static int firsttime=1;
  static int *partSkin; /*part skin is larger than part, it also contains a skin so that the correct forces &pots can be calculated*/
  static int *partSkinTemp;
  int *partSkinBackup;
  static int atomsInPartSkin;
  static int atomsInPartSkinTemp;
  int atomsInPartSkinBackup;
  int i,j,ip;
  double partSkinPot=0.0;
  struct bondList *blist;
  getBondList(&blist);
  
  if(firsttime){
    partSkin=malloc(sizeof(int)*pos.nAtoms);
    partSkinTemp=malloc(sizeof(int)*pos.nAtoms);
    atomsInPartSkin=0;
    firsttime=0;
  }
  

  if(updatePart && returnRealPot)
    updateParts(par,pos,part,partSkin,atomsInPart,(&atomsInPartSkin),1,1); 
  else if(updatePart)
    updateParts(par,pos,part,partSkin,atomsInPart,(&atomsInPartSkin),0,1);
  /*  update partSkin so that it contains all atoms interacting, or that used  to interact with part, part unchanged, look at treshold... */
  else if(returnRealPot)
    updateParts(par,pos,part,partSkin,atomsInPart,(&atomsInPartSkin),1,0);


  if(returnRealPot){
    /*if part large it is actually faster just to calculate the whole energy of the system, this particular value is just a guess.. */
    if((double)*atomsInPart/pos.nAtoms>0.5) 
      return wwwPot(par,pos,calcForces);
    /* 
       after this 
       update partSkinTemp so that it contains all atoms interacting with partSkin
       partSkin uncchanged,
    */
	 
    updateParts(par,pos,partSkin,partSkinTemp,(&atomsInPartSkin),(&atomsInPartSkinTemp),0,0);
	 
    /* now we save the old partskin and use the larger partskin, this makes sure that the results are correct.. (the pair forces are then correct in old partskin) */
    partSkinBackup=partSkin;	  /* save pointer */
    atomsInPartSkinBackup=	atomsInPartSkin;  /* save size*/ 
    partSkin=partSkinTemp;		  /* put partskin to point to temporary list */
    atomsInPartSkin=atomsInPartSkinTemp;
  }

  /* One would think that it would be enough to put the forces at part to zero but this leads to some small errors... why? have no idea, there might be some bug somewhere? */

  if(calcForces)
    memset(pos.xa,0,sizeof(double)*3*pos.nAtoms);
  
  for(ip=0;ip<atomsInPartSkin;ip++){
    i=partSkin[ip];
    pos.enPot[i]=0.0;
  }
  
  
  /*calculate forces*/
  
  if(wwwPar.includeKeatingPot==1)  /*dont know why one would want to exclude this part but...*/
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,keatingInnerLoop);
 
  else if(wwwPar.includeKeatingPot==2 )  /*simplified keating */
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,simpKeatingInnerLoop);
  
  else if(wwwPar.includeKeatingPot==3) {
	 if(checkNgbrUpdatePart(&nd,pos,par,partSkin,atomsInPartSkin)){
		updateNgbrsPart(&nd,pos,par,partSkin,atomsInPartSkin);
	 }
	 partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,stixInnerLoop); 
  }
  
  if(wwwPar.includeRepPot){
    if(checkNgbrUpdatePart(&nd,pos,par,partSkin,atomsInPartSkin)){
      updateNgbrsPart(&nd,pos,par,partSkin,atomsInPartSkin);
      nonNnNgbrsPart(&nd,pos.nAtoms,partSkin,atomsInPartSkin); /*tkaes away first and scond ngbrs that are bonded*/
    }
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,repulsiveInnerLoop);
  }

  if(wwwPar.includeSnnRep){
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,tabulatedRepulsiveInnerLoop);
  }


  if(wwwPar.includeSuboxidePot)
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,suboxideInnerLoop);
  if(wwwPar.includeDanglbondPot)
    partSkinPot+=partLoop(par,pos,partSkin,atomsInPartSkin,calcForces,danglBondsInnerLoop);
  
  /*put forces to zero at atoms which are fixed*/
  for(ip=0;ip<atomsInPartSkin;ip++){
    i=partSkin[ip];
	 if(pos.aFlag[i]==FIXED_FLAG){
		pos.xa[i]=0;
		pos.ya[i]=0;
		pos.za[i]=0;
	 }
  }
  
  /*now we have to fix the pot values so that tey are correct for each atom in the whole system*/
  if(returnRealPot){
    double totPot=0;


    if(wwwPar.includeRingPot)
      totPot+=wwwPar.ringPenaltyEnergy; /*increase pot value, this is not included in enPot[] */ 

    partSkin=partSkinBackup;	  /* restore pointer */
    atomsInPartSkin=atomsInPartSkinBackup;  /* restore size*/ 
	 
    ip=0;	 
    for(i=0;i<pos.nAtoms;i++){
      j=partSkin[ip];
      if(i==j){						  /* i is in partskin */
		  if(ip<atomsInPartSkin)
			 ip++;						  /* next time we check against the following one in the list */
      }

      else
		  pos.enPot[i]=pos.prevEnPot[i]; /* outside partskin, near partskin the potentials are polluted, copy old correct vaalues here */
      totPot+=pos.enPot[i];
    }
    return totPot;
  }
  return partSkinPot;
}
Exemplo n.º 15
0
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly)
  : Animation(ptr),
    mStateID(-1),
    mTimeToChange(0),
    mVisibilityFlags(visibilityFlags),
    mRobe(inv.end()),
    mHelmet(inv.end()),
    mShirt(inv.end()),
    mCuirass(inv.end()),
    mGreaves(inv.end()),
    mPauldronL(inv.end()),
    mPauldronR(inv.end()),
    mBoots(inv.end()),
    mPants(inv.end()),
    mGloveL(inv.end()),
    mGloveR(inv.end()),
    mSkirtIter(inv.end()),
    mHeadOnly(headOnly)
{
    mNpc = mPtr.get<ESM::NPC>()->mBase;

    for(size_t i = 0;i < sPartListSize;i++)
    {
        mPartslots[i] = -1;  //each slot is empty
        mPartPriorities[i] = 0;
    }

    const MWWorld::ESMStore &store =
        MWBase::Environment::get().getWorld()->getStore();
    const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);

    float scale = race->mData.mHeight.mMale;
    if(!mNpc->isMale())
        scale = race->mData.mHeight.mFemale;
    node->scale(Ogre::Vector3(scale));

    mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel;
    mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel;

    mBodyPrefix = "b_n_" + mNpc->mRace;
    Misc::StringUtils::toLower(mBodyPrefix);

    bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
    std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");

    createEntityList(node, smodel);
    for(size_t i = 0;i < mEntityList.mEntities.size();i++)
    {
        Ogre::Entity *base = mEntityList.mEntities[i];

        base->getUserObjectBindings().setUserAny(Ogre::Any(-1));
        if (mVisibilityFlags != 0)
            base->setVisibilityFlags(mVisibilityFlags);

        for(unsigned int j=0; j < base->getNumSubEntities(); ++j)
        {
            Ogre::SubEntity* subEnt = base->getSubEntity(j);
            subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
        }
    }

    std::vector<std::string> skelnames(1, smodel);
    if(!mNpc->isMale() && !isBeast)
        skelnames.push_back("meshes\\base_anim_female.nif");
    else if(mBodyPrefix.find("argonian") != std::string::npos)
        skelnames.push_back("meshes\\argonian_swimkna.nif");
    if(mNpc->mModel.length() > 0)
        skelnames.push_back("meshes\\"+Misc::StringUtils::lowerCase(mNpc->mModel));
    setAnimationSources(skelnames);

    updateParts(true);
}
Exemplo n.º 16
0
	TYPE_CASE(action, SymbolPartsAction) {
		symbol_preview.up_to_date = false;
		updateParts(action.parts);
		if (true) return;
	}
Exemplo n.º 17
0
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& _inv, int visibilityFlags)
    : Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags),
    robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()),
    cuirass(mInv.end()), greaves(mInv.end()),
    leftpauldron(mInv.end()), rightpauldron(mInv.end()),
    boots(mInv.end()),
    leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()),
    pants(mInv.end())
{
    MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();

    for (int init = 0; init < 27; init++)
    {
        mPartslots[init] = -1;  //each slot is empty
        mPartPriorities[init] = 0;
    }

    const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
    const ESM::Race *race = store.races.find(ref->base->mRace);

    std::string hairID = ref->base->mHair;
    std::string headID = ref->base->mHead;
    headModel = "meshes\\" + store.bodyParts.find(headID)->mModel;
    hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel;
    npcName = ref->base->mName;

    isFemale = !!(ref->base->mFlags&ESM::NPC::Female);
    isBeast = !!(race->mData.mFlags&ESM::Race::Beast);

    bodyRaceID = "b_n_"+ref->base->mRace;
    std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);


    mInsert = node;
    assert(mInsert);

    std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");

    mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel);
    for(size_t i = 0;i < mEntityList.mEntities.size();i++)
    {
        Ogre::Entity *base = mEntityList.mEntities[i];

        base->getUserObjectBindings ().setUserAny (Ogre::Any(-1));

        base->setVisibilityFlags(mVisibilityFlags);
        bool transparent = false;
        for(unsigned int j=0;j < base->getNumSubEntities();++j)
        {
            Ogre::MaterialPtr mat = base->getSubEntity(j)->getMaterial();
            Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
            while (techIt.hasMoreElements())
            {
                Ogre::Technique* tech = techIt.getNext();
                Ogre::Technique::PassIterator passIt = tech->getPassIterator();
                while (passIt.hasMoreElements())
                {
                    Ogre::Pass* pass = passIt.getNext();
                    if (pass->getDepthWriteEnabled() == false)
                        transparent = true;
                }
            }
        }
        base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
    }

    if(mEntityList.mSkelBase)
    {
        Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
        Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
        while(as.hasMoreElements())
        {
            Ogre::AnimationState *state = as.getNext();
            state->setEnabled(true);
            state->setLoop(false);
        }
    }

    float scale = race->mData.mHeight.mMale;
    if (isFemale) {
        scale = race->mData.mHeight.mFemale;
    }
    mInsert->scale(scale, scale, scale);

    updateParts();
}
Exemplo n.º 18
0
 void forceUpdate()
 { updateParts(true); }
Exemplo n.º 19
0
/*
 * StatusWndCreate - create the status window
 */
HWND StatusWndCreate( statwnd *sw, HWND parent, WPI_RECT *size, WPI_INST hinstance,
                      LPVOID lpvParam )
{
#ifndef __OS2_PM__
    /* Win16 and Win32 version of creation */
    currentStatWnd = sw;
#ifdef __NT__
    if( IsCommCtrlLoaded() ) {
        sw->win = CreateWindow( STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE |
                                WS_CLIPSIBLINGS | SBARS_SIZEGRIP,
                                0, 0, 0, 0, parent, NULL, hinstance, NULL );
        GetWindowRect( sw->win, size );
        if( sw->numSections > 0 ) {
            updateParts( sw );
        }
  #ifndef _WIN64
    } else if( LOBYTE( LOWORD( GetVersion() ) ) < 4 ) {
        sw->win = CreateWindow( className, NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
                                size->left, size->top, size->right - size->left,
                                size->bottom - size->top, parent, (HMENU)NULL, hinstance,
                                lpvParam );
  #endif
    } else {
        sw->win = CreateWindow( className, NULL, WS_CHILD, size->left, size->top,
                                size->right - size->left, size->bottom - size->top, parent,
                                (HMENU)NULL, hinstance, lpvParam );
    }
#else
    sw->win = CreateWindow( className, NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
                            size->left, size->top, size->right - size->left,
                            size->bottom - size->top, parent, (HMENU)NULL, hinstance,
                            lpvParam );
#endif
    if( sw->win != NULL ) {
#ifdef __NT__
  #ifndef _WIN64
       if( LOBYTE( LOWORD( GetVersion() ) ) < 4 ) {
           systemDataFont = (HFONT)GetStockObject( SYSTEM_FONT );
       } else {
  #endif
           /* New shell active, Win95 or later */
           systemDataFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT );
  #ifndef _WIN64
       }
  #endif
#endif
        ShowWindow( sw->win, SW_SHOWNORMAL );
        UpdateWindow( sw->win );
    }
#else
    /* OS/2 PM version of creation */
    ULONG       flags;

    hinstance = hinstance;
    lpvParam = lpvParam;
    flags = FCF_BORDER;
    currentStatWnd = sw;

    sw->win = WinCreateStdWindow( parent, WS_VISIBLE, &flags, className, "", 0L,
                                  (HMODULE)0, 10, NULL );
    if( sw->win != NULLHANDLE ) {
        WinSetWindowPos( sw->win, HWND_TOP, size->xLeft, size->yBottom,
                         size->xRight - size->xLeft, size->yTop - size->yBottom,
                         SWP_SIZE | SWP_MOVE | SWP_SHOW );
    }
#endif

    sw->wndHeight = _wpi_getheightrect( *size );
    return( sw->win );

} /* StatusWndCreate */