Fix #592
This commit is contained in:
parent
5948ef1a2a
commit
604d82eee4
@ -1,25 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2013 yvt
|
||||
|
||||
|
||||
This file is part of OpenSpades.
|
||||
|
||||
|
||||
OpenSpades is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
OpenSpades is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace spades {
|
||||
class ViewBlockSkin:
|
||||
class ViewBlockSkin:
|
||||
IToolSkin, IViewToolSkin, IBlockSkin {
|
||||
private float sprintState;
|
||||
private float raiseState;
|
||||
@ -30,57 +30,59 @@
|
||||
private Vector3 rightHand;
|
||||
private Vector3 blockColor;
|
||||
private float readyState;
|
||||
|
||||
float SprintState {
|
||||
|
||||
private float sprintStateSmooth;
|
||||
|
||||
float SprintState {
|
||||
set { sprintState = value; }
|
||||
}
|
||||
|
||||
float RaiseState {
|
||||
|
||||
float RaiseState {
|
||||
set { raiseState = value; }
|
||||
}
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
}
|
||||
|
||||
|
||||
bool IsMuted {
|
||||
set {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Matrix4 EyeMatrix {
|
||||
set { eyeMatrix = value; }
|
||||
}
|
||||
|
||||
|
||||
Vector3 Swing {
|
||||
set { swing = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vector3 LeftHandPosition {
|
||||
get {
|
||||
return leftHand;
|
||||
}
|
||||
}
|
||||
Vector3 RightHandPosition {
|
||||
Vector3 RightHandPosition {
|
||||
get {
|
||||
return rightHand;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vector3 BlockColor {
|
||||
set { blockColor = value; }
|
||||
}
|
||||
|
||||
|
||||
float ReadyState {
|
||||
set { readyState = value; }
|
||||
}
|
||||
|
||||
|
||||
private Renderer@ renderer;
|
||||
private AudioDevice@ audioDevice;
|
||||
private Model@ model;
|
||||
private Image@ sightImage;
|
||||
|
||||
|
||||
ViewBlockSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
@renderer = r;
|
||||
@audioDevice = dev;
|
||||
@ -89,10 +91,16 @@
|
||||
@sightImage = renderer.RegisterImage
|
||||
("Gfx/Sight.tga");
|
||||
}
|
||||
|
||||
|
||||
void Update(float dt) {
|
||||
float sprintStateSS = sprintState * sprintState;
|
||||
if (sprintStateSS > sprintStateSmooth) {
|
||||
sprintStateSmooth += (sprintStateSS - sprintStateSmooth) * (1.f - pow(0.001, dt));
|
||||
} else {
|
||||
sprintStateSmooth = sprintStateSS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddToScene() {
|
||||
if(readyState < .99f){
|
||||
// not ready
|
||||
@ -100,32 +108,32 @@
|
||||
rightHand = Vector3(-0.5f, 0.5f, 0.6f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Matrix4 mat = CreateScaleMatrix(0.033f);
|
||||
|
||||
if(sprintState > 0.f) {
|
||||
|
||||
if(sprintStateSmooth > 0.f) {
|
||||
mat = CreateRotateMatrix(Vector3(0.f, 0.f, 1.f),
|
||||
sprintState * -0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(Vector3(0.1f, -0.4f, -0.05f) * sprintState)
|
||||
sprintStateSmooth * -0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(Vector3(0.1f, -0.4f, -0.05f) * sprintStateSmooth)
|
||||
* mat;
|
||||
}
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(-0.3f, 0.7f, 0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(swing) * mat;
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(Vector3(-0.1f, -0.3f, 0.2f) * (1.f - raiseState))
|
||||
* mat;
|
||||
|
||||
|
||||
leftHand = mat * Vector3(5.f, -1.f, 4.f);
|
||||
rightHand = mat * Vector3(-5.5f, 3.f, -5.f);
|
||||
|
||||
|
||||
ModelRenderParam param;
|
||||
param.matrix = eyeMatrix * mat;
|
||||
param.customColor = blockColor;
|
||||
param.depthHack = true;
|
||||
renderer.AddModel(model, param);
|
||||
}
|
||||
|
||||
|
||||
void Draw2D() {
|
||||
renderer.ColorNP = (Vector4(1.f, 1.f, 1.f, 1.f));
|
||||
renderer.DrawImage(sightImage,
|
||||
@ -133,7 +141,7 @@
|
||||
(renderer.ScreenHeight - sightImage.Height) * 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IBlockSkin@ CreateViewBlockSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
return ViewBlockSkin(r, dev);
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2013 yvt
|
||||
|
||||
|
||||
This file is part of OpenSpades.
|
||||
|
||||
|
||||
OpenSpades is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
OpenSpades is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace spades {
|
||||
class ViewGrenadeSkin:
|
||||
class ViewGrenadeSkin:
|
||||
IToolSkin, IViewToolSkin, IGrenadeSkin {
|
||||
private float sprintState;
|
||||
private float raiseState;
|
||||
@ -30,57 +30,59 @@
|
||||
private Vector3 rightHand;
|
||||
private float cookTime;
|
||||
private float readyState;
|
||||
|
||||
float SprintState {
|
||||
|
||||
private float sprintStateSmooth;
|
||||
|
||||
float SprintState {
|
||||
set { sprintState = value; }
|
||||
}
|
||||
|
||||
float RaiseState {
|
||||
|
||||
float RaiseState {
|
||||
set { raiseState = value; }
|
||||
}
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
}
|
||||
|
||||
|
||||
bool IsMuted {
|
||||
set {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Matrix4 EyeMatrix {
|
||||
set { eyeMatrix = value; }
|
||||
}
|
||||
|
||||
|
||||
Vector3 Swing {
|
||||
set { swing = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vector3 LeftHandPosition {
|
||||
get {
|
||||
return leftHand;
|
||||
}
|
||||
}
|
||||
Vector3 RightHandPosition {
|
||||
Vector3 RightHandPosition {
|
||||
get {
|
||||
return rightHand;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float CookTime {
|
||||
set { cookTime = value; }
|
||||
}
|
||||
|
||||
|
||||
float ReadyState {
|
||||
set { readyState = value; }
|
||||
}
|
||||
|
||||
|
||||
private Renderer@ renderer;
|
||||
private AudioDevice@ audioDevice;
|
||||
private Model@ model;
|
||||
private Image@ sightImage;
|
||||
|
||||
|
||||
ViewGrenadeSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
@renderer = r;
|
||||
@audioDevice = dev;
|
||||
@ -89,57 +91,63 @@
|
||||
@sightImage = renderer.RegisterImage
|
||||
("Gfx/Sight.tga");
|
||||
}
|
||||
|
||||
|
||||
void Update(float dt) {
|
||||
float sprintStateSS = sprintState * sprintState;
|
||||
if (sprintStateSS > sprintStateSmooth) {
|
||||
sprintStateSmooth += (sprintStateSS - sprintStateSmooth) * (1.f - pow(0.001, dt));
|
||||
} else {
|
||||
sprintStateSmooth = sprintStateSS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddToScene() {
|
||||
Matrix4 mat = CreateScaleMatrix(0.033f);
|
||||
|
||||
|
||||
if(readyState > 0.9999) {
|
||||
float bring = 0.f;
|
||||
float pin = 0.f;
|
||||
float side = 0.f;
|
||||
|
||||
|
||||
bring = Min((readyState - 1.f) * 2.f, 1.f);
|
||||
bring = 1.f - bring;
|
||||
bring = 1.f - bring * bring;
|
||||
|
||||
|
||||
if(cookTime > 0.0001f) {
|
||||
pin = Min(cookTime * 8.f, 2.f);
|
||||
|
||||
|
||||
if(pin > 1.f) {
|
||||
side += pin - 1.f;
|
||||
bring -= (pin - 1.f) * 2.f;
|
||||
}
|
||||
}
|
||||
|
||||
if(sprintState > 0.f){
|
||||
|
||||
if(sprintStateSmooth > 0.f){
|
||||
mat = CreateRotateMatrix(Vector3(0.f, 0.f, 1.f),
|
||||
sprintState * -0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(Vector3(0.1f, -0.4f, -0.05f)
|
||||
* sprintState) * mat;
|
||||
sprintStateSmooth * -0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(Vector3(0.1f, -0.2f, -0.05f)
|
||||
* sprintStateSmooth) * mat;
|
||||
}
|
||||
mat = CreateTranslateMatrix(-0.3f - side * 0.8f,
|
||||
0.8f - bring * 0.1f, 0.45f - bring * 0.15f) * mat;
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(Vector3(-0.1f, -0.3f, 0.1f) * (1.f - raiseState))
|
||||
* mat;
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(swing) * mat;
|
||||
|
||||
|
||||
leftHand = mat * Vector3(10.f, -1.f, 10.f);
|
||||
rightHand = mat * Vector3(-3.f, 1.f, 5.f);
|
||||
|
||||
|
||||
Vector3 leftHand2 = mat * Vector3(2.f, 1.f, -2.f);
|
||||
Vector3 leftHand3 = mat * Vector3(8.f, -1.f, 10.f);
|
||||
|
||||
|
||||
if(pin < 1.f){
|
||||
leftHand = Mix(leftHand, leftHand2, pin);
|
||||
}else{
|
||||
leftHand = Mix(leftHand2, leftHand3, pin - 1.f);
|
||||
}
|
||||
|
||||
|
||||
ModelRenderParam param;
|
||||
param.matrix = eyeMatrix * mat;
|
||||
param.depthHack = true;
|
||||
@ -148,15 +156,15 @@
|
||||
// throwing
|
||||
float per = readyState;
|
||||
per = Min(per * 3.f, 1.f);
|
||||
|
||||
|
||||
// left hand shouldn't be visible
|
||||
leftHand = Vector3(0.5f, 0.5f, 0.6f);
|
||||
|
||||
|
||||
float p2 = per - 0.6f;
|
||||
p2 = 0.9f - p2 * p2 * 2.5f;
|
||||
rightHand = Vector3(-0.2f, p2, -0.9f + per * 1.8f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Draw2D() {
|
||||
renderer.ColorNP = (Vector4(1.f, 1.f, 1.f, 1.f));
|
||||
@ -165,7 +173,7 @@
|
||||
(renderer.ScreenHeight - sightImage.Height) * 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IGrenadeSkin@ CreateViewGrenadeSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
return ViewGrenadeSkin(r, dev);
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2013 yvt
|
||||
|
||||
|
||||
This file is part of OpenSpades.
|
||||
|
||||
|
||||
OpenSpades is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
OpenSpades is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace spades {
|
||||
class ViewSpadeSkin:
|
||||
class ViewSpadeSkin:
|
||||
IToolSkin, IViewToolSkin, ISpadeSkin {
|
||||
private float sprintState;
|
||||
private float raiseState;
|
||||
@ -30,57 +30,59 @@
|
||||
private Vector3 rightHand;
|
||||
private SpadeActionType actionType;
|
||||
private float actionProgress;
|
||||
|
||||
float SprintState {
|
||||
|
||||
private float sprintStateSmooth;
|
||||
|
||||
float SprintState {
|
||||
set { sprintState = value; }
|
||||
}
|
||||
|
||||
float RaiseState {
|
||||
|
||||
float RaiseState {
|
||||
set { raiseState = value; }
|
||||
}
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
|
||||
Vector3 TeamColor {
|
||||
set { teamColor = value; }
|
||||
}
|
||||
|
||||
|
||||
bool IsMuted {
|
||||
set {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Matrix4 EyeMatrix {
|
||||
set { eyeMatrix = value; }
|
||||
}
|
||||
|
||||
|
||||
Vector3 Swing {
|
||||
set { swing = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vector3 LeftHandPosition {
|
||||
get {
|
||||
return leftHand;
|
||||
}
|
||||
}
|
||||
Vector3 RightHandPosition {
|
||||
Vector3 RightHandPosition {
|
||||
get {
|
||||
return rightHand;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SpadeActionType ActionType {
|
||||
set { actionType = value; }
|
||||
}
|
||||
|
||||
|
||||
float ActionProgress {
|
||||
set { actionProgress = value; }
|
||||
}
|
||||
|
||||
|
||||
private Renderer@ renderer;
|
||||
private AudioDevice@ audioDevice;
|
||||
private Model@ model;
|
||||
private Image@ sightImage;
|
||||
|
||||
|
||||
ViewSpadeSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
@renderer = r;
|
||||
@audioDevice = dev;
|
||||
@ -89,13 +91,19 @@
|
||||
@sightImage = renderer.RegisterImage
|
||||
("Gfx/Sight.tga");
|
||||
}
|
||||
|
||||
|
||||
void Update(float dt) {
|
||||
float sprintStateSS = sprintState * sprintState;
|
||||
if (sprintStateSS > sprintStateSmooth) {
|
||||
sprintStateSmooth += (sprintStateSS - sprintStateSmooth) * (1.f - pow(0.001, dt));
|
||||
} else {
|
||||
sprintStateSmooth = sprintStateSS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddToScene() {
|
||||
Matrix4 mat = CreateScaleMatrix(0.033f);
|
||||
|
||||
|
||||
if(actionType == spades::SpadeActionType::Bash) {
|
||||
float per = 1.f - actionProgress;
|
||||
mat = CreateRotateMatrix(Vector3(1.f, 0.f, 0.f),
|
||||
@ -106,16 +114,16 @@
|
||||
actionType == spades::SpadeActionType::Dig) {
|
||||
bool first = actionType == spades::SpadeActionType::DigStart;
|
||||
float per = actionProgress;
|
||||
|
||||
|
||||
// some tunes
|
||||
const float readyFront = -0.8f;
|
||||
const float digAngle = 0.6f;
|
||||
const float readyAngle = 0.6f;
|
||||
|
||||
|
||||
float angle;
|
||||
float front = readyFront;
|
||||
float side = 1.f;
|
||||
|
||||
|
||||
if(per < 0.5f) {
|
||||
if(first) {
|
||||
// bringing to the dig position
|
||||
@ -137,41 +145,41 @@
|
||||
angle = readyAngle + per * digAngle;
|
||||
front += per * 2.f;
|
||||
}
|
||||
|
||||
|
||||
mat = CreateRotateMatrix(Vector3(1.f, 0.f, 0.f),
|
||||
angle) * mat;
|
||||
mat = CreateRotateMatrix(Vector3(0.f, 0.f, 1.f),
|
||||
front * 0.15f) * mat;
|
||||
|
||||
|
||||
side *= 0.3f;
|
||||
front *= 0.1f;
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(side, front, front * 0.2f)
|
||||
* mat;
|
||||
}
|
||||
|
||||
if(sprintState > 0.f || raiseState < 1.f){
|
||||
float per = Max(sprintState, 1.f - raiseState);
|
||||
|
||||
if(sprintStateSmooth > 0.f || raiseState < 1.f){
|
||||
float per = Max(sprintStateSmooth, 1.f - raiseState);
|
||||
mat = CreateRotateMatrix(Vector3(0.f, 1.f, 0.f),
|
||||
per * 1.3f) * mat;
|
||||
mat = CreateTranslateMatrix(Vector3(0.3f, -0.4f, -0.1f) * per)
|
||||
* mat;
|
||||
}
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(0.f, (1.f - raiseState) * -0.3f, 0.f) * mat;
|
||||
|
||||
|
||||
mat = CreateTranslateMatrix(-0.3f, 0.7f, 0.3f) * mat;
|
||||
mat = CreateTranslateMatrix(swing) * mat;
|
||||
|
||||
|
||||
leftHand = mat * Vector3(0.f, 0.f, 7.f);
|
||||
rightHand = mat * Vector3(0.f, 0.f, -2.f);
|
||||
|
||||
|
||||
ModelRenderParam param;
|
||||
param.matrix = eyeMatrix * mat;
|
||||
param.depthHack = true;
|
||||
renderer.AddModel(model, param);
|
||||
}
|
||||
|
||||
|
||||
void Draw2D() {
|
||||
renderer.ColorNP = (Vector4(1.f, 1.f, 1.f, 1.f));
|
||||
renderer.DrawImage(sightImage,
|
||||
@ -179,7 +187,7 @@
|
||||
(renderer.ScreenHeight - sightImage.Height) * 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ISpadeSkin@ CreateViewSpadeSkin(Renderer@ r, AudioDevice@ dev) {
|
||||
return ViewSpadeSkin(r, dev);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user