BOOL plFootstepSoundComponentProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = pm->GetParamBlock();
    HWND hSurface = GetDlgItem(hWnd, IDC_COMP_FOOTSTEP_SOUND_SURFACE);
    HWND hPick = GetDlgItem(hWnd, IDC_COMP_FOOTSTEP_SOUND_PICK);
    INode *curPick = nil;
    int curSurface = 0;

    switch (msg)
    {
    case WM_INITDIALOG:
        {
            int i;
            for (i = 0; i < plArmatureEffectsMgr::kMaxSurface; i++)
                ComboBox_AddString(hSurface, plArmatureEffectsMgr::SurfaceStrings[i]);

            curSurface = pb->GetInt(ParamID(plFootstepSoundComponent::kSurface));
            ComboBox_SetCurSel(hSurface, curSurface);

            curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curSurface);
            Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
        }
        return TRUE;


    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_COMP_FOOTSTEP_SOUND_PICK)
            {
                std::vector<Class_ID> cids;
                cids.push_back(RANDOM_SOUND_COMPONENT_ID);
                if (plPick::NodeRefKludge(pb, plFootstepSoundComponent::kNodePicker, &cids, true, false))           
                {
                    curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kNodePicker));
                    curSurface = pb->GetInt(ParamID(plFootstepSoundComponent::kSurface));
                    pb->SetValue(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curPick, curSurface); 
                    Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
                }
            
                return TRUE;
            }
        }
        else if (LOWORD(wParam) == IDC_COMP_FOOTSTEP_SOUND_SURFACE)
        {
            curSurface = ComboBox_GetCurSel(hSurface);
            curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curSurface);
            pb->SetValue(ParamID(plFootstepSoundComponent::kSurface), 0, curSurface);
            Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
        }
    }

    return FALSE;
}
Beispiel #2
0
BOOL    plPlasmaAnimSelectDlgProc::DlgProc( TimeValue t, IParamMap2 *pmap, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch ( msg )
    {
        case WM_INITDIALOG:
            {
                IParamBlock2 *pb = pmap->GetParamBlock();

                INode *node = pb->GetINode( fParamID );
                TSTR newName( node ? node->GetName() : "Pick" );
                ::SetWindowText( ::GetDlgItem( hWnd, fDlgItem ), newName );

                IUpdateNodeBtn( hWnd, pb );
            }
            break;

        case WM_COMMAND:
            if( ( HIWORD( wParam ) == BN_CLICKED ) )
            {
                if( LOWORD( wParam ) == fDlgItem )
                {
                    IParamBlock2 *pb = pmap->GetParamBlock();
                    plPlasmaAnimHitCallback hitCB( pb, fParamID, fTitle );
                    GetCOREInterface()->DoHitByNameDialog( &hitCB );

                    INode *node = pb->GetINode( fParamID );
                    TSTR newName( node ? node->GetName() : "Pick" );
                    ::SetWindowText( ::GetDlgItem(hWnd, fDlgItem ), newName );
                    pmap->Invalidate( fParamID );
                    ::InvalidateRect( hWnd, NULL, TRUE );

                    IUpdateNodeBtn( hWnd, pb );
                    return true;
                }
                else if( fUseNode && LOWORD( wParam ) == fNodeDlgItem )
                {
                    IParamBlock2 *pb = pmap->GetParamBlock();

                    plAnimObjInterface *iface = plAnimComponentBase::GetAnimInterface( pb->GetINode( fParamID ) );
                    iface->PickTargetNode( pb, fNodeParamID, fTypeParamID );

                    IUpdateNodeBtn( hWnd, pb );
                    return true;
                }
            }
            break;
    }

    if( fChain != nil )
        return fChain->DlgProc( t, pmap, hWnd, msg, wParam, lParam );

    return false;
}
BOOL OrientConstRotation::AppendTarget(INode *target, float weight){

	if (target == NULL){
		float var = 50.0f;
		int ct = pblock->Count(orientation_target_list);
		int ctf = pblock->Count(orientation_target_weight);
		theHold.Begin();
		pblock->SetCount(orientation_target_list, ct + 1);
		pblock->SetValue(orientation_target_list, GetCOREInterface()->GetTime(), target, ct);
		pblock->Append(orientation_target_weight, 1, &var, 1);
		theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
		return TRUE;
	}
	else if (!(target->TestForLoop(FOREVER,(ReferenceMaker *) this)!=REF_SUCCEED)) 
	{
		for (int i = 0; i < pblock->Count(orientation_target_list); i++){
			if (target == pblock->GetINode(orientation_target_list, GetCOREInterface()->GetTime(), i)){
				return FALSE; // the target is already in the targetlist
			}
		}
			
		theHold.Begin();
		pblock->Append(orientation_target_list, 1, &target, 1);
		pblock->Append(orientation_target_weight, 1, &weight, 1);
		theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
		return TRUE;
	}
	return FALSE;


}
plComponentBase *ResponderGetActivator(plComponentBase *comp, int idx)
{
    if (comp->ClassID() == RESPONDER_CID)
    {
        IParamBlock2 *pb = comp->GetParamBlockByID(plComponentBase::kBlkComp);
        plMaxNode *activatorNode = (plMaxNode*)pb->GetINode(kResponderActivators, 0, idx);
        return activatorNode->ConvertToComponent();
    }

    return nil;
}
Beispiel #5
0
 void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t)
 {
     if (id == plLODAvatarComponent::kMeshNodeAddBtn)
     {
         plLODAvatarComponent *comp = (plLODAvatarComponent *)owner;
         IParamBlock2 *pb = comp->GetParamBlockByID(plLODAvatarComponent::kBlkComp);
         int LodBeginState = pb->GetInt(plLODAvatarComponent::kLODState);
             
         INode *node = pb->GetINode(plLODAvatarComponent::kMeshNodeAddBtn, t);
         if (node)
             pb->SetValue(plLODAvatarComponent::kMeshNodeTab, t, node, LodBeginState);
     }
 }
