How to retrieve the blendshape targets with the shape editor worlkflow (C++API)

How to retrieve the blendshape targets with the shape editor worlkflow (C++API)

Anonymous
Not applicable
4,985 Views
22 Replies
Message 1 of 23

How to retrieve the blendshape targets with the shape editor worlkflow (C++API)

Anonymous
Not applicable

Hello,

 

We have a Maya mesh exporter to a proprietary format. This format is handling blendshape targets, and was correctly exported up to maya2016. With the Shape Editor workflow thou, it seems that the API is unable to return the different targets as it used to do :

 

- If I ask the MFnBlendshapeDeformer for getBaseObejcts(), it does return the correct objet as before.

- when I ask for getTargets(...), the same way it worked previously, it either returns "invalidParameter", if we did not play with the shapeEditor at all, or it returns correctly then goes to targetItemIndexList(...) which returns an invalid number of indices compared to the target objects.

 

Does anyone have a sample/ code snippet of plugin export, which would be compatible with the shape editor worlkflow ? Or any additional help would be welcome !

 

Thank you

 

0 Likes
Accepted solutions (1)
4,986 Views
22 Replies
Replies (22)
Message 2 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I tried to reproduce the issue but failed. Could you send us a sample to reproduce this issue?

 

Yours,

Li

 

0 Likes
Message 3 of 23

Anonymous
Not applicable

Hi, and thank you to take care of this issue.

enclosed is a simple cube with a blendshape, with one weight moving a single vertex of the cube, from Maya2018. If you try to access the blendshapes targets through API, you will either end with an error on getTargets, or on the next call to get blendshape indices weights.

If you export in FBX and import the result back into maya, then it is successful, but we can't ask this to our customers.

0 Likes
Message 4 of 23

Anonymous
Not applicable

There is no python binding for MFnBlendshapeDeformer, so its a bit tricky to build a complete portable sample, but here it is in c++, you can drop it in some existing plugin or anywhere it can be launched easily.

 

The blendshape documentation mention :

unsigned int numWeights(MStatus ReturnStatus = NULL)const

Return the number of weight values that this blend shape deformer has.

The number of weight values is equal to the number of targets. Targets are either shapes in the dag or baked data on the blendShape node (when a target shape is deleted).

 

You can see that with this sample, we have :

- 1 as "numweights"

- 1 as weightIndexList

- 0 as target 

 

getTargets() either generates an error, or succceeds and returns an empty target array.

 

The result I have with this code is :

// Found blendshape node blendShape1 //
// It has 1 weights //
// Processing basemesh 0 //
// Blendshape first base mesh is pCube1Shape //
// Processing weight index list #0 //
// Error: Error when getting Targets. //

 

This is an issue in my case, as I need to obtained some raw (mesh) deformed geometry to be able to store it in my proprietary format.

0 Likes
Message 5 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I could reproduce this issue. After discussing with engineers and doing some research myself. I feel it is an omission update for this API while introducing the blend shape editor.

 

I also checked how FBX deal with this API when exporting. FBX uses targetItemIndexList to iterate through the targets. If the index is greater than the length of target objecy array when baking the object, fbx will ignore the target object array and continue.

 

I've logged a defect in our system. Our engineers will look at it.

 

Yours,

Li

0 Likes
Message 6 of 23

Anonymous
Not applicable

Hey there, 

As some other customers are meeting this issue, I ping back : is there a log number for this issue, or any mean to track the advance on this subject ?

Thank you

0 Likes
Message 7 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I've sent you the defect id through an email from salesforce. Please check it out.

 

Yours,

Li

0 Likes
Message 8 of 23

jgarrett
Explorer
Explorer

hi

 

could I get a bit more info about this:

 

> FBX uses targetItemIndexList to iterate through the targets. If the index is
> greater than the length of target objecy array when baking the object, fbx
> will ignore the target object array and continue.

 

I get an item index of 6000 - which can be converted to a fullWeight value of 1

but I'm not sure what to do with that value

 

- how is FBX using it ?

 

thanks

 

Jonny

 

0 Likes
Message 9 of 23

golaem
Enthusiast
Enthusiast

