mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
started working on input plugin architecture
This commit is contained in:
parent
9363ca2f97
commit
fb62fda2d2
5 changed files with 56 additions and 12 deletions
|
@ -2226,6 +2226,9 @@ void Application::loadSettings() {
|
|||
DependencyManager::get<AudioClient>()->loadSettings();
|
||||
DependencyManager::get<LODManager>()->loadSettings();
|
||||
|
||||
// DONT CHECK IN
|
||||
//DependencyManager::get<LODManager>()->setAutomaticLODAdjust(false);
|
||||
|
||||
Menu::getInstance()->loadSettings();
|
||||
_myAvatar->loadData();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
//
|
||||
// Created by Sam Gondelman on 7/13/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "InputPlugin.h"
|
17
libraries/input-plugins/src/input-plugins/InputPlugin.h
Normal file
17
libraries/input-plugins/src/input-plugins/InputPlugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// Created by Sam Gondelman on 7/13/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <plugins/Plugin.h>
|
||||
|
||||
class InputPlugin : public Plugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual bool isHandController() = 0;
|
||||
};
|
||||
|
|
@ -56,7 +56,9 @@ ViveControllerManager::ViveControllerManager() :
|
|||
_isInitialized(false),
|
||||
_isEnabled(true),
|
||||
_trackedControllers(0),
|
||||
_modelLoaded(false)
|
||||
_modelLoaded(false),
|
||||
_leftHandRenderID(0),
|
||||
_rightHandRenderID(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -144,11 +146,11 @@ void ViveControllerManager::activate() {
|
|||
|
||||
gpu::Element formatGPU = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA);
|
||||
gpu::Element formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA);
|
||||
texture = gpu::TexturePointer(
|
||||
_texture = gpu::TexturePointer(
|
||||
gpu::Texture::create2D(formatGPU, model.diffuseTexture.unWidth, model.diffuseTexture.unHeight,
|
||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
texture->assignStoredMip(0, formatMip, model.diffuseTexture.unWidth * model.diffuseTexture.unHeight * 4 * sizeof(uint8_t), model.diffuseTexture.rubTextureMapData);
|
||||
texture->autoGenerateMips(-1);
|
||||
_texture->assignStoredMip(0, formatMip, model.diffuseTexture.unWidth * model.diffuseTexture.unHeight * 4 * sizeof(uint8_t), model.diffuseTexture.rubTextureMapData);
|
||||
_texture->autoGenerateMips(-1);
|
||||
|
||||
_modelLoaded = true;
|
||||
}
|
||||
|
@ -156,21 +158,30 @@ void ViveControllerManager::activate() {
|
|||
_isInitialized = true;
|
||||
}
|
||||
|
||||
void ViveControllerManager::render(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("ViveControllerManager::render");
|
||||
void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
|
||||
PerformanceTimer perfTimer("ViveControllerManager::updateRendering");
|
||||
|
||||
if (_modelLoaded) {
|
||||
//auto controllerPayload = new render::Payload<ViveControllerManager>(this);
|
||||
//auto controllerPayloadPointer = ViveControllerManager::PayloadPointer(controllerPayload);
|
||||
//if (_leftHandRenderID == 0) {
|
||||
// _leftHandRenderID = scene->allocateID();
|
||||
// pendingChanges.resetItem(_leftHandRenderID, controllerPayloadPointer);
|
||||
//}
|
||||
//pendingChanges.updateItem(_leftHandRenderID, );
|
||||
|
||||
|
||||
UserInputMapper::PoseValue leftHand = _poseStateMap[makeInput(JointChannel::LEFT_HAND).getChannel()];
|
||||
UserInputMapper::PoseValue rightHand = _poseStateMap[makeInput(JointChannel::RIGHT_HAND).getChannel()];
|
||||
|
||||
gpu::Batch batch;
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
geometryCache->useSimpleDrawPipeline(batch);
|
||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch);
|
||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, true);
|
||||
|
||||
auto mesh = _modelGeometry.getMesh();
|
||||
batch.setInputFormat(mesh->getVertexFormat());
|
||||
//batch.setUniformTexture(0, texture);
|
||||
//batch._glBindTexture(GL_TEXTURE_2D, _uexture);
|
||||
|
||||
if (leftHand.isValid()) {
|
||||
renderHand(leftHand, batch, LEFT_HAND);
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
|
||||
#include <model/Geometry.h>
|
||||
#include <gpu/Texture.h>
|
||||
#include "plugins/Plugin.h"
|
||||
#include "InputPlugin.h"
|
||||
#include <RenderArgs.h>
|
||||
#include <render/Scene.h>
|
||||
#include "UserInputMapper.h"
|
||||
|
||||
class ViveControllerManager : public Plugin {
|
||||
class ViveControllerManager : public InputPlugin {
|
||||
public:
|
||||
virtual const QString& getName() const override;
|
||||
virtual bool isSupported() const override;
|
||||
virtual bool isHandController() { return true; }
|
||||
|
||||
/// Called when plugin is initially loaded, typically at application start
|
||||
virtual void init() override;
|
||||
|
@ -68,7 +70,7 @@ public:
|
|||
|
||||
void focusOutEvent();
|
||||
|
||||
void render(RenderArgs* args);
|
||||
void updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges);
|
||||
void update();
|
||||
|
||||
static ViveControllerManager& getInstance();
|
||||
|
@ -106,7 +108,10 @@ private:
|
|||
|
||||
bool _modelLoaded;
|
||||
model::Geometry _modelGeometry;
|
||||
gpu::TexturePointer texture;
|
||||
gpu::TexturePointer _texture;
|
||||
|
||||
int _leftHandRenderID;
|
||||
int _rightHandRenderID;
|
||||
|
||||
static const QString NAME;
|
||||
|
||||
|
|
Loading…
Reference in a new issue