Пример #1
0
Abc::C4f AlembicPoints::GetColor(IParticleObjectExt *pExt, int particleId,
                                 TimeValue ticks)
{
  Abc::C4f color(0.5, 0.5, 0.5, 1.0);

  // Go into the particle's action list
  INode *particleGroupNode = pExt->GetParticleGroup(particleId);
  Object *particleGroupObj = (particleGroupNode != NULL)
                                 ? particleGroupNode->EvalWorldState(ticks).obj
                                 : NULL;

  if (!particleGroupObj) {
    return color;
  }

  IParticleGroup *particleGroup = GetParticleGroupInterface(particleGroupObj);
  INode *particleActionListNode = particleGroup->GetActionList();
  Object *particleActionObj =
      (particleActionListNode != NULL
           ? particleActionListNode->EvalWorldState(ticks).obj
           : NULL);

  if (!particleActionObj) {
    return color;
  }

  PFSimpleOperator *pSimpleOperator = NULL;

  // In the case of multiple shape operators in an action list, the one furthest
  // down the list seems to be the one that applies
  IPFActionList *particleActionList =
      GetPFActionListInterface(particleActionObj);

  for (int p = particleActionList->NumActions() - 1; p >= 0; p -= 1) {
    INode *pActionNode = particleActionList->GetAction(p);
    Object *pActionObj =
        (pActionNode != NULL ? pActionNode->EvalWorldState(ticks).obj : NULL);

    if (pActionObj == NULL) {
      continue;
    }

    if (pActionObj->ClassID() == PFOperatorDisplay_Class_ID) {
      pSimpleOperator = static_cast<PFSimpleOperator *>(pActionObj);
      break;
    }
  }

  if (pSimpleOperator) {
    IParamBlock2 *pblock = pSimpleOperator->GetParamBlockByID(0);
    Point3 c = pblock->GetPoint3(kDisplay_color);
    color.r = c.x;
    color.g = c.y;
    color.b = c.z;
    color.a = 1.0;
  }

  return color;
}
Пример #2
0
void
ParticleMesherObject::PickPFEvents(HWND hWnd)
{
   Tab<INode *> pfEvents;
   int numberOfNodes = 1;;

   TimeValue t = GetCOREInterface()->GetTime();


   pfNodes.ZeroCount();
   addPFNodes.ZeroCount();
   

   for (int i = 0; i < numberOfNodes; i++)
      {
      INode *node;
      pblock2->GetValue(particlemesher_pick,t,node,ivalid,i);

      if (node)
         {
         ObjectState tos =  node->EvalWorldState(t,TRUE);

         if (tos.obj->IsParticleSystem())
            {
            IParticleObjectExt* epobj;
            epobj = (IParticleObjectExt*) tos.obj->GetInterface(PARTICLEOBJECTEXT_INTERFACE);
   
            if (epobj) 
               {
               MyEnumProc dep;              
               tos.obj->DoEnumDependents(&dep);
               for (int i = 0; i < dep.Nodes.Count(); i++)
                  {
                  Interval valid;
                  INode *node = dep.Nodes[i];

                  Object *obj = node->GetObjectRef();
				  IParticleGroup* iPGroup = ParticleGroupInterface(obj);
				  if (iPGroup != nullptr)
					  {
						 // we need to filter out the global action list events since
						 // they do not carry any actual particle shape geometry
						 if (iPGroup->GetParticleSystem() != iPGroup->GetActionList())
						 {
							 pfNodes.Append(1, &node);
						 }
					  }
			      }
               }

            }

         }
      }
   if (pfNodes.Count() > 0)
      {
      int iret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_ADD_DIALOG),
            hWnd,AddDlgProc,(LPARAM)this);
      if ((iret) && (addPFNodes.Count() > 0))
         {
         theHold.Begin();
         for (int i = 0; i < addPFNodes.Count(); i++)
            {
            int index = addPFNodes[i];
            INode *node = pfNodes[index];
            pblock2->Append(particlemesher_pfeventlist,1,&node);
            }
         theHold.Accept(GetString(IDS_ADDEVENTS));

         }
      }  

}
Пример #3
0
void AlembicPoints::GetShapeType(IParticleObjectExt *pExt, int particleId, TimeValue ticks, ShapeType &type, Abc::uint16_t &instanceId, float &animationTime)
{
    // Set up initial values
    type = ShapeType_Point;
    instanceId = 0;
    animationTime = 0.0f;

    // Go into the particle's action list
    INode *particleGroupNode = pExt->GetParticleGroup(particleId);
    Object *particleGroupObj = (particleGroupNode != NULL) ? particleGroupNode->EvalWorldState(ticks).obj : NULL;

	if (!particleGroupObj){
        return;
	}

    IParticleGroup *particleGroup = GetParticleGroupInterface(particleGroupObj);
    INode *particleActionListNode = particleGroup->GetActionList();
    Object *particleActionObj = (particleActionListNode != NULL ? particleActionListNode->EvalWorldState(ticks).obj : NULL);

	if (!particleActionObj){
        return;
	}
	
    PFSimpleOperator *pSimpleOperator = NULL;

	//In the case of multiple shape operators in an action list, the one furthest down the list seems to be the one that applies
    IPFActionList *particleActionList = GetPFActionListInterface(particleActionObj);
	
	for (int p = particleActionList->NumActions()-1; p >= 0; p -= 1)
	{
		INode *pActionNode = particleActionList->GetAction(p);
		Object *pActionObj = (pActionNode != NULL ? pActionNode->EvalWorldState(ticks).obj : NULL);

		if (pActionObj == NULL){
			continue;
		}

		if (pActionObj->ClassID() == PFOperatorSimpleShape_Class_ID){
			pSimpleOperator = static_cast<PFSimpleOperator*>(pActionObj);
			break;
		}else if(pActionObj->ClassID() == PFOperatorShapeLib_Class_ID){
			pSimpleOperator = static_cast<PFSimpleOperator*>(pActionObj);
			break;
		}else if(pActionObj->ClassID() == PFOperatorInstanceShape_Class_ID){
			pSimpleOperator = static_cast<PFSimpleOperator*>(pActionObj);
			break;
		}else if(pActionObj->ClassID() == PFOperatorMarkShape_Class_ID){
			pSimpleOperator = static_cast<PFSimpleOperator*>(pActionObj);
			break;
		}else if(pActionObj->ClassID() == PFOperatorFacingShape_Class_ID){
			pSimpleOperator = static_cast<PFSimpleOperator*>(pActionObj);
			break;
		}
	}

	

	for (int p = particleActionList->NumActions()-1; p >= 0; p -= 1)
	{
		INode *pActionNode = particleActionList->GetAction(p);
		Object *pActionObj = (pActionNode != NULL ? pActionNode->EvalWorldState(ticks).obj : NULL);

		if (pActionObj == NULL){
			continue;
		}

		IPFTest* pTestAction = GetPFTestInterface(pActionObj);

		if (pTestAction){
			
			INode* childActionListNode = pTestAction->GetNextActionList(pActionNode, NULL);

			if(childActionListNode){
				AlembicPoints::perActionListShapeMap_it actionListIt = mPerActionListShapeMap.find(childActionListNode);

				//create a cache entry if necessary
				if(actionListIt == mPerActionListShapeMap.end()){
					mPerActionListShapeMap[childActionListNode] = AlembicPoints::shapeInfo();
				}
				AlembicPoints::shapeInfo& sInfo = mPerActionListShapeMap[childActionListNode];
				
				if(!sInfo.pParentActionList){
					sInfo.pParentActionList = particleActionListNode;
				}
			}
		}
	}

	ReadShapeFromOperator(particleGroup, pSimpleOperator, particleId, ticks, type, instanceId, animationTime);

	if(type != ShapeType_NbElements){//write the shape to the cache

		// create cache entry for the current action list node, and then fill in the shape info
		// we will fill in the parent later

		AlembicPoints::perActionListShapeMap_it actionListIt = mPerActionListShapeMap.find(particleActionListNode);

		//create a cache entry if necessary
		if(actionListIt == mPerActionListShapeMap.end()){
			mPerActionListShapeMap[particleActionListNode] = AlembicPoints::shapeInfo();
		}
		AlembicPoints::shapeInfo& sInfo = mPerActionListShapeMap[particleActionListNode];
		
		//if(sInfo.type == ShapeType_NbElements){
		//	sInfo.type = type;
		//	sInfo.animationTime = animationTime;
		//	if(sInfo.type == ShapeType_Instance){
		//		sInfo.instanceName = mInstanceNames[instanceId];
		//	}
		//}
	}
	else{ //read the shape from the cache

		AlembicPoints::shapeInfo sInfo;
		INode* currActionNode = particleActionListNode;
		
		//search for shape along path from this node to the root node
		const int MAX_DEPTH = 10; //just in case there is an infinite loop due a bug
		int i = 0;
		while(currActionNode && sInfo.type == ShapeType_NbElements && i<MAX_DEPTH){

			AlembicPoints::perActionListShapeMap_it actionListIt = mPerActionListShapeMap.find(currActionNode);
			if(actionListIt != mPerActionListShapeMap.end()){
				sInfo = actionListIt->second;
			}

			currActionNode = sInfo.pParentActionList;
			i++;
		}

		if(sInfo.type != ShapeType_NbElements){//We have found shape, so add it to the list if necessary

			// Find if the name is alerady registered, otherwise add it to the list
			//instanceId = FindInstanceName(sInfo.instanceName);
			//if (instanceId == USHRT_MAX)
			//{
			//	mInstanceNames.push_back(sInfo.instanceName);
			//	instanceId = (Abc::uint16_t)mInstanceNames.size()-1;
			//}
			//type = sInfo.type;
		}
		else{
			int nBornIndex = pExt->GetParticleBornIndex(particleId);
			ESS_LOG_INFO("Could not determine shape type for particle with born index: "<<nBornIndex<<". Defaulting to point.");
 			type = ShapeType_Point;
		}
	}
}