Ejemplo n.º 1
0
/*
**	Update the player action.
*/
void	Bot::update(gdl::Clock const &clock, Field& map)
{
  float	add;
  int	action;

  if (_character->isDancing())
    return ;
  action = getNextAction(map);
  if (action < 0 || action == STAGN)
    {
      if (++_nbrStagnTurns > STAGN_LIMIT)
	action = PUT_BOMB;
    }
  else
    _nbrStagnTurns = 0;
  if ((add = 0.1f * static_cast<float>(clock.getElapsed()) * SPEED(_speed)) > BOT_MAX_SPEED)
    add = BOT_MAX_SPEED;
  if (action < 4)
    (_character->*_launchMove[action])(add);
  else
    {
      _character->pauseModel();
      if (action == PUT_BOMB && map.getMap()[_character->getY()][_character->getX()] == NULL && _bombs > 0)
	{
	  map.getMap()[_character->getY()][_character->getX()] = new Bomb(static_cast<int>(_character->getY()), static_cast<int>(_character->getX()), this, *map.getModels()["Bomb"]);
	  map.getMap()[_character->getY()][_character->getX()]->initialize();
	  _bombs--;
	}
    }
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
MStatus		BPT_InsertVtx::doCompleteCompute( MDataBlock& data )
//----------------------------------------------------------------------------
{

				SPEED("Berechne EdgeSplit neu: ");

				MStatus status;

				MPRINT("MACHE KOMPLETTE BERECHNUNG")



				MDataHandle inMeshHandle = data.inputValue(IVinMesh);
				MDataHandle outMeshHandle = data.outputValue(IVoutMesh);


					//splitCount setzen
				
				MDataHandle countHandle	= data.inputValue(IVcount);			
				fIVfty.setCount(countHandle.asInt());
			
				

				MDataHandle spinHandle = data.inputValue(IVspin);

				fIVfty.setSpin(spinHandle.asInt());
				

				int initialVtxCount;	//wird spueueter benueuetigt, um das ValidIndicesArray gleich in der rictigen grueueueuee zu erstellen und zu schreiben


				//gleich zu beginn muss der MeshPath initialisiert werden, damit der MeshPath an die fty ueuebergeben werden kann
				// Dies geschieht besser durch die STE - sie ist darauf ausgelegt
				softTransformationEngine::gatherAttributeObjects(thisMObject());
				softTransformationEngine::saveMeshPathes();

				

				fIVfty.setMeshPath(meshPath);
				
				
			
				MDataHandle	rHandle = data.inputValue(IVslideRelative);
				fIVfty.setRelative(rHandle.asInt());
				
				
				MDataHandle nRelativeHandle = data.inputValue(IVnormalRelative);
				fIVfty.setNormalRelative(nRelativeHandle.asInt());
				
				
				//selection setzen
				MFnIntArrayData		intDataArray;	
				
				MDataHandle arrayHandle = data.inputValue(IVselEdgeIDs);
				intDataArray.setObject(arrayHandle.data());
				
				fIVfty.setEdgeIDs( intDataArray.array() );

				arrayHandle = data.inputValue(IVselVertIDs);
				intDataArray.setObject(arrayHandle.data());

				fIVfty.setVertIDs(intDataArray.array());
				

				//				optionen holen
				
				arrayHandle = data.inputValue(IVoptions);
				intDataArray.setObject(arrayHandle.data());
				MIntArray optionsArray(intDataArray.array());
				

				fIVfty.setOptions(optionsArray);
				
				
				
				
				MDataHandle slideHandle = data.inputValue(IVslide);
				fIVfty.setSlide(slideHandle.asDouble());

				
				//whichSide attribute wird nur fueuer SLide selbst verwendet und kann nicht bereits beim command gestetzt werden
				
				


				MObject inMeshRef = inMeshHandle.asMesh();
				fIVfty.setMesh(inMeshRef);


				MFnMesh meshFn(inMeshHandle.asMesh());
				initialVtxCount = meshFn.numVertices();
				

				

				//ACTION
				try
				{
					status = fIVfty.doIt();
				}
				
				catch(...)
				{
					MGlobal::displayError(" An unknown, severe, error occoured.\nIf it happens again in this situation, please write a bug report.\nPlease undo the operation and save your work!");
					return MS::kUnknownParameter;
				}

				
				MObject newOutMesh = fIVfty.getMesh();

				
				outMeshHandle.set(newOutMesh);

				
				// ---------------------
				// SOFT TRANSFORMATION
				// ---------------------
				// VtxSet setzen - hier reicht es, wenn er einfach die neuen Vtx nimmt


				softTransformationEngine::setVtxSet(data);

		

				//------------SELECTION ROUTINE----------------------


			
				//nur wenn sich spin nicht verueuendert hat, darf ne neue selection gemacht werden - dies wird auch von der IV berueuecksichtigt
				//die selection wird nur noch einmal ausgefueuehrt, weshalb scriptJobInitiated nicht mehr gesetzt wird vom scriptjob
				if( optionsArray[6] && !scriptJobInitated && !(meshPath.apiType() == MFn::kInvalid) )
				{
						
						//auf jeden Fall erstmal die neuen Vertizen holen, damit die anderen prozeduren auch darauf arbeiten kueuennen

						//alles neuen Vertces sollen gewueuehlt werden, also einfach alle Indices eintragen vom initialVtxCount
						//bis zum jetzigen VtxCount
						MIntArray validEdges, validFaces;
						componentConverter CC(newOutMesh);

						int i = 0;


						meshFn.setObject(newOutMesh);
						int newCount = meshFn.numVertices();
						
						validIndices.clear();
						validIndices.setLength(newCount - initialVtxCount);
						
						

						for(; initialVtxCount < newCount; initialVtxCount++)
							validIndices[i++] = initialVtxCount;
						
						

					
					if(optionsArray[6] == 1 || optionsArray[6] == 2) //select edges
					{
						
						CC.getContainedEdges(validIndices,validEdges);
					}


					BPT_Helpers helper;


					if(optionsArray[6] == 2) //select Faces
					{
						CC.getConnectedFaces(validEdges,validFaces);

						//jetzt kann gleich alles beendet werden, da hiernach keine componente mehr kommt, in die man faces umwandeln mueuesste
						validIndices.clear();
						validIndices.append(2);

						
						helper.addIntArrayToLHS(validIndices,validFaces);

					}

					if(optionsArray[6] == 1)
					{//edges fertigmachen
						
						validIndices.clear();
						validIndices.append(1);

						helper.addIntArrayToLHS(validIndices,validEdges);

					}
					else if(optionsArray[6] == 5)
						validIndices.insert(3,0);


					//component Mode umschalten bei bedarf
					if(optionsArray[5])
					{
						MSelectionMask::SelectionType type = MSelectionMask::kSelectMeshVerts;
						
						if(optionsArray[6] == 5)
						{
							type = MSelectionMask::kSelectMeshVerts;
						}
						else if(optionsArray[6] == 2)
						{
							type = MSelectionMask::kSelectMeshFaces;
						}
						else if(optionsArray[6] == 1)
						{
							type = MSelectionMask::kSelectMeshEdges;
						}
						
						
						MSelectionMask mask(type);
						
						
						MGlobal:: setComponentSelectionMask(mask);
					}


					eID = MEventMessage::addEventCallback("idle",IV_makeSelection,this);

					scriptJobInitated = true;

				}
				else
				{//ansonsten muss die SelectionList neu aufgebaut werden, allerdings ohne komponenten
					//diese Aktion solte auch nur einmal ausgefueuehrt werden

					//gegenwueuertige selection holen
					MSelectionList currentList;
					MSelectionList newList;
					MGlobal::getActiveSelectionList(currentList);

					//durch die Liste iterieren und Komponenten Filtern
					MItSelectionList selIter(currentList);
					MObject currentObj;
					for( ; !selIter.isDone();selIter.next() )
					{
						
						selIter.getDependNode(currentObj);
						
						newList.add(currentObj);
					}

					MGlobal::setActiveSelectionList(newList, MGlobal::kAddToList);


		


				}


				



				return status;

}
Ejemplo n.º 3
0
MStatus	BPTfty_NH::doIt()
{

	SPEED(" MACHE NON- TOPO - CHANGE AKTION ");	

	switch(mode)
	{
	case 1:
		{
			//erstmal alle Edges holen
			MIntArray	allEdges;
			MIntArray	edgeLoops;		//enthält die fertige EL auswahl zum anwählen


			//	cout<<"MAIN: "<<"hole alle edgeIndices"<<endl;
			getAllEdgeIndices(allEdges);

			//	cout<<"MAIN: "<<"finde edgeLoops"<<endl;
			findEdgeLoops(allEdges,edgeLoops);


			//	cout<<"MAIN: "<<"Wähle Komponenten an"<<endl;
			selectComponents(edgeLoops,"edges");
			switchComponentModeIfNeeded();	

			break;

		}

		//edgeRing auswählen
	case 2:
		{
			MIntArray	allEdges;
			MIntArray	edgeRings;

			//	cout<<"MAIN: "<<"hole alle edgeIndices"<<endl;
			getAllEdgeIndices(allEdges);

			//	cout<<"MAIN: "<<"finde edgeRings"<<endl;
			findEdgeRings(allEdges,edgeRings);


			//	cout<<"MAIN: "<<"Wähle Komponenten an"<<endl;
			selectComponents(edgeRings,"edges");
			switchComponentModeIfNeeded();

			break;
		}
		//boundary erstellen
	case 3:
		{
			

			MStatus	status;
			MItMeshPolygon	polyIter(fMesh,&status);

			convertAllToFaces(polyIDs,vertIDs,edgeIDs);

			INVIS(if(status == MS::kFailure))
				INVIS(cout <<"FEHLER, fMesh ist nicht angekommen in fty"<<endl;)


			MIntArray		EdgeTmp;



			//invertSelection(polyIDs, polyIter.count(),inverted);

			faceGetContainedEdgeIndices(polyIDs, EdgeTmp);
			//faceGetContainedEdgeIndices(inverted, Edge2Tmp);


			MIntArray outline;
			helper.memoryPrune(EdgeTmp,outline);

			//outline finalisieren durch : allEdges - inner edges (in outline momentan)
			helper.memoryArrayRemove(EdgeTmp,outline);

			selectComponents(EdgeTmp,"edges");
			//selectComponents(memoryMatch(EdgeTmp,Edge2Tmp),"edges");

			switchComponentModeIfNeeded();

			break;

		}



	case 7:
		{
			MPRINT("WILL GROWEN")
			
			SPEED(" GROWING ");
			
			MItMeshVertex	vertIter(fMesh);
			MItMeshPolygon	polyIter(fMesh);
			MItMeshEdge		edgeIter(fMesh);

			if(vertIDs.length() != 0)
			{	
				growVtxSelection(vertIDs,vertIter,polyIter, true);
			}
			else if(edgeIDs.length() != 0)
			{
				growEdgeSelection(edgeIDs,edgeIter,0);
			}
			else if(polyIDs.length() != 0)
			{//jetzt muss faceIDs an der reihe sein, da ja eine auswahl vorhanden sein muss, wenn er in fty ist
				//->diese auswahl koennen aber auch UVs sein
				growFaceSelection(polyIDs,edgeIter,polyIter.count());
			}
			break;
		}
	case 8:
		{
			MPRINT("will shrinken")

			SPEED(" SHRINKING ");
				
			MItMeshVertex	vertIter(fMesh);
			MItMeshPolygon	polyIter(fMesh);
			MItMeshEdge		edgeIter(fMesh);
			MIntArray	allVtx;


			if(vertIDs.length() != 0)
			{	
				schrinkVtxSelection(vertIDs,vertIter,polyIter, true);
			}
			else if(edgeIDs.length() != 0)
			{
				shrinkEdgeSelection(edgeIDs,edgeIter,polyIter.count());
			}
			else if(polyIDs.length() != 0)
			{//jetzt muss faceIDs an der reihe sein, da ja eine auswahl vorhanden sein muss, wenn er in fty ist
				shrinkFaceSelection(polyIDs,edgeIter,polyIter.count());
			}


			break;
		}
	}
Ejemplo n.º 4
0
OP_ERROR
SOP_Rain::cookMySop(OP_Context &context)
{
    //UT_Interrupt    *boss;
    if (error() < UT_ERROR_ABORT)
    {
        //boss = UTgetInterrupt();
        //boss->opStart("Start generating rain");
        
        fpreal now = TIME(context.getTime());
        long nPoints = NPOINTS( now );
        UT_Vector3 rainDirection = RAINDIRECTION(now);
        //rainDirection.normalize(); //TODO: check for (0,0,0) vector

        RainData rain(  now,
                        nPoints, BOUNDMIN (now), BOUNDMAX (now),
                        rainDirection, 
                        DICEMIN(now), DICEMAX(now), SEED(now),
                        SPEED (now),
                        SPEEDVARIENCE (now));

        if(rain.getAllocationState() == false || isPointsNumberChanged_ == true)
        {
            rain.allocate(nPoints);
        }
        if( rain.getAllocationState() == true && 
            ( rain.getCachedState() == false || isParameterChanged_ == true ) )
        {   
            rain.computeInitialPositions();
            rain.setCachedState(true);     
        }

        if (isPointsGenerated_ == false)
        {
            printf("Generate Points procedure\n");
            gdp->clearAndDestroy();

            generatePoints(gdp, nPoints);
            isPointsGenerated_ = true;
        }
        

        for (   GA_Iterator pr_it(gdp->getPrimitiveRange());
                !pr_it.atEnd();
                ++pr_it)
        {
            GEO_Primitive* prim = gdp->getGEOPrimitive(*pr_it);
            GA_Range range = prim->getPointRange();
            rain.shiftPositions( gdp, range);            
        }


     

        //boss->opEnd();
    }
    isParameterChanged_ = false;
    isPointsNumberChanged_ = false;
    //unlockInputs();
    return error();
}