mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-17 11:27:05 +02:00
Fixing line endings
This commit is contained in:
parent
82c041d06a
commit
282cdadf63
18 changed files with 2702 additions and 2702 deletions
File diff suppressed because it is too large
Load diff
|
@ -231,8 +231,8 @@ const gpu::PipelinePointer& DrawOverlay3D::getOpaquePipeline() {
|
|||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setDepthTest(false);
|
||||
// additive blending
|
||||
state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
// additive blending
|
||||
state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
|
||||
_opaquePipeline.reset(gpu::Pipeline::create(program, state));
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren
|
|||
|
||||
batch.setPipeline(getOpaquePipeline());
|
||||
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
batch.setResourceTexture(0, nullptr);
|
||||
|
||||
});
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
<!
|
||||
// Skinning.slh
|
||||
// libraries/render-utils/src
|
||||
//
|
||||
// Created by Sam Gateau on 10/5/15.
|
||||
// Copyright 2013 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
|
||||
!>
|
||||
<@if not SKINNING_SLH@>
|
||||
<@def SKINNING_SLH@>
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
layout(std140) uniform skinClusterBuffer {
|
||||
mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
};
|
||||
|
||||
void skinPosition(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, out vec4 skinnedPosition) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
}
|
||||
|
||||
void skinPositionNormal(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal,
|
||||
out vec4 skinnedPosition, out vec3 skinnedNormal) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
skinnedNormal = newNormal.xyz;
|
||||
}
|
||||
|
||||
void skinPositionNormalTangent(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, vec3 inTangent,
|
||||
out vec4 skinnedPosition, out vec3 skinnedNormal, out vec3 skinnedTangent) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||
newTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
skinnedNormal = newNormal.xyz;
|
||||
skinnedTangent = newTangent.xyz;
|
||||
}
|
||||
|
||||
|
||||
<!
|
||||
// Skinning.slh
|
||||
// libraries/render-utils/src
|
||||
//
|
||||
// Created by Sam Gateau on 10/5/15.
|
||||
// Copyright 2013 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
|
||||
!>
|
||||
<@if not SKINNING_SLH@>
|
||||
<@def SKINNING_SLH@>
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
layout(std140) uniform skinClusterBuffer {
|
||||
mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
};
|
||||
|
||||
void skinPosition(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, out vec4 skinnedPosition) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
}
|
||||
|
||||
void skinPositionNormal(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal,
|
||||
out vec4 skinnedPosition, out vec3 skinnedNormal) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
skinnedNormal = newNormal.xyz;
|
||||
}
|
||||
|
||||
void skinPositionNormalTangent(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, vec3 inTangent,
|
||||
out vec4 skinnedPosition, out vec3 skinnedNormal, out vec3 skinnedTangent) {
|
||||
vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 newTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])];
|
||||
float clusterWeight = skinClusterWeight[i];
|
||||
newPosition += clusterMatrix * inPosition * clusterWeight;
|
||||
newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||
newTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
skinnedPosition = newPosition;
|
||||
skinnedNormal = newNormal.xyz;
|
||||
skinnedTangent = newTangent.xyz;
|
||||
}
|
||||
|
||||
|
||||
<@endif@>
|
|
@ -20,7 +20,7 @@
|
|||
<$declareEvalAmbientSphereGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<$declareEvalAmbientGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<$declareEvalSkyboxGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.xy, 0.0, 1.0)).st;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToEyeDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
}
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.xy, 0.0, 1.0)).st;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToEyeDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
void main(void) {
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||
}
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
void main(void) {
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||
}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec3 interpolatedNormal = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal);
|
||||
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
_normal = interpolatedNormal.xyz;
|
||||
}
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec3 interpolatedNormal = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal);
|
||||
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
_normal = interpolatedNormal.xyz;
|
||||
}
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/29/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
|
||||
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
|
||||
|
||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
}
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/29/13.
|
||||
// Copyright 2013 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 gpu/Inputs.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
|
||||
|
||||
// pass along the diffuse color
|
||||
_color = inColor.rgb;
|
||||
|
||||
// and the texture coordinates
|
||||
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
|
||||
|
||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToEyeDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
skinPosition(inSkinClusterIndex, inSkinClusterWeight, inPosition, position);
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
||||
}
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
skinPosition(inSkinClusterIndex, inSkinClusterWeight, inPosition, position);
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
||||
}
|
||||
|
|
|
@ -1,163 +1,163 @@
|
|||
//
|
||||
// DrawStatus.cpp
|
||||
// render/src/render
|
||||
//
|
||||
// Created by Niraj Venkat on 6/29/15.
|
||||
// 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 "DrawStatus.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
#include <PerfStat.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <RenderArgs.h>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
|
||||
#include "drawItemBounds_vert.h"
|
||||
#include "drawItemBounds_frag.h"
|
||||
#include "drawItemStatus_vert.h"
|
||||
#include "drawItemStatus_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
||||
|
||||
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
||||
if (!_drawItemBoundsPipeline) {
|
||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||
_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||
|
||||
// Blend on transparent
|
||||
state->setBlendFunction(true,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
||||
}
|
||||
return _drawItemBoundsPipeline;
|
||||
}
|
||||
|
||||
const gpu::PipelinePointer& DrawStatus::getDrawItemStatusPipeline() {
|
||||
if (!_drawItemStatusPipeline) {
|
||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert)));
|
||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag)));
|
||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
_drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||
_drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||
_drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus");
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||
|
||||
// Blend on transparent
|
||||
state->setBlendFunction(true,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_drawItemStatusPipeline.reset(gpu::Pipeline::create(program, state));
|
||||
}
|
||||
return _drawItemStatusPipeline;
|
||||
}
|
||||
|
||||
void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_viewFrustum);
|
||||
RenderArgs* args = renderContext->args;
|
||||
auto& scene = sceneContext->_scene;
|
||||
|
||||
// FIrst thing, we collect the bound and the status for all the items we want to render
|
||||
int nbItems = 0;
|
||||
{
|
||||
if (!_itemBounds) {
|
||||
_itemBounds = std::make_shared<gpu::Buffer>();
|
||||
}
|
||||
if (!_itemStatus) {
|
||||
_itemStatus = std::make_shared<gpu::Buffer>();;
|
||||
}
|
||||
|
||||
_itemBounds->resize((inItems.size() * sizeof(AABox)));
|
||||
_itemStatus->resize((inItems.size() * sizeof(glm::vec4)));
|
||||
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_itemStatus->editData());
|
||||
for (auto& item : inItems) {
|
||||
if (!item.bounds.isInvalid()) {
|
||||
if (!item.bounds.isNull()) {
|
||||
(*itemAABox) = item.bounds;
|
||||
} else {
|
||||
(*itemAABox).setBox(item.bounds.getCorner(), 0.1f);
|
||||
}
|
||||
auto& itemScene = scene->getItem(item.id);
|
||||
(*itemStatus) = itemScene.getStatusPackedValues();
|
||||
|
||||
nbItems++;
|
||||
itemAABox++;
|
||||
itemStatus++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nbItems == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allright, something to render let's do it
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||
args->_viewFrustum->evalViewTransform(viewMat);
|
||||
|
||||
batch.setProjectionTransform(projMat);
|
||||
batch.setViewTransform(viewMat);
|
||||
batch.setModelTransform(Transform());
|
||||
|
||||
// bind the one gpu::Pipeline we need
|
||||
batch.setPipeline(getDrawItemBoundsPipeline());
|
||||
|
||||
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_itemStatus->editData());
|
||||
|
||||
const unsigned int VEC3_ADRESS_OFFSET = 3;
|
||||
|
||||
for (int i = 0; i < nbItems; i++) {
|
||||
batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*) (itemAABox + i));
|
||||
batch._glUniform3fv(_drawItemBoundDimLoc, 1, ((const float*) (itemAABox + i)) + VEC3_ADRESS_OFFSET);
|
||||
|
||||
batch.draw(gpu::LINES, 24, 0);
|
||||
}
|
||||
|
||||
batch.setPipeline(getDrawItemStatusPipeline());
|
||||
for (int i = 0; i < nbItems; i++) {
|
||||
batch._glUniform3fv(_drawItemStatusPosLoc, 1, (const float*) (itemAABox + i));
|
||||
batch._glUniform3fv(_drawItemStatusDimLoc, 1, ((const float*) (itemAABox + i)) + VEC3_ADRESS_OFFSET);
|
||||
batch._glUniform4iv(_drawItemStatusValueLoc, 1, (const int*) (itemStatus + i));
|
||||
|
||||
batch.draw(gpu::TRIANGLES, 24, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
// DrawStatus.cpp
|
||||
// render/src/render
|
||||
//
|
||||
// Created by Niraj Venkat on 6/29/15.
|
||||
// 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 "DrawStatus.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
#include <PerfStat.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <RenderArgs.h>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
|
||||
#include "drawItemBounds_vert.h"
|
||||
#include "drawItemBounds_frag.h"
|
||||
#include "drawItemStatus_vert.h"
|
||||
#include "drawItemStatus_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
||||
|
||||
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
||||
if (!_drawItemBoundsPipeline) {
|
||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||
_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||
|
||||
// Blend on transparent
|
||||
state->setBlendFunction(true,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
||||
}
|
||||
return _drawItemBoundsPipeline;
|
||||
}
|
||||
|
||||
const gpu::PipelinePointer& DrawStatus::getDrawItemStatusPipeline() {
|
||||
if (!_drawItemStatusPipeline) {
|
||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert)));
|
||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag)));
|
||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
_drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||
_drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||
_drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus");
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||
|
||||
// Blend on transparent
|
||||
state->setBlendFunction(true,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||
|
||||
// Good to go add the brand new pipeline
|
||||
_drawItemStatusPipeline.reset(gpu::Pipeline::create(program, state));
|
||||
}
|
||||
return _drawItemStatusPipeline;
|
||||
}
|
||||
|
||||
void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_viewFrustum);
|
||||
RenderArgs* args = renderContext->args;
|
||||
auto& scene = sceneContext->_scene;
|
||||
|
||||
// FIrst thing, we collect the bound and the status for all the items we want to render
|
||||
int nbItems = 0;
|
||||
{
|
||||
if (!_itemBounds) {
|
||||
_itemBounds = std::make_shared<gpu::Buffer>();
|
||||
}
|
||||
if (!_itemStatus) {
|
||||
_itemStatus = std::make_shared<gpu::Buffer>();;
|
||||
}
|
||||
|
||||
_itemBounds->resize((inItems.size() * sizeof(AABox)));
|
||||
_itemStatus->resize((inItems.size() * sizeof(glm::vec4)));
|
||||
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_itemStatus->editData());
|
||||
for (auto& item : inItems) {
|
||||
if (!item.bounds.isInvalid()) {
|
||||
if (!item.bounds.isNull()) {
|
||||
(*itemAABox) = item.bounds;
|
||||
} else {
|
||||
(*itemAABox).setBox(item.bounds.getCorner(), 0.1f);
|
||||
}
|
||||
auto& itemScene = scene->getItem(item.id);
|
||||
(*itemStatus) = itemScene.getStatusPackedValues();
|
||||
|
||||
nbItems++;
|
||||
itemAABox++;
|
||||
itemStatus++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nbItems == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allright, something to render let's do it
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||
args->_viewFrustum->evalViewTransform(viewMat);
|
||||
|
||||
batch.setProjectionTransform(projMat);
|
||||
batch.setViewTransform(viewMat);
|
||||
batch.setModelTransform(Transform());
|
||||
|
||||
// bind the one gpu::Pipeline we need
|
||||
batch.setPipeline(getDrawItemBoundsPipeline());
|
||||
|
||||
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_itemStatus->editData());
|
||||
|
||||
const unsigned int VEC3_ADRESS_OFFSET = 3;
|
||||
|
||||
for (int i = 0; i < nbItems; i++) {
|
||||
batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const float*) (itemAABox + i));
|
||||
batch._glUniform3fv(_drawItemBoundDimLoc, 1, ((const float*) (itemAABox + i)) + VEC3_ADRESS_OFFSET);
|
||||
|
||||
batch.draw(gpu::LINES, 24, 0);
|
||||
}
|
||||
|
||||
batch.setPipeline(getDrawItemStatusPipeline());
|
||||
for (int i = 0; i < nbItems; i++) {
|
||||
batch._glUniform3fv(_drawItemStatusPosLoc, 1, (const float*) (itemAABox + i));
|
||||
batch._glUniform3fv(_drawItemStatusDimLoc, 1, ((const float*) (itemAABox + i)) + VEC3_ADRESS_OFFSET);
|
||||
batch._glUniform4iv(_drawItemStatusValueLoc, 1, (const int*) (itemStatus + i));
|
||||
|
||||
batch.draw(gpu::TRIANGLES, 24, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
//
|
||||
// DrawStatus.h
|
||||
// render/src/render
|
||||
//
|
||||
// Created by Niraj Venkat on 6/29/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_render_DrawStatus_h
|
||||
#define hifi_render_DrawStatus_h
|
||||
|
||||
#include "DrawTask.h"
|
||||
#include "gpu/Batch.h"
|
||||
|
||||
namespace render {
|
||||
class DrawStatus {
|
||||
int _drawItemBoundPosLoc = -1;
|
||||
int _drawItemBoundDimLoc = -1;
|
||||
int _drawItemStatusPosLoc = -1;
|
||||
int _drawItemStatusDimLoc = -1;
|
||||
int _drawItemStatusValueLoc = -1;
|
||||
|
||||
gpu::Stream::FormatPointer _drawItemFormat;
|
||||
gpu::PipelinePointer _drawItemBoundsPipeline;
|
||||
gpu::PipelinePointer _drawItemStatusPipeline;
|
||||
gpu::BufferPointer _itemBounds;
|
||||
gpu::BufferPointer _itemStatus;
|
||||
|
||||
public:
|
||||
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
|
||||
|
||||
typedef Job::ModelI<DrawStatus, ItemIDsBounds> JobModel;
|
||||
|
||||
const gpu::PipelinePointer& getDrawItemBoundsPipeline();
|
||||
const gpu::PipelinePointer& getDrawItemStatusPipeline();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_render_DrawStatus_h
|
||||
//
|
||||
// DrawStatus.h
|
||||
// render/src/render
|
||||
//
|
||||
// Created by Niraj Venkat on 6/29/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_render_DrawStatus_h
|
||||
#define hifi_render_DrawStatus_h
|
||||
|
||||
#include "DrawTask.h"
|
||||
#include "gpu/Batch.h"
|
||||
|
||||
namespace render {
|
||||
class DrawStatus {
|
||||
int _drawItemBoundPosLoc = -1;
|
||||
int _drawItemBoundDimLoc = -1;
|
||||
int _drawItemStatusPosLoc = -1;
|
||||
int _drawItemStatusDimLoc = -1;
|
||||
int _drawItemStatusValueLoc = -1;
|
||||
|
||||
gpu::Stream::FormatPointer _drawItemFormat;
|
||||
gpu::PipelinePointer _drawItemBoundsPipeline;
|
||||
gpu::PipelinePointer _drawItemStatusPipeline;
|
||||
gpu::BufferPointer _itemBounds;
|
||||
gpu::BufferPointer _itemStatus;
|
||||
|
||||
public:
|
||||
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
|
||||
|
||||
typedef Job::ModelI<DrawStatus, ItemIDsBounds> JobModel;
|
||||
|
||||
const gpu::PipelinePointer& getDrawItemBoundsPipeline();
|
||||
const gpu::PipelinePointer& getDrawItemStatusPipeline();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_render_DrawStatus_h
|
||||
|
|
|
@ -19,39 +19,39 @@
|
|||
uniform vec3 inBoundPos;
|
||||
uniform vec3 inBoundDim;
|
||||
|
||||
void main(void) {
|
||||
const vec4 UNIT_BOX[8] = vec4[8](
|
||||
vec4(0.0, 0.0, 0.0, 1.0),
|
||||
vec4(1.0, 0.0, 0.0, 1.0),
|
||||
vec4(0.0, 1.0, 0.0, 1.0),
|
||||
vec4(1.0, 1.0, 0.0, 1.0),
|
||||
vec4(0.0, 0.0, 1.0, 1.0),
|
||||
vec4(1.0, 0.0, 1.0, 1.0),
|
||||
vec4(0.0, 1.0, 1.0, 1.0),
|
||||
vec4(1.0, 1.0, 1.0, 1.0)
|
||||
);
|
||||
const int UNIT_BOX_LINE_INDICES[24] = int[24](
|
||||
0, 1,
|
||||
1, 3,
|
||||
3, 2,
|
||||
2, 0,
|
||||
4, 5,
|
||||
5, 7,
|
||||
7, 6,
|
||||
6, 4,
|
||||
2, 6,
|
||||
3, 7,
|
||||
0, 4,
|
||||
1, 5
|
||||
);
|
||||
vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]];
|
||||
|
||||
pos.xyz = inBoundPos + inBoundDim * pos.xyz;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
|
||||
// varTexcoord = (pos.xy + 1) * 0.5;
|
||||
void main(void) {
|
||||
const vec4 UNIT_BOX[8] = vec4[8](
|
||||
vec4(0.0, 0.0, 0.0, 1.0),
|
||||
vec4(1.0, 0.0, 0.0, 1.0),
|
||||
vec4(0.0, 1.0, 0.0, 1.0),
|
||||
vec4(1.0, 1.0, 0.0, 1.0),
|
||||
vec4(0.0, 0.0, 1.0, 1.0),
|
||||
vec4(1.0, 0.0, 1.0, 1.0),
|
||||
vec4(0.0, 1.0, 1.0, 1.0),
|
||||
vec4(1.0, 1.0, 1.0, 1.0)
|
||||
);
|
||||
const int UNIT_BOX_LINE_INDICES[24] = int[24](
|
||||
0, 1,
|
||||
1, 3,
|
||||
3, 2,
|
||||
2, 0,
|
||||
4, 5,
|
||||
5, 7,
|
||||
7, 6,
|
||||
6, 4,
|
||||
2, 6,
|
||||
3, 7,
|
||||
0, 4,
|
||||
1, 5
|
||||
);
|
||||
vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]];
|
||||
|
||||
pos.xyz = inBoundPos + inBoundDim * pos.xyz;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
|
||||
// varTexcoord = (pos.xy + 1) * 0.5;
|
||||
}
|
|
@ -1,103 +1,103 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// drawItemStatus.slv
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Sam Gateau on 6/30/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 gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
out vec4 varColor;
|
||||
|
||||
uniform vec3 inBoundPos;
|
||||
uniform vec3 inBoundDim;
|
||||
uniform ivec4 inStatus;
|
||||
|
||||
vec3 paintRainbow(float normalizedHue) {
|
||||
float v = normalizedHue * 6.f;
|
||||
if (v < 0.f) {
|
||||
return vec3(1.f, 0.f, 0.f);
|
||||
} else if (v < 1.f) {
|
||||
return vec3(1.f, v, 0.f);
|
||||
} else if (v < 2.f) {
|
||||
return vec3(1.f - (v-1.f), 1.f, 0.f);
|
||||
} else if (v < 3.f) {
|
||||
return vec3(0.f, 1.f, (v-2.f));
|
||||
} else if (v < 4.f) {
|
||||
return vec3(0.f, 1.f - (v-3.f), 1.f );
|
||||
} else if (v < 5.f) {
|
||||
return vec3((v-4.f), 0.f, 1.f );
|
||||
} else if (v < 6.f) {
|
||||
return vec3(1.f, 0.f, 1.f - (v-5.f));
|
||||
} else {
|
||||
return vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 unpackStatus(int v) {
|
||||
return vec2(clamp(float(int((v >> 0) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
|
||||
clamp(float(int((v >> 16) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0));
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
const vec2 ICON_PIXEL_SIZE = vec2(10, 10);
|
||||
const vec2 MARGIN_PIXEL_SIZE = vec2(2, 2);
|
||||
const int NUM_VERTICES = 6;
|
||||
const vec4 UNIT_QUAD[NUM_VERTICES] = vec4[NUM_VERTICES](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4(1.0, -1.0, 0.0, 1.0),
|
||||
vec4(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4(1.0, -1.0, 0.0, 1.0),
|
||||
vec4(1.0, 1.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
// anchor point in clip space
|
||||
vec4 anchorPoint = vec4(inBoundPos, 1.0) + vec4(inBoundDim, 0.0) * vec4(0.5, 0.5, 0.5, 0.0);
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, anchorPoint, anchorPoint)$>
|
||||
|
||||
// Which icon are we dealing with ?
|
||||
int iconNum = gl_VertexID / NUM_VERTICES;
|
||||
|
||||
// if invalid, just kill
|
||||
if (inStatus[iconNum] == 0xFFFFFFFF) {
|
||||
gl_Position = anchorPoint;
|
||||
varColor = vec4(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// unpack to get x and y satus
|
||||
vec2 iconStatus = unpackStatus(inStatus[iconNum]);
|
||||
|
||||
// Use the status for showing a color
|
||||
varColor = vec4(paintRainbow(abs(iconStatus.y)), 1.0);
|
||||
|
||||
// Also changes the size of the notification
|
||||
vec2 iconScale = ICON_PIXEL_SIZE;
|
||||
iconScale = max(vec2(1, 1), (iconScale * iconStatus.x));
|
||||
|
||||
//Offset icon to the right based on the iconNum
|
||||
vec2 offset = vec2(iconNum * (ICON_PIXEL_SIZE.x + MARGIN_PIXEL_SIZE.x), 0);
|
||||
|
||||
// Final position in pixel space
|
||||
int twoTriID = gl_VertexID - iconNum * NUM_VERTICES;
|
||||
vec4 pos = UNIT_QUAD[twoTriID];
|
||||
vec2 quadPixelPos = offset.xy + pos.xy * 0.5 * iconScale;
|
||||
|
||||
vec4 viewport;
|
||||
<$transformCameraViewport(cam, viewport)$>;
|
||||
vec2 pixelToClip = vec2(2.0 / viewport.z, 2.0 / viewport.w);
|
||||
gl_Position = anchorPoint + (anchorPoint.w * vec4(quadPixelPos * pixelToClip, 0.0, 0.0));
|
||||
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// drawItemStatus.slv
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Sam Gateau on 6/30/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 gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
out vec4 varColor;
|
||||
|
||||
uniform vec3 inBoundPos;
|
||||
uniform vec3 inBoundDim;
|
||||
uniform ivec4 inStatus;
|
||||
|
||||
vec3 paintRainbow(float normalizedHue) {
|
||||
float v = normalizedHue * 6.f;
|
||||
if (v < 0.f) {
|
||||
return vec3(1.f, 0.f, 0.f);
|
||||
} else if (v < 1.f) {
|
||||
return vec3(1.f, v, 0.f);
|
||||
} else if (v < 2.f) {
|
||||
return vec3(1.f - (v-1.f), 1.f, 0.f);
|
||||
} else if (v < 3.f) {
|
||||
return vec3(0.f, 1.f, (v-2.f));
|
||||
} else if (v < 4.f) {
|
||||
return vec3(0.f, 1.f - (v-3.f), 1.f );
|
||||
} else if (v < 5.f) {
|
||||
return vec3((v-4.f), 0.f, 1.f );
|
||||
} else if (v < 6.f) {
|
||||
return vec3(1.f, 0.f, 1.f - (v-5.f));
|
||||
} else {
|
||||
return vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 unpackStatus(int v) {
|
||||
return vec2(clamp(float(int((v >> 0) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
|
||||
clamp(float(int((v >> 16) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0));
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
const vec2 ICON_PIXEL_SIZE = vec2(10, 10);
|
||||
const vec2 MARGIN_PIXEL_SIZE = vec2(2, 2);
|
||||
const int NUM_VERTICES = 6;
|
||||
const vec4 UNIT_QUAD[NUM_VERTICES] = vec4[NUM_VERTICES](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4(1.0, -1.0, 0.0, 1.0),
|
||||
vec4(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4(1.0, -1.0, 0.0, 1.0),
|
||||
vec4(1.0, 1.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
// anchor point in clip space
|
||||
vec4 anchorPoint = vec4(inBoundPos, 1.0) + vec4(inBoundDim, 0.0) * vec4(0.5, 0.5, 0.5, 0.0);
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, anchorPoint, anchorPoint)$>
|
||||
|
||||
// Which icon are we dealing with ?
|
||||
int iconNum = gl_VertexID / NUM_VERTICES;
|
||||
|
||||
// if invalid, just kill
|
||||
if (inStatus[iconNum] == 0xFFFFFFFF) {
|
||||
gl_Position = anchorPoint;
|
||||
varColor = vec4(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// unpack to get x and y satus
|
||||
vec2 iconStatus = unpackStatus(inStatus[iconNum]);
|
||||
|
||||
// Use the status for showing a color
|
||||
varColor = vec4(paintRainbow(abs(iconStatus.y)), 1.0);
|
||||
|
||||
// Also changes the size of the notification
|
||||
vec2 iconScale = ICON_PIXEL_SIZE;
|
||||
iconScale = max(vec2(1, 1), (iconScale * iconStatus.x));
|
||||
|
||||
//Offset icon to the right based on the iconNum
|
||||
vec2 offset = vec2(iconNum * (ICON_PIXEL_SIZE.x + MARGIN_PIXEL_SIZE.x), 0);
|
||||
|
||||
// Final position in pixel space
|
||||
int twoTriID = gl_VertexID - iconNum * NUM_VERTICES;
|
||||
vec4 pos = UNIT_QUAD[twoTriID];
|
||||
vec2 quadPixelPos = offset.xy + pos.xy * 0.5 * iconScale;
|
||||
|
||||
vec4 viewport;
|
||||
<$transformCameraViewport(cam, viewport)$>;
|
||||
vec2 pixelToClip = vec2(2.0 / viewport.z, 2.0 / viewport.w);
|
||||
gl_Position = anchorPoint + (anchorPoint.w * vec4(quadPixelPos * pixelToClip, 0.0, 0.0));
|
||||
|
||||
}
|
|
@ -90,8 +90,8 @@ void SceneScriptingInterface::setStageSunModelEnable(bool isEnabled) {
|
|||
_skyStage->setSunModelEnable(isEnabled);
|
||||
}
|
||||
|
||||
bool SceneScriptingInterface::isStageSunModelEnabled() const {
|
||||
return _skyStage->isSunModelEnabled();
|
||||
bool SceneScriptingInterface::isStageSunModelEnabled() const {
|
||||
return _skyStage->isSunModelEnabled();
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setBackgroundMode(const QString& mode) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
//
|
||||
// TextTemplate.cpp
|
||||
// tools/shaderScribe/src
|
||||
|
@ -7,198 +7,198 @@
|
|||
// Copyright 2013 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
|
||||
#ifndef hifi_TEXT_TEMPLATE_H
|
||||
#define hifi_TEXT_TEMPLATE_H
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
|
||||
class TextTemplate {
|
||||
public:
|
||||
typedef std::shared_ptr< TextTemplate > Pointer;
|
||||
typedef std::string String;
|
||||
typedef std::vector< String > StringVector;
|
||||
typedef std::map< String, String > Vars;
|
||||
typedef std::map< String, TextTemplate::Pointer > Includes;
|
||||
|
||||
class Tag {
|
||||
public:
|
||||
enum Type {
|
||||
VARIABLE = 0,
|
||||
COMMAND,
|
||||
REMARK,
|
||||
INVALID = -1,
|
||||
};
|
||||
|
||||
static const char BEGIN = '<';
|
||||
static const char END = '>';
|
||||
|
||||
static const char VAR = '$';
|
||||
static const char COM = '@';
|
||||
static const char REM = '!';
|
||||
};
|
||||
|
||||
class Command {
|
||||
public:
|
||||
typedef std::vector< Command > vector;
|
||||
|
||||
enum Type {
|
||||
VAR = 0,
|
||||
BLOCK,
|
||||
FUNC,
|
||||
ENDFUNC,
|
||||
IFBLOCK,
|
||||
IF,
|
||||
ELIF,
|
||||
ELSE,
|
||||
ENDIF,
|
||||
FOR,
|
||||
ENDFOR,
|
||||
INCLUDE,
|
||||
DEF,
|
||||
};
|
||||
|
||||
Type type;
|
||||
std::vector< String > arguments;
|
||||
|
||||
bool isBlockEnd() {
|
||||
switch (type) {
|
||||
case ENDFUNC:
|
||||
case ENDIF:
|
||||
case ENDFOR:
|
||||
case INCLUDE:
|
||||
case DEF:
|
||||
case VAR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Block {
|
||||
public:
|
||||
typedef std::shared_ptr<Block> Pointer;
|
||||
typedef std::vector< Block::Pointer > Vector;
|
||||
|
||||
Block::Pointer parent;
|
||||
Command command;
|
||||
Vector blocks;
|
||||
std::stringstream ostr;
|
||||
|
||||
String sourceName;
|
||||
|
||||
Block(const String& sourceFilename) :
|
||||
sourceName(sourceFilename) {}
|
||||
|
||||
static void addNewBlock(const Block::Pointer& parent, const Block::Pointer& block);
|
||||
static const Block::Pointer& getCurrentBlock(const Block::Pointer& block);
|
||||
|
||||
static void displayTree(const Block::Pointer& block, std::ostream& dst, int& level);
|
||||
};
|
||||
|
||||
class Funcs {
|
||||
public:
|
||||
typedef std::map< String, Block::Pointer > map;
|
||||
|
||||
Funcs();
|
||||
~Funcs();
|
||||
|
||||
const Block::Pointer findFunc(const char* func);
|
||||
const Block::Pointer addFunc(const char* func, const Block::Pointer& root);
|
||||
|
||||
map _funcs;
|
||||
protected:
|
||||
};
|
||||
|
||||
class Config {
|
||||
public:
|
||||
typedef std::shared_ptr< Config > Pointer;
|
||||
typedef bool (*IncluderCallback) (const Config::Pointer& config, const char* filename, String& source);
|
||||
|
||||
Includes _includes;
|
||||
Funcs _funcs;
|
||||
std::ostream* _logStream;
|
||||
int _numErrors;
|
||||
IncluderCallback _includerCallback;
|
||||
StringVector _paths;
|
||||
|
||||
Config();
|
||||
|
||||
static const TextTemplate::Pointer addInclude(const Config::Pointer& config, const char* include);
|
||||
const TextTemplate::Pointer findInclude(const char* include);
|
||||
|
||||
void addIncludePath(const char* path);
|
||||
|
||||
void displayTree(std::ostream& dst, int& level) const;
|
||||
};
|
||||
|
||||
static bool loadFile(const Config::Pointer& config, const char* filename, String& source);
|
||||
|
||||
TextTemplate(const String& name, const Config::Pointer& config = std::make_shared<Config>());
|
||||
~TextTemplate();
|
||||
|
||||
// Scibe does all the job of parsing an inout template stream and then gneerating theresulting stream using the vars
|
||||
int scribe(std::ostream& dst, std::istream& src, Vars& vars);
|
||||
|
||||
int parse(std::istream& src);
|
||||
int generate(std::ostream& dst, Vars& vars);
|
||||
|
||||
const Config::Pointer config() { return _config; }
|
||||
|
||||
void displayTree(std::ostream& dst, int& level) const;
|
||||
|
||||
protected:
|
||||
Config::Pointer _config;
|
||||
Block::Pointer _root;
|
||||
int _numErrors;
|
||||
bool _steppingStarted;
|
||||
|
||||
bool grabUntilBeginTag(std::istream* str, String& grabbed, Tag::Type& tagType);
|
||||
bool grabUntilEndTag(std::istream* str, String& grabbed, Tag::Type& tagType);
|
||||
|
||||
bool stepForward(std::istream* str, String& grabbed, String& tag, Tag::Type& tagType, Tag::Type& nextTagType);
|
||||
|
||||
bool grabFirstToken(String& src, String& token, String& reminder);
|
||||
bool convertExpressionToArguments(String& src, std::vector< String >& arguments);
|
||||
bool convertExpressionToDefArguments(String& src, std::vector< String >& arguments);
|
||||
bool convertExpressionToFuncArguments(String& src, std::vector< String >& arguments);
|
||||
|
||||
// Filter between var, command or comments
|
||||
const Block::Pointer processStep(const Block::Pointer& block, String& grabbed, String& tag, Tag::Type& tagType);
|
||||
const Block::Pointer processStepVar(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepCommand(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepRemark(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Define command
|
||||
const Block::Pointer processStepDef(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// If commands
|
||||
const Block::Pointer processStepCommandIf(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandEndIf(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandElif(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandElse(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
|
||||
// Include command
|
||||
const Block::Pointer processStepInclude(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Function command
|
||||
const Block::Pointer processStepFunc(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepEndFunc(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Generation
|
||||
int generateTree(std::ostream& dst, const Block::Pointer& block, Vars& vars);
|
||||
int evalBlockGeneration(std::ostream& dst, const Block::Pointer& block, Vars& vars, Block::Pointer& branch);
|
||||
|
||||
// Errors
|
||||
std::ostream& log() { return (* _config->_logStream); }
|
||||
void logError(const Block::Pointer& block, const char* error, ...);
|
||||
};
|
||||
|
||||
#endif
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#ifndef hifi_TEXT_TEMPLATE_H
|
||||
#define hifi_TEXT_TEMPLATE_H
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
|
||||
class TextTemplate {
|
||||
public:
|
||||
typedef std::shared_ptr< TextTemplate > Pointer;
|
||||
typedef std::string String;
|
||||
typedef std::vector< String > StringVector;
|
||||
typedef std::map< String, String > Vars;
|
||||
typedef std::map< String, TextTemplate::Pointer > Includes;
|
||||
|
||||
class Tag {
|
||||
public:
|
||||
enum Type {
|
||||
VARIABLE = 0,
|
||||
COMMAND,
|
||||
REMARK,
|
||||
INVALID = -1,
|
||||
};
|
||||
|
||||
static const char BEGIN = '<';
|
||||
static const char END = '>';
|
||||
|
||||
static const char VAR = '$';
|
||||
static const char COM = '@';
|
||||
static const char REM = '!';
|
||||
};
|
||||
|
||||
class Command {
|
||||
public:
|
||||
typedef std::vector< Command > vector;
|
||||
|
||||
enum Type {
|
||||
VAR = 0,
|
||||
BLOCK,
|
||||
FUNC,
|
||||
ENDFUNC,
|
||||
IFBLOCK,
|
||||
IF,
|
||||
ELIF,
|
||||
ELSE,
|
||||
ENDIF,
|
||||
FOR,
|
||||
ENDFOR,
|
||||
INCLUDE,
|
||||
DEF,
|
||||
};
|
||||
|
||||
Type type;
|
||||
std::vector< String > arguments;
|
||||
|
||||
bool isBlockEnd() {
|
||||
switch (type) {
|
||||
case ENDFUNC:
|
||||
case ENDIF:
|
||||
case ENDFOR:
|
||||
case INCLUDE:
|
||||
case DEF:
|
||||
case VAR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Block {
|
||||
public:
|
||||
typedef std::shared_ptr<Block> Pointer;
|
||||
typedef std::vector< Block::Pointer > Vector;
|
||||
|
||||
Block::Pointer parent;
|
||||
Command command;
|
||||
Vector blocks;
|
||||
std::stringstream ostr;
|
||||
|
||||
String sourceName;
|
||||
|
||||
Block(const String& sourceFilename) :
|
||||
sourceName(sourceFilename) {}
|
||||
|
||||
static void addNewBlock(const Block::Pointer& parent, const Block::Pointer& block);
|
||||
static const Block::Pointer& getCurrentBlock(const Block::Pointer& block);
|
||||
|
||||
static void displayTree(const Block::Pointer& block, std::ostream& dst, int& level);
|
||||
};
|
||||
|
||||
class Funcs {
|
||||
public:
|
||||
typedef std::map< String, Block::Pointer > map;
|
||||
|
||||
Funcs();
|
||||
~Funcs();
|
||||
|
||||
const Block::Pointer findFunc(const char* func);
|
||||
const Block::Pointer addFunc(const char* func, const Block::Pointer& root);
|
||||
|
||||
map _funcs;
|
||||
protected:
|
||||
};
|
||||
|
||||
class Config {
|
||||
public:
|
||||
typedef std::shared_ptr< Config > Pointer;
|
||||
typedef bool (*IncluderCallback) (const Config::Pointer& config, const char* filename, String& source);
|
||||
|
||||
Includes _includes;
|
||||
Funcs _funcs;
|
||||
std::ostream* _logStream;
|
||||
int _numErrors;
|
||||
IncluderCallback _includerCallback;
|
||||
StringVector _paths;
|
||||
|
||||
Config();
|
||||
|
||||
static const TextTemplate::Pointer addInclude(const Config::Pointer& config, const char* include);
|
||||
const TextTemplate::Pointer findInclude(const char* include);
|
||||
|
||||
void addIncludePath(const char* path);
|
||||
|
||||
void displayTree(std::ostream& dst, int& level) const;
|
||||
};
|
||||
|
||||
static bool loadFile(const Config::Pointer& config, const char* filename, String& source);
|
||||
|
||||
TextTemplate(const String& name, const Config::Pointer& config = std::make_shared<Config>());
|
||||
~TextTemplate();
|
||||
|
||||
// Scibe does all the job of parsing an inout template stream and then gneerating theresulting stream using the vars
|
||||
int scribe(std::ostream& dst, std::istream& src, Vars& vars);
|
||||
|
||||
int parse(std::istream& src);
|
||||
int generate(std::ostream& dst, Vars& vars);
|
||||
|
||||
const Config::Pointer config() { return _config; }
|
||||
|
||||
void displayTree(std::ostream& dst, int& level) const;
|
||||
|
||||
protected:
|
||||
Config::Pointer _config;
|
||||
Block::Pointer _root;
|
||||
int _numErrors;
|
||||
bool _steppingStarted;
|
||||
|
||||
bool grabUntilBeginTag(std::istream* str, String& grabbed, Tag::Type& tagType);
|
||||
bool grabUntilEndTag(std::istream* str, String& grabbed, Tag::Type& tagType);
|
||||
|
||||
bool stepForward(std::istream* str, String& grabbed, String& tag, Tag::Type& tagType, Tag::Type& nextTagType);
|
||||
|
||||
bool grabFirstToken(String& src, String& token, String& reminder);
|
||||
bool convertExpressionToArguments(String& src, std::vector< String >& arguments);
|
||||
bool convertExpressionToDefArguments(String& src, std::vector< String >& arguments);
|
||||
bool convertExpressionToFuncArguments(String& src, std::vector< String >& arguments);
|
||||
|
||||
// Filter between var, command or comments
|
||||
const Block::Pointer processStep(const Block::Pointer& block, String& grabbed, String& tag, Tag::Type& tagType);
|
||||
const Block::Pointer processStepVar(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepCommand(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepRemark(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Define command
|
||||
const Block::Pointer processStepDef(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// If commands
|
||||
const Block::Pointer processStepCommandIf(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandEndIf(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandElif(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
const Block::Pointer processStepCommandElse(const Block::Pointer& block, String& grabbed, String& expression);
|
||||
|
||||
// Include command
|
||||
const Block::Pointer processStepInclude(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Function command
|
||||
const Block::Pointer processStepFunc(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
const Block::Pointer processStepEndFunc(const Block::Pointer& block, String& grabbed, String& tag);
|
||||
|
||||
// Generation
|
||||
int generateTree(std::ostream& dst, const Block::Pointer& block, Vars& vars);
|
||||
int evalBlockGeneration(std::ostream& dst, const Block::Pointer& block, Vars& vars, Block::Pointer& branch);
|
||||
|
||||
// Errors
|
||||
std::ostream& log() { return (* _config->_logStream); }
|
||||
void logError(const Block::Pointer& block, const char* error, ...);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue