As always writing to the list and a quick bike ride are a cure to all
softimage related ailments.
For anyone coming upon this on a google search, here is the code that got
it to work:
(This is just the code from the Evaluate callback.)
case ID_OUT_DecPointPositionArray :
{
// Get the output port array ...
CDataArray2DVector3f outData( in_ctxt );
// Get the input data buffers for each port
CDataArray2DCustomType EncodedGoalData( in_ctxt, ID_IN_EncodedGoalArray );
// We need a CIndexSet to iterate over the data
CIndexSet indexSet( in_ctxt );
for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next())
{
// Add code to set output port...
CDataArray2DCustomType::Accessor EncodedGoalDataSubArray =
EncodedGoalData[it];
GoalData* pBufferEncodedGoal;
ULONG nSizeEncodedGoal;
EncodedGoalDataSubArray.GetData( it,(const
CDataArray2DCustomType::TData**)&pBufferEncodedGoal, nSizeEncodedGoal );
CDataArray2DVector3f::Accessor outDataSubArray = outData.Resize(it,
EncodedGoalDataSubArray.GetCount());
for (ULONG i=0; i<EncodedGoalDataSubArray.GetCount(); i++)
{
if (nSizeEncodedGoal)
{
outDataSubArray[i].PutX(pBufferEncodedGoal->PointPosition.GetX());
outDataSubArray[i].PutY(pBufferEncodedGoal->PointPosition.GetY());
outDataSubArray[i].PutZ(pBufferEncodedGoal->PointPosition.GetZ());
}
else
{
outDataSubArray[i] = MATH::CVector3f( 0, 0, 0 );
}
}
}
}
break;
Have a good evening everyone!
On Fri, Jun 7, 2013 at 9:48 PM, Leonard Koch <[email protected]>wrote:
> Hi everyone,
>
> I'm trying to access the individual elements of a two dimensional array of
> a custom type.
> I have no problems when the array is one dimensional, but when it is two
> dimensional and I try to create subArrays, I get stuck.
> You can't get access to a subArray of custom type by saying subArray =
> mainArray[it] like you can with normal data-types.
>
> I could probably just hack something together by passing in the size of
> the individual sub arrays and then computing the indices of the individual
> elements from the 2D-array, but I would hope for a cleaner solution.
>
> If that is actually the only way to your knowledge, then please let me
> know.
>
> I know this is rather technical, but if you guys happen to have any
> suggestions I would appreciate it.
>
> case ID_OUT_DecPointPositionArray :
> {
> // Get the output port array ...
> CDataArray2DVector3f outData( in_ctxt );
> // Get the input data buffers for each port
> CDataArrayCustomType EncodedGoalArrayData( in_ctxt,
> ID_IN_EncodedGoalArray );
> CIndexSet indexSet( in_ctxt );
> for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next())
> {
> //The line below is the problem.
> CDataArray2DCustomType::Accessor EncodedGoalArraySubArray =
> EncodedGoalArrayData[it];
> for (ULONG i=0; i<EncodedGoalArraySubArray.GetCount( ); i++)
> {
> GoalData* pBufferEncodedGoalArray;
> ULONG nSizeEncodedGoalArray;
> EncodedGoalArraySubArray.GetData(i,(const
> CDataArray2DCustomType::TData**)& pBufferEncodedGoalArray,
> nSizeEncodedGoalArray);
>
> CDataArray2DVector3f::Accessor outDataSubArray =
> outData.Resize(it, EncodedGoalArraySubArray.GetCount());
>
> if (nSizeEncodedGoalArray)
> {
> outDataSubArray[i].PutX(pBufferEncodedGoalArray->PointPosition.GetX());
> outDataSubArray[i].PutY(pBufferEncodedGoalArray->PointPosition.GetY());
> outDataSubArray[i].PutZ(pBufferEncodedGoalArray->PointPosition.GetZ());
> }
> else
> {
> outDataSubArray[i] = MATH::CVector3f( 0, 0, 0 ); //State not initialized
> yet
> }
> }
> }
> }
> break;
>
> Here is the simple structure which lives inside the custom data type:
>
> struct GoalData
> {
> MATH::CVector3f PointPosition;
> MATH::CVector3f PointTangent;
> MATH::CVector3f PointNormal;
> };
>
>
> If there are any questions left open feel free to ask.
>