Beispiel #6
0
 void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t)
 {
     if (id == plClothingComponent::kMeshNodeAddBtn)
     {
         plClothingComponent *comp = (plClothingComponent *)owner;
         IParamBlock2 *pb = comp->GetParamBlockByID(plClothingComponent::kBlkComp);
         int state = pb->GetInt(plClothingComponent::kLODState);
             
         INode *node = pb->GetINode(plClothingComponent::kMeshNodeAddBtn);
         if (node)
             pb->SetValue(plClothingComponent::kMeshNodeTab, 0, node, state);
     }
         
     if (id == plClothingComponent::kMeshNodeTab)
     {
         plComponentBase *comp = (plComponentBase*)owner;
         comp->NotifyDependents(FOREVER, PART_ALL, REFMSG_USER_COMP_REF_CHANGED);
     }
 }
Beispiel #7
0
    void UpdateBoneDisplay(IParamMap2 *pm)
    {
        HWND hWnd = pm->GetHWnd();
        HWND hList = GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_BONELIST);
        IParamBlock2 *pb = pm->GetParamBlock();
            
        ListBox_ResetContent(hList);
        int group = fComp->GetCurGroupIdx();
        int startIdx = fComp->GetStartIndex(group);
        int endIdx = fComp->GetEndIndex(group);

        while (startIdx < endIdx)
        {
            INode *curNode = pb->GetINode(ParamID(plLODAvatarComponent::kBoneList), 0, startIdx);
            if (curNode == nil)
            {
                fComp->RemoveBone(startIdx);
                endIdx--;
                continue;
            }
            ListBox_AddString(hList, curNode->GetName());
            startIdx++;
        }
    }
