diff --git a/res/model/archer/archer.c3b b/res/model/archer/archer.c3b index d93da491..c8cd0229 100644 Binary files a/res/model/archer/archer.c3b and b/res/model/archer/archer.c3b differ diff --git a/res/model/dragon/dragon.c3b b/res/model/dragon/dragon.c3b index 230eb096..bb814f7b 100644 Binary files a/res/model/dragon/dragon.c3b and b/res/model/dragon/dragon.c3b differ diff --git a/res/model/knight/knight.c3b b/res/model/knight/knight.c3b index 5da843ae..92aedd14 100644 Binary files a/res/model/knight/knight.c3b and b/res/model/knight/knight.c3b differ diff --git a/res/model/mage/mage.c3b b/res/model/mage/mage.c3b index 125d065d..508d9cb6 100644 Binary files a/res/model/mage/mage.c3b and b/res/model/mage/mage.c3b differ diff --git a/res/model/rat/rat.c3b b/res/model/rat/rat.c3b index 150599cc..0ced8741 100644 Binary files a/res/model/rat/rat.c3b and b/res/model/rat/rat.c3b differ diff --git a/res/model/slime/slime.c3b b/res/model/slime/slime.c3b index 4d6a8b51..b2b906df 100644 Binary files a/res/model/slime/slime.c3b and b/res/model/slime/slime.c3b differ diff --git a/res/shader3D/SkinnedOutline.vert b/res/shader3D/SkinnedOutline.vert index fdf40e7a..f1b16605 100755 --- a/res/shader3D/SkinnedOutline.vert +++ b/res/shader3D/SkinnedOutline.vert @@ -1,73 +1,72 @@ attribute vec3 a_position; attribute vec3 a_normal; -attribute vec4 a_blendWeight; +attribute lowp vec4 a_blendWeight; attribute vec4 a_blendIndex; attribute vec2 a_texCoord; uniform float OutlineWidth; -const int SKINNING_JOINT_COUNT = 60; +const int SKINNING_JOINT_COUNT = 8; // Uniforms uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3]; // Varyings varying vec2 TextureCoordOut; -vec4 SkinnedVec3(vec4 vec) -{ - float blendWeight = a_blendWeight[0]; +struct SSkinningTransform { + vec4 row_one; + vec4 row_two; + vec4 row_three; +}; + +SSkinningTransform GenerateSkinningTransform() { + SSkinningTransform skinning_transform; + lowp float blendWeight = a_blendWeight[0]; int matrixIndex = int (a_blendIndex[0]) * 3; - vec4 matrixPalette1 = u_matrixPalette[matrixIndex] * blendWeight; - vec4 matrixPalette2 = u_matrixPalette[matrixIndex + 1] * blendWeight; - vec4 matrixPalette3 = u_matrixPalette[matrixIndex + 2] * blendWeight; - - + skinning_transform.row_one = u_matrixPalette[matrixIndex] * blendWeight; + skinning_transform.row_two = u_matrixPalette[matrixIndex + 1] * blendWeight; + skinning_transform.row_three = u_matrixPalette[matrixIndex + 2] * blendWeight; + blendWeight = a_blendWeight[1]; - if (blendWeight > 0.0) - { + if (blendWeight > 0.0) { matrixIndex = int(a_blendIndex[1]) * 3; - matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight; - matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight; - matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight; + skinning_transform.row_one += u_matrixPalette[matrixIndex] * blendWeight; + skinning_transform.row_two += u_matrixPalette[matrixIndex + 1] * blendWeight; + skinning_transform.row_three += u_matrixPalette[matrixIndex + 2] * blendWeight; + blendWeight = a_blendWeight[2]; + + if (blendWeight > 0.0) { + matrixIndex = int(a_blendIndex[2]) * 3; + skinning_transform.row_one += u_matrixPalette[matrixIndex] * blendWeight; + skinning_transform.row_two += u_matrixPalette[matrixIndex + 1] * blendWeight; + skinning_transform.row_three += u_matrixPalette[matrixIndex + 2] * blendWeight; + blendWeight = a_blendWeight[3]; + + if (blendWeight > 0.0) { + matrixIndex = int(a_blendIndex[3]) * 3; + skinning_transform.row_one += u_matrixPalette[matrixIndex] * blendWeight; + skinning_transform.row_two += u_matrixPalette[matrixIndex + 1] * blendWeight; + skinning_transform.row_three += u_matrixPalette[matrixIndex + 2] * blendWeight; + } + } } - - - blendWeight = a_blendWeight[2]; - if (blendWeight > 0.0) - { - matrixIndex = int(a_blendIndex[2]) * 3; - matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight; - matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight; - matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight; - } - - - blendWeight = a_blendWeight[3]; - if (blendWeight > 0.0) - { - matrixIndex = int(a_blendIndex[3]) * 3; - matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight; - matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight; - matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight; - } - + return skinning_transform; +} - vec4 _skinnedPosition; - vec4 postion = vec; - _skinnedPosition.x = dot(postion, matrixPalette1); - _skinnedPosition.y = dot(postion, matrixPalette2); - _skinnedPosition.z = dot(postion, matrixPalette3); - _skinnedPosition.w = postion.w; - - return _skinnedPosition; +vec3 SkinnedVector(vec3 input_vector, SSkinningTransform skinning_transform) { + vec3 skinned_vector; + skinned_vector.x = dot(vec4(input_vector, 1.0), skinning_transform.row_one); + skinned_vector.y = dot(vec4(input_vector, 1.0), skinning_transform.row_two); + skinned_vector.z = dot(vec4(input_vector, 1.0), skinning_transform.row_three); + return skinned_vector; } void main() { - vec4 pos = CC_MVPMatrix * SkinnedVec3(vec4(a_position,1.0)); - - vec4 normalproj = CC_MVPMatrix * vec4(SkinnedVec3(vec4(a_normal,0.0)).xyz, 0); + SSkinningTransform skinning_transform = GenerateSkinningTransform(); + vec4 pos = CC_MVPMatrix * vec4(SkinnedVector(a_position, skinning_transform), 1.0); + vec4 normalproj = CC_MVPMatrix * vec4(SkinnedVector(a_normal, skinning_transform), 0.0); normalproj = normalize(normalproj); pos.xy += normalproj.xy * (OutlineWidth * (pos.z * 0.5 + 0.5)); diff --git a/src/GameMaster.lua b/src/GameMaster.lua index c4caa993..1af66484 100644 --- a/src/GameMaster.lua +++ b/src/GameMaster.lua @@ -11,7 +11,7 @@ require "Archer" --require "Boss" local gloableZOrder = 1 -local monsterCount = {dragon=1,slime=7,piglet=2,rat = 0} --rat count must be 0. +local monsterCount = {dragon=1,slime=8,piglet=0,rat = 0} --rat count must be 0. local EXIST_MIN_MONSTER = 4 local scheduleid local stage = 0 diff --git a/src/actors/Archer.lua b/src/actors/Archer.lua index 68375a78..26d510b5 100644 --- a/src/actors/Archer.lua +++ b/src/actors/Archer.lua @@ -118,10 +118,11 @@ function Archer:init3D() self:initPuff() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setScale(1.6) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) self:setDefaultEqt() end diff --git a/src/actors/Dragon.lua b/src/actors/Dragon.lua index 75c1c63e..a9bfd7ef 100644 --- a/src/actors/Dragon.lua +++ b/src/actors/Dragon.lua @@ -83,10 +83,11 @@ function Dragon:init3D() self:initShadow() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setScale(10) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) end -- init Dragon animations============================= diff --git a/src/actors/Knight.lua b/src/actors/Knight.lua index fb2ced89..7366079a 100644 --- a/src/actors/Knight.lua +++ b/src/actors/Knight.lua @@ -135,10 +135,11 @@ function Knight:init3D() self:initPuff() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setScale(25) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) self:setDefaultEqt() end diff --git a/src/actors/Mage.lua b/src/actors/Mage.lua index 2b538e6b..f9e82a9c 100644 --- a/src/actors/Mage.lua +++ b/src/actors/Mage.lua @@ -75,10 +75,11 @@ function Mage:init3D() self:initPuff() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setScale(1.9) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) self:setDefaultEqt() end diff --git a/src/actors/Piglet.lua b/src/actors/Piglet.lua index 4dd4c0e2..4ef8229c 100644 --- a/src/actors/Piglet.lua +++ b/src/actors/Piglet.lua @@ -67,10 +67,11 @@ function Piglet:init3D() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setTexture("model/piglet/zhu0928.jpg") self._sprite3d:setScale(1.3) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) end -- init Piglet animations============================= diff --git a/src/actors/Rat.lua b/src/actors/Rat.lua index cddd9e7f..55e19ce9 100644 --- a/src/actors/Rat.lua +++ b/src/actors/Rat.lua @@ -54,10 +54,11 @@ function Rat:init3D() self:initShadow() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setScale(20) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) end -- init Rat animations============================= diff --git a/src/actors/Slime.lua b/src/actors/Slime.lua index 1213b8b6..a2821fb9 100644 --- a/src/actors/Slime.lua +++ b/src/actors/Slime.lua @@ -63,10 +63,11 @@ function Slime:init3D() self._sprite3d = cc.EffectSprite3D:create(file) self._sprite3d:setTexture("model/slime/baozi.jpg") self._sprite3d:setScale(17) - self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) + --self._sprite3d:addEffect(cc.V3(0,0,0),CelLine, -1) self:addChild(self._sprite3d) self._sprite3d:setRotation3D({x = 90, y = 0, z = 0}) self._sprite3d:setRotation(-90) + self._sprite3d:setOpacity(255) end -- function Slime:walkMode()