Download

Setup guide for C++?

Is there any quick start guide for using the Vive in C++? I have my controllers tracked and HMD moving around just fine via blueprints following the quick start guide on the wiki, but I don’t like trying to program in blueprints, it’s tedious…

Anyway, I haven’t figured out how to get everything setup in a C++ pawn… I need Chaperone and Motion controllers. I’ve looked into some of the engine source code, but I’m not experienced enough ti figure this all out.

Are there any guides for this already out there? (I looked), or has anyone does this before than can help me out?

I don’t know too much about the proper way to implement Chaperone, but all you need to get started with Vive in C++ is include HeadMountedDisplay.h, IMotionController.h, and MotionControllerComponent.h to your character class. Declare an HMD and enable positional tracking. Then just attach two motioncontroller components and a camera component to the root component or some other base parent. You’ll also have to assign left/right enums to differentiate the motioncontroller components, and attach/assign meshes to the motioncontroller components so you can see them, and hook up inputs.

hey minderaser, any success on setting up vive in c++ ?

The chaperone works without any additional set up in my C++ project. Otherwise porting from the blueprints to C++ is pretty straight forward

To your build.cs file add Headmounted display ie

PublicDependencyModuleNames.AddRange(new string] { “AIModule”, “Core”, “CoreUObject”, “Engine”, “HeadMountedDisplay”, “InputCore”, “OnlineSubsystem”, “OnlineSubsystemUtils” });

Add your motion controllers to your pawn (or player controller is what I perferred, but to follow the BP example do it on the yourpawn.h)

UPROPERTY(EditDefaultsOnly)
class UMotionControllerComponent* LeftMotionController;

UPROPERTY(EditDefaultsOnly)
class UMotionControllerComponent* RightMotionController;

and initialize them in the constuctor

RootSceneComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT(“RootSceneComponent”));
RootComponent = RootSceneComponent;
LeftMotionController = ObjectInitializer.CreateDefaultSubobject<UMotionControllerComponent>(this, TEXT(“LeftMotionController”));
LeftMotionController->AttachParent = RootComponent;

//Same for Right

CameraComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT(“PlayerCameraComponent”));
CameraComponent->AttachParent = RootComponent;

BaseEyeHeight = 0.0f;

let me know if you need more detail, I’d post full source but I’m working professionally on VR so am careful about posting too much

Did you figured out yourself the code you just posted?
I ask because in others very difficult to find projects, the PublicDependencyModuleNames.AddRange line is different. For example: { “Core”, “CoreUObject”, “Engine”, “InputCore” }
or at the end they have “SteamVR”,“SteamVRController”, all this using USceneComponent, UMotionControllerComponent,etc as you showed us.
Therefore my question: Why you used “OnlineSubsystem”, “OnlineSubsystemUtils” statements? wich new methods you have with those modules you declared? And why you need them? There is any API Doc?