Beispiel #8
0
plLayerInterface    *plLayerConverter::IConvertCameraLayer(plPlasmaMAXLayer *layer, 
                                                           plMaxNode *maxNode, uint32_t blendFlags, 
                                                           bool preserveUVOffset, bool upperLayer)
{
    hsGuardBegin( "plLayerConverter::IConvertCameraLayer" );

    IParamBlock2        *pb;
    plLocation          loc;

    loc = maxNode->GetLocation();
    pb = layer->GetParamBlockByID(plMAXCameraLayer::kBlkMain);

    if (!pb)
    {
        fErrorMsg->Set(!pb, "Plasma Layer Error", "Paramblock for Plasma Camera Layer not found" ).Show();
        fErrorMsg->Set();
        return nil;
    }

    plLayer *plasmaLayer = ICreateLayer (plString::FromUtf8(layer->GetName()), upperLayer, loc);

    plMaxNode *rootNode = (plMaxNode*)pb->GetINode(ParamID(plMAXCameraLayer::kRootNode));
    plDynamicCamMap *map = plEnvMapComponent::GetCamMap(rootNode ? rootNode : maxNode);
    if (map)
    {
        int32_t texFlags = 0;
        if (!pb->GetInt(ParamID(plMAXCameraLayer::kExplicitCam)))
        {
            plasmaLayer->SetUVWSrc(plLayerInterface::kUVWPosition);
            plasmaLayer->SetMiscFlags(hsGMatState::kMiscCam2Screen | hsGMatState::kMiscPerspProjection);
            hsgResMgr::ResMgr()->AddViaNotify(rootNode->GetSceneObject()->GetKey(), new plGenRefMsg(map->GetKey(), plRefMsg::kOnCreate, -1, plDynamicCamMap::kRefRootNode), plRefFlags::kActiveRef);
            hsgResMgr::ResMgr()->AddViaNotify(plasmaLayer->GetKey(), new plGenRefMsg(map->GetKey(), plRefMsg::kOnCreate, -1, plDynamicCamMap::kRefMatLayer), plRefFlags::kActiveRef);
            if (!pb->GetInt(ParamID(plMAXCameraLayer::kForce)))
            {
                plBitmap *disableTexture = hsMaterialConverter::Instance().GetStaticColorTexture(pb->GetColor(ParamID(plMAXCameraLayer::kDisableColor)), loc);
                hsgResMgr::ResMgr()->AddViaNotify(disableTexture->GetKey(), new plGenRefMsg(map->GetKey(), plRefMsg::kOnCreate, -1, plDynamicCamMap::kRefDisableTexture), plRefFlags::kActiveRef);
            }
        }
        else
        {
            plMaxNode *camNode = (plMaxNode*)pb->GetINode(ParamID(plMAXCameraLayer::kCamera));
            if (camNode)
            {
                const plCameraModifier1 *mod = plCameraModifier1::ConvertNoRef(camNode->GetSceneObject()->GetModifierByType(plCameraModifier1::Index()));
                if (mod)
                    hsgResMgr::ResMgr()->AddViaNotify(mod->GetKey(), new plGenRefMsg(map->GetKey(), plRefMsg::kOnCreate, -1, plDynamicCamMap::kRefCamera), plRefFlags::kActiveRef);
            }

            plasmaLayer->SetUVWSrc(pb->GetInt(ParamID(plMAXCameraLayer::kUVSource)));
        }

        hsTArray<plMaxNode*> nodeList;
        hsMaterialConverter::GetNodesByMaterial(maxNode->GetMtl(), nodeList);
        int i;
        for (i = 0; i < nodeList.GetCount(); i++)
        {
            hsgResMgr::ResMgr()->AddViaNotify(nodeList[i]->GetSceneObject()->GetKey(), new plGenRefMsg(map->GetKey(), plRefMsg::kOnCreate, -1, plDynamicCamMap::kRefTargetNode), plRefFlags::kActiveRef);
        }
        hsgResMgr::ResMgr()->AddViaNotify(map->GetKey(), new plLayRefMsg(plasmaLayer->GetKey(), plRefMsg::kOnCreate, -1, plLayRefMsg::kTexture), plRefFlags::kActiveRef);

    }

    return plasmaLayer;

    hsGuardEnd;
}
Beispiel #9
0
plLayerInterface    *plLayerConverter::IConvertDynamicEnvLayer( plPlasmaMAXLayer *layer, 
                                                                plMaxNode *maxNode, uint32_t blendFlags, 
                                                                bool preserveUVOffset, bool upperLayer )
{
    hsGuardBegin( "plLayerConverter::IConvertDynamicEnvLayer" );

    IParamBlock2        *bitmapPB;
    plLocation          loc;

    loc = maxNode->GetLocation();
    bitmapPB = layer->GetParamBlockByID( plDynamicEnvLayer::kBlkBitmap );
    
    if( !bitmapPB )
    {
        fErrorMsg->Set( !bitmapPB, "Plasma Layer Error", "Bitmap paramblock for Plasma Layer not found" ).Show();
        fErrorMsg->Set();
        return nil;
    }

    // Get a new layer to play with
    plLayer *plasmaLayer = ICreateLayer( plString::FromUtf8( layer->GetName() ), upperLayer, loc );

    // Get the anchor node
    plMaxNode   *anchor = (plMaxNode *)bitmapPB->GetINode( plDynamicEnvLayer::kBmpAnchorNode );
    if( anchor == nil )
        // Default to self as the anchor--just make sure we make unique versions of this material!
        anchor = maxNode;
    
    if( !anchor->CanConvert() || !( anchor->GetForceLocal() || anchor->GetDrawable() ) )
    {
        fErrorMsg->Set( true, "Plasma Layer Error", "The dynamic envMap material %s has an invalid anchor specified. Please specify a valid Plasma scene object as an anchor.", plasmaLayer->GetKeyName().c_str() ).Show();
        fErrorMsg->Set();
        return (plLayerInterface *)plasmaLayer;
    }

    // Create texture and add it to list if unique
    int32_t texFlags = 0;

    /// Since we're a cubic environMap, we don't care about the UV transform nor the uvwSrc
    plasmaLayer->SetUVWSrc( 0 );
    plasmaLayer->SetUVWSrc( plasmaLayer->GetUVWSrc() | plLayerInterface::kUVWReflect );

    // Create the texture.  If it works, assign it to the layer
    plString texName;
    if( anchor == maxNode )
    {
        // Self-anchoring material, make sure the name is unique via the nodeName
        texName = plFormat("{}_cubicRT@{}", plasmaLayer->GetKeyName(), maxNode->GetName());
    }
    else
        texName = plFormat("{}_cubicRT", plasmaLayer->GetKeyName());

    plBitmap *texture = (plBitmap *)IMakeCubicRenderTarget( texName, maxNode, anchor );
    if( texture )
        hsgResMgr::ResMgr()->AddViaNotify( texture->GetKey(), new plLayRefMsg( plasmaLayer->GetKey(), plRefMsg::kOnCreate, 0, plLayRefMsg::kTexture ), plRefFlags::kActiveRef );

    // Tag this layer as reflective cubic environmentmapping
    if( bitmapPB->GetInt(plDynamicEnvLayer::kBmpRefract) )
        plasmaLayer->SetMiscFlags( plasmaLayer->GetMiscFlags() | hsGMatState::kMiscUseRefractionXform );
    else
        plasmaLayer->SetMiscFlags( plasmaLayer->GetMiscFlags() | hsGMatState::kMiscUseReflectionXform );

    return (plLayerInterface *)plasmaLayer;

    hsGuardEnd;
}
Beispiel #10
0
void AlembicPoints::ReadShapeFromOperator( IParticleGroup *particleGroup, PFSimpleOperator *pSimpleOperator, int particleId, TimeValue ticks, ShapeType &type, Abc::uint16_t &instanceId, float &animationTime)
{
	if(!pSimpleOperator){
		return;
	}

	if (pSimpleOperator->ClassID() == PFOperatorSimpleShape_Class_ID)
    {
        IParamBlock2 *pblock = pSimpleOperator->GetParamBlockByID(0);
        int nShapeId = pblock->GetInt(PFlow_kSimpleShape_shape, ticks);

        switch(nShapeId)
        {
        case PFlow_kSimpleShape_shape_pyramid:
            type = ShapeType_Cone;
            break;
        case PFlow_kSimpleShape_shape_cube:
            type = ShapeType_Box;
            break;
        case PFlow_kSimpleShape_shape_sphere:
            type = ShapeType_Sphere;
            break;
        case PFlow_kSimpleShape_shape_vertex:
            type = ShapeType_Point;
            break;
		default:
			type = ShapeType_Point;
        }
    }
	else if (pSimpleOperator->ClassID() == PFOperatorShapeLib_Class_ID)
	{
        IParamBlock2 *pblock = pSimpleOperator->GetParamBlockByID(0);
		int nDimension = pblock->GetInt(PFlow_kShapeLibary_dimensionType, ticks);
		if(nDimension == PFlow_kShapeLibrary_dimensionType_2D){
			int n2DShapeId = pblock->GetInt(PFlow_kShapeLibary_2DType, ticks);
			if( n2DShapeId == PFlow_kShapeLibrary_dimensionType_2D_square){
				type = ShapeType_Rectangle;
			}
			else{
				ESS_LOG_INFO("Unsupported shape type.");
				type = ShapeType_Point;
			}
		}
		else if(nDimension == PFlow_kShapeLibrary_dimensionType_3D){
			int n3DShapeId = pblock->GetInt(PFlow_kShapeLibary_3DType, ticks);
			if(n3DShapeId == PFlow_kShapeLibary_3DType_cube){
				type = ShapeType_Box;
			}
			else if(n3DShapeId == PFlow_kShapeLibary_3DType_Sphere20sides ||
					n3DShapeId == PFlow_kShapeLibary_3DType_Sphere80sides){
				type = ShapeType_Sphere;
			}
			else{
				ESS_LOG_INFO("Unsupported shape type.");
				type = ShapeType_Point;
			}
		
			//ShapeType_Cylinder unsupported
			//ShapeType_Cone unsupported
			//ShapeType_Disc unsupported
			//ShapeType_NbElements unsupported
		}
		else{
			ESS_LOG_INFO("Unknown dimension.");
			type = ShapeType_Point;
		}
			
		//int nNumParams = pblock->NumParams();

		//for(int i=0; i<nNumParams; i++){
	
		//	ParamID id = pblock->IndextoID(i);
		//	MSTR paramStr = pblock->GetLocalName(id, 0);
		//	int n = 0;
		//
		//}

	}
    else if (pSimpleOperator->ClassID() == PFOperatorInstanceShape_Class_ID)
    {
        // Assign animation time and shape here
        IParamBlock2 *pblock = pSimpleOperator->GetParamBlockByID(0);
        INode *pNode = pblock->GetINode(PFlow_kInstanceShape_objectMaxscript, ticks);
        if (pNode == NULL || pNode->GetName() == NULL)
        {
            return;
        }
        
        type = ShapeType_Instance;

		bool bFlatten = GetCurrentJob()->GetOption("flattenHierarchy");
		std::string nodePath = getNodeAlembicPath( EC_MCHAR_to_UTF8( pNode->GetName() ), bFlatten);

        // Find if the name is alerady registered, otherwise add it to the list
   //     instanceId = FindInstanceName(nodePath);
   //     if (instanceId == USHRT_MAX)
   //     {
			//mInstanceNames.push_back(nodePath);
   //         instanceId = (Abc::uint16_t)mInstanceNames.size()-1;
   //     }

        // Determine if we have an animated shape
        BOOL animatedShape = pblock->GetInt(PFlow_kInstanceShape_animatedShape);
	    BOOL acquireShape = pblock->GetInt(PFlow_kInstanceShape_acquireShape);

        if (!animatedShape && !acquireShape)
        {
            return;
        }

        // Get the necesary particle channels to grab the current time values
        ::IObject *pCont = particleGroup->GetParticleContainer();
        if (!pCont)
        {
            return;
        }

        // Get synch values that we are interested in fromt the param block
        int syncType = pblock->GetInt(PFlow_kInstanceShape_syncType);
        BOOL syncRandom = pblock->GetInt(PFlow_kInstanceShape_syncRandom);

        IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
        if (chTime == NULL) 
        {
            return; // can't find particle times in the container
        }

        IChannelContainer* chCont = GetChannelContainerInterface(pCont);
        if (chCont == NULL) 
        {
            return;  // can't get access to ChannelContainer interface
        }

        IParticleChannelPTVR* chBirthTime = NULL;
        IParticleChannelPTVR* chEventStartR = NULL;
        bool initEventStart = false;

        if (syncType == PFlow_kInstanceShape_syncBy_particleAge) 
        {
            chBirthTime = GetParticleChannelBirthTimeRInterface(pCont);
            if (chBirthTime == NULL) 
            {
                return; // can't read particle age
            }
        }
        else if (syncType == PFlow_kInstanceShape_syncBy_eventStart) 
        {
            chEventStartR = GetParticleChannelEventStartRInterface(pCont);
             
            if (chEventStartR == NULL) 
            {
                return; // can't read event start time
            }
        }

        IParticleChannelIntR* chLocalOffR = NULL;
        bool initLocalOff = false;

        // acquire LocalOffset particle channel; if not present then create it.
        if (syncRandom) 
        {
            chLocalOffR =  (IParticleChannelIntR*)chCont->GetPrivateInterface(PARTICLECHANNELLOCALOFFSETR_INTERFACE, pSimpleOperator);
        }

        // get new shape from the source
        PreciseTimeValue time = chTime->GetValue(particleId);
        switch(syncType)
        {
        case PFlow_kInstanceShape_syncBy_absoluteTime:
            break;
        case PFlow_kInstanceShape_syncBy_particleAge:
            time -= chBirthTime->GetValue(particleId);
            break;
        case PFlow_kInstanceShape_syncBy_eventStart:
            time -= chEventStartR->GetValue(particleId);
            break;
        default:
            break;
        }

        if (syncRandom) 
        {
            if (chLocalOffR != NULL)
                time += chLocalOffR->GetValue(particleId);
        }
		
		//timeValueMap::iterator it = mTimeValueMap.find(time);
		//if( it != mTimeValueMap.end() ){
		//	ESS_LOG_WARNING("sampleTime already seen.");
		//}
		//else{
		//	mTimeValueMap[time] = true;
		//	mTimeSamplesCount++;
		//	ESS_LOG_WARNING("sampleTime: "<<(float)time<<" totalSamples: "<<mTimeSamplesCount);
		//}

        TimeValue t = TimeValue(time);
        animationTime = (float)GetSecondsFromTimeValue(t);
    }
	else if (pSimpleOperator->ClassID() == PFOperatorMarkShape_Class_ID)
	{
		ESS_LOG_INFO("Shape Mark operator not supported.");
	}
	else if (pSimpleOperator->ClassID() == PFOperatorFacingShape_Class_ID)
	{
		ESS_LOG_INFO("Shape Facing operator not supported.");
	}

}
Beispiel #11
0
    BOOL DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        int selection;
        HWND cbox = NULL;
        HWND hList = GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_BONELIST);

        switch (msg)
        {
        case WM_INITDIALOG:
            {
                int LodBeginState   = map->GetParamBlock()->GetInt(plLODAvatarComponent::kLODState);

                HWND LODCombo = GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_STATE);
    
                fMstrDlg = hWnd;
            
                fPB = map->GetParamBlock();
                fComp = (plLODAvatarComponent*) fPB->GetOwner();

                VCharArray Nilptr;
                ILoadComboBox(LODCombo, fComp->fLODLevels);
                SendMessage(LODCombo, CB_SETCURSEL, LodBeginState,  0); // select the right one

                int i;
                for (i = 0; i < plClothingMgr::kMaxGroup; i++)
                {
                    cbox = GetDlgItem(hWnd, IDC_COMP_AVATAR_CLOTHING_GROUP);
                    SendMessage(cbox, CB_ADDSTRING, 0, (LPARAM)plClothingMgr::GroupStrings[i]);
                }
                selection = fPB->GetInt(ParamID(plLODAvatarComponent::kClothingGroup));
                SendMessage(cbox, CB_SETCURSEL, selection, 0);

                for (i = 0; i < plArmatureMod::kMaxBoneBase; i++)
                {
                    cbox = GetDlgItem(hWnd, IDC_COMP_AVATAR_SKELETON);
                    SendMessage(cbox, CB_ADDSTRING, 0, (LPARAM)plArmatureMod::BoneStrings[i]);
                }
                selection = fPB->GetInt(ParamID(plLODAvatarComponent::kSkeleton));
                SendMessage(cbox, CB_SETCURSEL, selection, 0);

                Mtl *mat = fPB->GetMtl(plLODAvatarComponent::kMaterial);
                Button_SetText(GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_MTL), (mat ? mat->GetName() : "(none)"));

                UpdateBoneDisplay(map);
                return true;
            }

        case WM_COMMAND:
            if (LOWORD(wParam) == IDC_COMP_AVATAR_CLOTHING_GROUP)
            {
                selection = SendMessage(GetDlgItem(hWnd, IDC_COMP_AVATAR_CLOTHING_GROUP), CB_GETCURSEL, 0, 0);
                fPB->SetValue(ParamID(plLODAvatarComponent::kClothingGroup), t, selection);
                return TRUE;
            }
            else if (LOWORD(wParam) == IDC_COMP_AVATAR_SKELETON)
            {
                selection = SendMessage(GetDlgItem(hWnd, IDC_COMP_AVATAR_SKELETON), CB_GETCURSEL, 0, 0);
                fPB->SetValue(ParamID(plLODAvatarComponent::kSkeleton), t, selection);
                return TRUE;
            }
            else if (HIWORD(wParam) == BN_CLICKED)
            {
                if (LOWORD(wParam) == IDC_COMP_LOD_AVATAR_BONE_ADD)
                {
                    std::vector<Class_ID> cids;
                    cids.push_back(Class_ID(TRIOBJ_CLASS_ID, 0));
                    cids.push_back(Class_ID(EDITTRIOBJ_CLASS_ID, 0));
                    if (plPick::NodeRefKludge(fPB, plLODAvatarComponent::kLastPick, &cids, true, false))            
                        fComp->AddSelectedBone();

                    return TRUE;
                }
                // Remove the currently selected material
                else if (LOWORD(wParam) == IDC_COMP_LOD_AVATAR_BONE_REMOVE)
                {
                    int curSel = SendMessage(hList, LB_GETCURSEL, 0, 0);
                    if (curSel >= 0)
                        fComp->RemoveBone(curSel);

                    return TRUE;
                }
                else if (LOWORD(wParam) == IDC_COMP_LOD_AVATAR_MTL)
                {
                    Mtl *pickedMtl = plPickMaterialMap::PickMaterial(plMtlCollector::kPlasmaOnly);
                    fPB->SetValue(plLODAvatarComponent::kMaterial, 0, pickedMtl);
                    Button_SetText(GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_MTL), (pickedMtl ? pickedMtl->GetName() : "(none)"));

                    return TRUE;
                }
            }
            else 
            {
                int LodBeginState   = map->GetParamBlock()->GetInt(plLODAvatarComponent::kLODState);
                
                if(fPB->GetINode(plLODAvatarComponent::kMeshNodeAddBtn,t))
                    fPB->SetValue(plLODAvatarComponent::kMeshNodeTab, t, fPB->GetINode(plLODAvatarComponent::kMeshNodeAddBtn,t), LodBeginState);
                    
                if(LOWORD(wParam) == IDC_COMP_LOD_AVATAR_STATE && HIWORD(wParam) == CBN_SELCHANGE)
                {
                    int idx = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
                    fPB->SetValue(plLODAvatarComponent::kLODState, 0, idx);
                    
                    if(fPB->GetINode(plLODAvatarComponent::kMeshNodeTab, t, idx))
                        fPB->SetValue(plLODAvatarComponent::kMeshNodeAddBtn, t, fPB->GetINode(plLODAvatarComponent::kMeshNodeTab,t, idx));
                    else
                        fPB->Reset(plLODAvatarComponent::kMeshNodeAddBtn);
                    return true;
                }
            }

            break;

        case WM_CLOSE:
            {
                int LodBeginState   = map->GetParamBlock()->GetInt(plLODAvatarComponent::kLODState);

                if(fPB->GetINode(plLODAvatarComponent::kMeshNodeAddBtn,t))
                    fPB->SetValue(plLODAvatarComponent::kMeshNodeTab, t, fPB->GetINode(plLODAvatarComponent::kMeshNodeAddBtn,t), LodBeginState);

                return false;
            }
        }
            
        return false;
    }
