HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mocapstream/MocapStreamRokokoHDK.h
/*
* PROPRIETARY INFORMATION. This software is proprietary to
* Side Effects Software Inc., and is not to be reproduced,
* transmitted, or disclosed in any way without written permission.
*
* NAME: MocapStreamRokokoHDK.h ( KineFX Library, C++)
*
*/
#ifndef __MOCAPSTREAMROKOKOHDK_H_INCLUDED__
#define __MOCAPSTREAMROKOKOHDK_H_INCLUDED__
namespace HDK_Sample
{
class MocapStreamRokokoHDK : public MC_MocapStreamImpl
{
public:
/// Initializes the MC_MocapStream::ServerOptions class with the default
/// values for the different parameters on the MocapStream SOP and define
/// which parameters are visible.
MocapStreamRokokoHDK(const ServerOptions& opts = ServerOptions{
14043, "", "", "", 0, 0, 32768,
{true, false, false, false, false, false, true, false, false, false}}
);
~MocapStreamRokokoHDK() override;
/// Creates a unique pointer to the the MocapStreamRokokoHDK device from
/// a set of server options.
///
/// This must be implemented and is used in the connection process.
UT_UniquePtr<MC_MocapStreamImpl> clone(const ServerOptions& opts) override
{
return UTmakeUnique<MocapStreamRokokoHDK>(opts);
}
fpreal packet_time,
bool &parse_incomplete) override;
const MC_MocapStreamCookParms &cookparms,
const MC_MocapStreamCookParms &prev_cookparms) override;
void removeSkeleton(const UT_StringHolder& name) override;
/// Define the label for this device. This will be added in the "Device"
/// menu on the MocapStream SOP.
const char* label() const override { return "Rokoko Studio - HDK"; }
/// Define a unique name for this device. This will be used to distinguish
/// This device from other MocapStream devices.
const char* name() const override { return "rokoko_hdk"; }
private:
void computeSkeletonTransforms();
// A structure to hold all of the data for a single point in the motion
// capture stream.
struct ActorPoint
{
ActorPoint()
: myWorldXform(1.0)
, myLocalXform(1.0)
, myDidReceive(true)
{}
UT_Matrix4F myWorldXform;
UT_Matrix4F myLocalXform;
bool myDidReceive;
};
// A structure to hold all of the data for a single actor (skeleton or
// rigid body) in the motion capture stream.
struct Actor
{
Actor()
: myOccurances(0)
, myIsDirty(true)
{}
int myOccurances;
bool myIsDirty;
};
// A structure to hold a set of actors (either skeletons or rigid bodies)
// streamed from Rokoko Studio.
class ActorList
{
public:
ActorList() {}
~ActorList() {}
exint size() { return myActors.size(); }
void resetOccurances()
{
for (auto &actor : myActors)
{
actor.myOccurances = 0;
}
}
Actor *addActor(UT_StringHolder name)
{
if (myNameToIdx.contains(name))
{
Actor &actor = myActors(myNameToIdx[name]);
actor.myPoints.clear();
return &actor;
}
Actor new_actor;
new_actor.myName = name;
myActors.append(new_actor);
myNameToIdx[name] = myActors.entries()-1;
return &myActors(myActors.entries()-1);
}
Actor *findActor(UT_StringHolder name)
{
if (myNameToIdx.contains(name))
return &myActors(myNameToIdx[name]);
return nullptr;
}
bool removeActor(UT_StringHolder name)
{
if (!myNameToIdx.contains(name))
return false;
exint removed_idx = myNameToIdx[name];
myActors.removeIndex(removed_idx);
for (auto it = myNameToIdx.begin(); !it.atEnd(); ++it)
{
if (it->second > removed_idx)
it->second--;
}
return true;
}
Actor &operator()(exint i)
{
if (i < 0)
i = 0;
if (i >= myActors.size())
i = myActors.size()-1;
return myActors(i);
}
private:
UT_Array<Actor> myActors;
};
ActorList mySkeletons;
ActorList myProps;
};
}
#endif