HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MC_MocapStreamImpl Class Referenceabstract

#include <MC_MocapStreamImpl.h>

+ Inheritance diagram for MC_MocapStreamImpl:

Classes

class  Register
 
class  RegisterBase
 
struct  ServerOptions
 
struct  ServerState
 

Public Types

typedef void(* MC_MocapServerFunc )(ServerState &state, const ServerOptions &options, MC_MocapStreamImpl *data)
 

Public Member Functions

 MC_MocapStreamImpl (MC_MocapServerFunc f, const ServerOptions &myServerOptions)
 
virtual ~MC_MocapStreamImpl ()
 
virtual UT_UniquePtr
< MC_MocapStreamImpl
clone (const ServerOptions &opts)=0
 
virtual bool parsePacket (UT_StringHolder &packet, fpreal packet_time, bool &parse_incomplete)=0
 
virtual void buildSkeleton (GU_Detail *, UT_StringHolder name)=0
 
virtual void removeSkeleton (const UT_StringHolder &name)
 Removes the stored data for a skeleton. More...
 
virtual bool removeExpiredSkeletons () const
 
virtual int expirationCount ()
 
virtual void updateJoints (GU_Detail *gdp, const MC_MocapStreamCookParms &cookparms, const MC_MocapStreamCookParms &prev_cookparms)=0
 
void receivedSkeleton (const UT_StringHolder &name)
 
void renamedSkeleton (const UT_StringHolder &old_name, const UT_StringHolder &new_name)
 Call this to let the base class know an actor's name has changed. More...
 
void setPacketTime (fpreal64 time)
 
template<typename... Args>
void addParseError (const char *fmt, Args &&...args)
 Call this to report an error when parsing. More...
 
template<typename... Args>
void addParseWarning (const char *fmt, Args &&...args)
 Call this to report a warning when parsing. More...
 
void rebuildSkeletons ()
 
void queueServerTask (const UT_Function< void(void *)> &task)
 
virtual const char * name () const =0
 The unique name used to identify a subclass's mocap stream device. More...
 
virtual const char * label () const =0
 
bool cook (GU_Detail *gdp, uint64 &skeleton_version, fpreal time, const MC_MocapStreamCookParms &cookparms, const MC_MocapStreamCookParms &prev_cookparms, bool &is_killed)
 
void clear ()
 Removes all actors/skeletons. More...
 
void startRecording (UT_SharedPtr< MC_MocapRecorder > recorder, const MC_MocapStreamCookParms &cookparms)
 Starts recording the motion capture data and stores it in a MotionClip. More...
 
void stopRecording (UT_SharedPtr< MC_MocapRecorder > recorder)
 Stops recording the motion capture data. More...
 
const UT_ArrayStringMap< exint > & getActorMap ()
 
bool hasHitError ()
 Used to determine if the stream has run into an error. More...
 

Static Public Member Functions

static void basicUdpReceiver (ServerState &state, const ServerOptions &options, MC_MocapStreamImpl *data)
 
static void basicTcpClient (ServerState &state, const ServerOptions &options, MC_MocapStreamImpl *data)
 
static void getBoostErrorMessage (hboost::system::error_code e, UT_StringHolder &err_msg)
 Gets the error message corresponding to an hboost error code. More...
 
static void getBoostErrorMessage (hboost::system::system_error &e, UT_StringHolder &err_msg)
 Gets the error message corresponding to an hboost error code. More...
 
static void handleBoostError (hboost::system::error_code e, ServerState &state)
 Adds an error message to the log corresponding to an hboost error code. More...
 
static void handleBoostError (hboost::system::system_error &e, ServerState &state)
 Adds an error message to the log corresponding to an hboost error code. More...
 

Protected Member Functions

UT_StringHolder updateAttribName (GU_Detail *gdp, const UT_StringHolder &base_name, const UT_StringHolder &rename_pattern, const UT_StringHolder &prev_rename_pattern)
 

Friends

class MC_MocapStreamManager
 

Detailed Description

Member Typedef Documentation

typedef void(* MC_MocapStreamImpl::MC_MocapServerFunc)(ServerState &state, const ServerOptions &options, MC_MocapStreamImpl *data)

Definition at line 241 of file MC_MocapStreamImpl.h.

Constructor & Destructor Documentation

MC_MocapStreamImpl::MC_MocapStreamImpl ( MC_MocapServerFunc  f,
const ServerOptions myServerOptions 
)
virtual MC_MocapStreamImpl::~MC_MocapStreamImpl ( )
virtual

Member Function Documentation

template<typename... Args>
void MC_MocapStreamImpl::addParseError ( const char *  fmt,
Args &&...  args 
)
inline

Call this to report an error when parsing.

Definition at line 326 of file MC_MocapStreamImpl.h.

template<typename... Args>
void MC_MocapStreamImpl::addParseWarning ( const char *  fmt,
Args &&...  args 
)
inline

Call this to report a warning when parsing.

Definition at line 334 of file MC_MocapStreamImpl.h.

static void MC_MocapStreamImpl::basicTcpClient ( ServerState state,
const ServerOptions options,
MC_MocapStreamImpl data 
)
static

A function for establishing a basic TPC connection, receiving motion capture data, and passing it along to be parsed.

static void MC_MocapStreamImpl::basicUdpReceiver ( ServerState state,
const ServerOptions options,
MC_MocapStreamImpl data 
)
static

A function for establishing a basic UDP connection to a server, receiving motion capture data, and passing it along to be parsed.

virtual void MC_MocapStreamImpl::buildSkeleton ( GU_Detail ,
UT_StringHolder  name 
)
pure virtual

Appends the skeleton's geometry to the gdp The theActorAttribName attribute should store the name of the skeleton, and the name attribute will store the names of each joint.