bool HoudiniEngineMesh::UpdateParameters(TimeValue t)
{
	bool need_cook = false;
	if ( assetId >= 0 )
	{
		hapi::Asset asset(assetId);
		if (asset.isValid())
		{
			INode* node = this->GetINode();
			if (node)
			{
				MSTR pname;
				int subs = node->NumSubs();
				for (int i = 0; i < subs; ++i)
				{
					pname = node->SubAnimName(i);
					Animatable* anim = node->SubAnim(i);
					if (anim)
					{
						int blocks = anim->NumParamBlocks();
						for (int block = 0; block < blocks; ++block)
						{
							IParamBlock2 *pblock = anim->GetParamBlock(block);
							if (pblock) {
								TSTR pbname = pblock->GetLocalName();
								int nNumParams = pblock->NumParams();
								ParamID id;
								std::map<std::string, hapi::Parm> params = asset.parmMap();
								for (int i = 0; i < nNumParams; i++)
								{
									id = pblock->IndextoID(i);
									MSTR pname = pblock->GetLocalName(id);
									std::string hname = CStr::FromMSTR(pblock->GetLocalName(id)).data();

									int index = (int)(hname[hname.size() - 1] - '0');
									hname.pop_back();

									if (std::string("__he_input") == hname)
									{
										// input node
										INode* inputnode = pblock->GetINode(id, t);
										if (inputnode)
										{
											need_cook = SetInputNode(index, inputnode) || need_cook;
										}
									}
									else
									{
										// parameters
										if (params.find(hname) != params.end())
										{
											hapi::Parm parm = params[hname];
											if (HAPI_ParmInfo_IsInt(&parm.info()))
											{
												int value = pblock->GetInt(id, t);
												if (value != parm.getIntValue(index))
												{
													parm.setIntValue(index, value);
													need_cook = true;
												}
											}
											else if (HAPI_ParmInfo_IsFloat(&parm.info()))
											{
												float value = pblock->GetFloat(id, t);
												if (value != parm.getFloatValue(index))
												{
													parm.setFloatValue(index, value);
													need_cook = true;
												}
											}
											else if (HAPI_ParmInfo_IsString(&parm.info()))
											{
												std::string value = CStr::FromMSTR(pblock->GetStr(id, t));
												if (value != parm.getStringValue(index))
												{
													parm.setStringValue(index, value.c_str());
													need_cook = true;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return need_cook;
}
Beispiel #13
0
BOOL plClothingComponentProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = pm->GetParamBlock();
    HWND hList = GetDlgItem(hWnd, IDC_CLOTHING_LIST);
    HWND hGroup = GetDlgItem(hWnd, IDC_CLOTHING_GROUP);
    HWND hType = GetDlgItem(hWnd, IDC_CLOTHING_TYPE);
    HWND hLOD = GetDlgItem(hWnd, IDC_COMP_LOD_CLOTHING_STATE);
    switch (msg)
    {
    case WM_INITDIALOG:
        {
            ListBox_ResetContent(hList);
            int i;
            for (i = 0; i < pb->Count(plClothingComponent::kMaterials); i++)
                ListBox_AddString(hList, pb->GetMtl(ParamID(plClothingComponent::kMaterials), 0, i)->GetName());

            ListBox_SetCurSel(hList, -1);

            for (i = 0; i < plClothingMgr::kMaxGroup; i++)
                ComboBox_AddString(hGroup, plClothingMgr::GroupStrings[i]);
            ComboBox_SetCurSel(hGroup, pb->GetInt(plClothingComponent::kGroup));

            for (i = 0; i < plClothingMgr::kMaxType; i++)
                ComboBox_AddString(hType, plClothingMgr::TypeStrings[i]);
            ComboBox_SetCurSel(hType, pb->GetInt(plClothingComponent::kType));

            ComboBox_AddString(hLOD, "High");
            ComboBox_AddString(hLOD, "Medium");
            ComboBox_AddString(hLOD, "Low");
            ComboBox_SetCurSel(hLOD, pb->GetInt(plClothingComponent::kLODState));
        }
        return TRUE;


    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_CLOTHING_ADD)
            {
                Mtl *pickedMtl = plPickMaterialMap::PickMaterial(plMtlCollector::kClothingMtlOnly);
                if (pickedMtl != nil)
                {
                    LRESULT stringIdx = ListBox_FindStringExact(hList, -1, pickedMtl->GetName());
                    if (stringIdx == LB_ERR) // It's not already there, go and add it
                    {
                        pb->Append(ParamID(plClothingComponent::kMaterials), 1, &pickedMtl, 0);
                        ListBox_AddString(hList, pickedMtl->GetName());
                    }
                }
                return TRUE;
            }
            // Remove the currently selected material
            else if (LOWORD(wParam) == IDC_CLOTHING_REMOVE)
            {
                int sel = ListBox_GetCurSel(hList);
                if (sel != LB_ERR)
                {
                    pb->Delete(plClothingComponent::kMaterials, sel, 1);
                    ListBox_DeleteString(hList, sel);
                }
                return TRUE;
            }
            else if( LOWORD( wParam ) == IDC_CLOTHING_CLEARMESH )
            {
                int state = pb->GetInt(plClothingComponent::kLODState);
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, (INode*)nil, state );
                pb->Reset(plClothingComponent::kMeshNodeAddBtn);
            }
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_GROUP)
        {
            int setIdx = ComboBox_GetCurSel(hGroup);
            pb->SetValue(plClothingComponent::kGroup, 0, setIdx);

            return TRUE;
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_TYPE)
        {
            int setIdx = ComboBox_GetCurSel(hType);
            pb->SetValue(plClothingComponent::kType, 0, setIdx);

            return TRUE;
        }
        else
        {
            int state = pb->GetInt(plClothingComponent::kLODState);
                
            INode *node = pb->GetINode(plClothingComponent::kMeshNodeAddBtn);
            if (node)
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, node, state);

            if(LOWORD(wParam) == IDC_COMP_LOD_CLOTHING_STATE && HIWORD(wParam) == CBN_SELCHANGE)
            {
                int idx = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
                pb->SetValue(plClothingComponent::kLODState, 0, idx);
            
                node = pb->GetINode(plClothingComponent::kMeshNodeTab, 0, idx);
                if (node)
                    pb->SetValue(plClothingComponent::kMeshNodeAddBtn, 0, node);
                else
                    pb->Reset(plClothingComponent::kMeshNodeAddBtn);

                return TRUE;
            }
        }
    }

    return FALSE;
}
	void OrientConstRotation::RedrawListbox(TimeValue t,  int sel)
	{
		if (hWnd == NULL) return;
		if (!ip || editCont != this) return;
		int isWorldinListboxFlag = 0;
		if(!orientCD.NumParamMaps()) return;
		int selection = SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_GETCURSEL, 0, 0);
//		IParamBlock2* pb = orientCD.GetParamMap(0)->GetParamBlock();
		SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_RESETCONTENT, 0, 0);
		int ts = 64;  // appears smaller than necessary since for a large no of targets the vertical scroll bar needs space
		SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETTABSTOPS, 1, (LPARAM)&ts);
		int ct = pblock->Count(orientation_target_list);
		int ctf = pblock->Count(orientation_target_weight);
		if (ct != ctf) return;		// CAL-09/10/02: In the middle of changing table size.

		for (int i = 0; i < ct; i++){				
			TSTR str;
			INode *testNode;
			testNode = pblock->GetINode(orientation_target_list, t, i);
			if (testNode == NULL){
				str.printf( _T("%-s\t%-d"), // NOTE: for tab "\t" to use, check "use tabstops" in the resource listbox properties
										_T("World"), (int)pblock->GetFloat(orientation_target_weight, t, i));
				isWorldinListboxFlag = 1;
				ICustButton *iPickOb;
				iPickOb	= GetICustButton(GetDlgItem(hWnd, IDC_ORIENT_PICK_WORLD));
				if (iPickOb != NULL){
					iPickOb->Enable(FALSE);
					ReleaseICustButton(iPickOb);
				}
			}
			else{
				float wwt = pblock->GetFloat(orientation_target_weight, t, i);
				const TCHAR * nname = testNode->GetName();
				str.printf(_T("%-s\t%-d"), 
				testNode->GetName(),
				(int)pblock->GetFloat(orientation_target_weight, t, i));
			}
			SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) str.data());			
		}

		if(!isWorldinListboxFlag){
				ICustButton *iPickOb;
				iPickOb	= GetICustButton(GetDlgItem(hWnd, IDC_ORIENT_PICK_WORLD));
				if (iPickOb != NULL){
					iPickOb->Enable(TRUE);
					ReleaseICustButton(iPickOb);
				}
		}

		if (ct > 0){
			if (sel >= 0){
				SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, sel, 0);
			}
			else{
//		int selection = SendDlgItemMessage(hWnd, IDC_POS_TARG_LIST, LB_GETCURSEL, 0, 0);
				if (selection >= 0){
					SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, selection, 0);
					last_selection = selection;
				}
				else if (ct == 1){
					SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, 0, 0);
					last_selection = 0;
				}
			}
			
			ISpinnerControl* spin = GetISpinner(GetDlgItem(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER));
			if (last_selection >= 0 && spin != NULL){
				float value = pblock->GetFloat(orientation_target_weight, GetCOREInterface()->GetTime(), last_selection);
				spin->SetValue(value, FALSE);
			}
			ReleaseISpinner(spin);
		}
		HWND hListBox = GetDlgItem(hWnd, IDC_ORIENT_TARG_LIST);
		int extent = computeHorizontalExtent(hListBox, TRUE, 1, &ts);
		SendMessage(hListBox, LB_SETHORIZONTALEXTENT, extent, 0);
		UpdateWindow(hWnd);
	}