Hi Jonny,

If you check above posts about .ma and code snippet, you should not need any FBX. To sum up, since 2016.5 :

- produce a blendshape via the blendshape editor (one is provided in the above .ma, so you can skip this part)

- try to access it via the API code in the zip file (build a custom plugin to make it a command, or even drop this method in an existing custom command plugin for test purpose )

The expected / faulty results are explained in the .zip post

 

0 Likes
Message 10 of 23

jgarrett
Explorer
Explorer

hi

in my exporter I'm also attempting to iterate through targets by calling MFnBlendShapeDeformer::getTargets on the weight indices returned by MFnBlendShapeDeformer::weightIndexList - eg.

 

  MIntArray weight_indices;
  VERIFY( fn_morpher.weightIndexList( weight_indices ) );

  for( uint32_t iweight = 0; iweight < weight_indices.length(); iweight++ )
  {
    uint32_t weight_id = weight_indices[ iweight ];

    // get the targets
    MObjectArray targets;
    MStatus stat =  fn_morpher.getTargets( object, weight_id, targets );
    ...

the getTargets call is returning MS::kInvalidParameter


in this response, Li mentions that the FBX exporter uses targetItemIndexList to iterate through the targets


and I'm asking for more info about how that's done


Jonny

0 Likes
Message 11 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

 

It is using just iweight not weight value to loop through.

 

If it is unbaked object and iweight is larger than target object list count, it will continue.

 

 

pseudo-code

 

 

if (!isTargetedBaked)
{    if (iweight > targetObjectList.length())
continue;
targetobject = targetObjectList[iweight]
}
else
//process baked target.

It could have target index larger than the targetObjectList's length and we still need to process.

 

Hope it helps.

 

Yours,

Li

 

0 Likes
Message 12 of 23

golaem
Enthusiast
Enthusiast

Good afternoon and HNY 2019 to all the Autodesk Team

 

Thanks for the Change Request number. You're referring that we can request an update on the status of this issue, or to provide us with additional information, at any time by submitting a new Case through DevHelp Online quoting the Change Request number or this Case number.

 

Any chance you could let us know how to access that DevHelp Online ?

 

Moreover, we had multiple customers hitting this issue those latter weeks and it's starting to become quite important for us.

Would love to get updated about this matter.

 

Best;

0 Likes
Message 13 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

It refers to the API support portal. So, mainly it's just:

 

• To Log a case based on your current subscription, log into the manage.autodesk.com portal.
• Select the "View my Support Cases" in upper right area
• Enter an "API Support" case and request an update on the change request ID..

 

Yours,

Li

0 Likes
Message 14 of 23

golaem
Enthusiast
Enthusiast

Thanks for the fast answer

I'm afraid that none of our two accounts (sebastien.maraux and golaem) have that "View my Support Cases" section

Should we be granted a specific access ?

 

Thanks

0 Likes
Message 15 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

I could see your current subscription status on the forum(account golaem). The link should be here:

 

support.png

Yours,

Li

0 Likes
Message 16 of 23

golaem
Enthusiast
Enthusiast

2019-01-10 11_42_55-GolaemForUnreal - Microsoft Visual Studio.png

Here is mine (for the golaem account)

0 Likes
Message 17 of 23

jgarrett
Explorer
Explorer

thanks Li

 

how can I tell if the object is baked or not (ie. what sets isTargetedBaked) ?

 

Jonny

0 Likes
Message 18 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Sorry for the delay, I was traveling last week and got sick later. It checks if the inputTarget.inputTargetGroup.inputTargetItem.inputGeomTarget has connection.

 

Yours,

Li

0 Likes
Message 19 of 23

jgarrett
Explorer
Explorer

thanks, that makes sense

Jonny

0 Likes
Message 20 of 23

golaem
Enthusiast
Enthusiast

Hello, bouncing back this thread, as our customers are regularly hitting this issue when they export their blendshapes.  Please focus on the 5 first messages and replies for the main issue. We would really appreciate if someone at Autodesk could take this issue into account and fix this missing/buggy API part on blendshapes, as we have no better option now than warning our customers that we can't handle their data until the API is fixed.

Thank you