Implemented in HDK_Sample::MocapStreamRokokoHDK.

void MC_MocapStreamImpl::clear ( )

Removes all actors/skeletons.

virtual UT_UniquePtr<MC_MocapStreamImpl> MC_MocapStreamImpl::clone ( const ServerOptions opts)
pure virtual
bool MC_MocapStreamImpl::cook ( GU_Detail gdp,
uint64 skeleton_version,
fpreal  time,
const MC_MocapStreamCookParms cookparms,
const MC_MocapStreamCookParms prev_cookparms,
bool &  is_killed 
)

The main entry point into MocapStreamImpl for creating or updating a SOP's skeleton geometry. Returns true if it has successfully parsed new data.

virtual int MC_MocapStreamImpl::expirationCount ( )
virtual

Each time we sucessfully parse a packet we increment a counter, if receivedSkeleton has not been called the last 'expirationCount' of successful parses then we will remove the skeleton. Return -1 to disable this.

const UT_ArrayStringMap<exint>& MC_MocapStreamImpl::getActorMap ( )
static void MC_MocapStreamImpl::getBoostErrorMessage ( hboost::system::error_code  e,
UT_StringHolder err_msg 
)
static

Gets the error message corresponding to an hboost error code.

static void MC_MocapStreamImpl::getBoostErrorMessage ( hboost::system::system_error e,
UT_StringHolder err_msg 
)
static

Gets the error message corresponding to an hboost error code.

static void MC_MocapStreamImpl::handleBoostError ( hboost::system::error_code  e,
ServerState state 
)
static

Adds an error message to the log corresponding to an hboost error code.

Examples:
mocapstream/MocapStreamRokokoHDK.C.
static void MC_MocapStreamImpl::handleBoostError ( hboost::system::system_error e,
ServerState state 
)
static

Adds an error message to the log corresponding to an hboost error code.

bool MC_MocapStreamImpl::hasHitError ( )

Used to determine if the stream has run into an error.

virtual const char* MC_MocapStreamImpl::label ( ) const
pure virtual

The label for a subclass's mocap stream device which appears in the "Device" menu on the MocapStream SOP.

Implemented in HDK_Sample::MocapStreamRokokoHDK.

virtual const char* MC_MocapStreamImpl::name ( ) const
pure virtual

The unique name used to identify a subclass's mocap stream device.

Implemented in HDK_Sample::MocapStreamRokokoHDK.

virtual bool MC_MocapStreamImpl::parsePacket ( UT_StringHolder packet,
fpreal  packet_time,
bool &  parse_incomplete 
)
pure virtual

Called for each packet received from the server. Return true when a packet which defines a pose is valid. parse_incomplete is set to true when a portion of the packet remains to be parsed. In this case, packet is set to the appropriate value to call this method again.

NOTE: If this returns true and parse_incomplete is set to true, that means that the "packet" that was passed in contained parts of more that one packet. This can occur when the data is from a constant stream that has been cut up.

Implemented in HDK_Sample::MocapStreamRokokoHDK.

void MC_MocapStreamImpl::queueServerTask ( const UT_Function< void(void *)> &  task)

Used by the main thread to queue a task for the server. The server function will access these tasks via state.myTasks so it can call them. Ensure your task functions accept the same data type your server passes into them.

Your functions should not bind any data that would be unsafe to access within the server thread.

void MC_MocapStreamImpl::rebuildSkeletons ( )
inline

Definition at line 340 of file MC_MocapStreamImpl.h.

void MC_MocapStreamImpl::receivedSkeleton ( const UT_StringHolder name)

Should be called when an actor's data has been parsed. The base class will keep track of the actors and and call build/removeSkeleton when needed.

virtual bool MC_MocapStreamImpl::removeExpiredSkeletons ( ) const
inlinevirtual

Definition at line 296 of file MC_MocapStreamImpl.h.

virtual void MC_MocapStreamImpl::removeSkeleton ( const UT_StringHolder name)
virtual

Removes the stored data for a skeleton.

Reimplemented in HDK_Sample::MocapStreamRokokoHDK.

void MC_MocapStreamImpl::renamedSkeleton ( const UT_StringHolder old_name,
const UT_StringHolder new_name 
)

Call this to let the base class know an actor's name has changed.

void MC_MocapStreamImpl::setPacketTime ( fpreal64  time)

Call this in parsePacket to specify the time in seconds of the received packet. Otherwise it will default to the time it was received This is used for timing in the recorded MotionClip.

void MC_MocapStreamImpl::startRecording ( UT_SharedPtr< MC_MocapRecorder recorder,
const MC_MocapStreamCookParms cookparms 
)

Starts recording the motion capture data and stores it in a MotionClip.

void MC_MocapStreamImpl::stopRecording ( UT_SharedPtr< MC_MocapRecorder recorder)

Stops recording the motion capture data.

UT_StringHolder MC_MocapStreamImpl::updateAttribName ( GU_Detail gdp,
const UT_StringHolder base_name,
const UT_StringHolder rename_pattern,
const UT_StringHolder prev_rename_pattern 
)
protected

Call this from updateJoints to rename any of the attributes for storing the parsed blendshapes.

virtual void MC_MocapStreamImpl::updateJoints ( GU_Detail gdp,
const MC_MocapStreamCookParms cookparms,
const MC_MocapStreamCookParms prev_cookparms 
)
pure virtual

Updates the joints' attributes in place based on the results of parsePacket you can assume that all desired skeletons have already been built in the gdp, so you should keep the same geometry, just update the attributes you need.

Implemented in HDK_Sample::MocapStreamRokokoHDK.

Friends And Related Function Documentation

friend class MC_MocapStreamManager
friend

Definition at line 76 of file MC_MocapStreamImpl.h.


The documentation for this class was generated from the following file: