Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdenCullen committed Nov 15, 2014
2 parents 20d68de + e3cb87f commit 0eea55a
Show file tree
Hide file tree
Showing 46 changed files with 5,223 additions and 3,990 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ os:
- linux
- osx
env:
# - DMD_VER=2.065.0 DUB_VER=0.9.21
- DMD_VER=2.066.0 DUB_VER=0.9.21
- DMD_VER=2.066.0 DUB_VER=0.9.22
install:
- bash .travis/setup_linux.sh
- bash .travis/setup_osx.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Dash Logo](https://cloud.githubusercontent.com/assets/512416/2726786/6618d624-c5c2-11e3-9049-23637e5a1739.png)](https://github.com/Circular-Studios/Dash/wiki)

# [![Build Status](http://img.shields.io/travis/Circular-Studios/Dash/develop.svg?style=flat)](https://travis-ci.org/Circular-Studios/Dash) [![Docs](http://img.shields.io/badge/docs-ddoc-yellow.svg?style=flat)](http://circular-studios.github.io/Dash/docs/latest) [![Gitter Chat](http://img.shields.io/badge/chat-gitter-brightgreen.svg?style=flat)](https://gitter.im/Circular-Studios/Dash) [![Release](http://img.shields.io/github/release/Circular-Studios/Dash.svg?style=flat)](http://code.dlang.org/packages/dash)
# [![Build Status](http://img.shields.io/travis/Circular-Studios/Dash/develop.svg?style=flat)](https://travis-ci.org/Circular-Studios/Dash) [![Docs](http://img.shields.io/badge/docs-ddoc-yellow.svg?style=flat)](http://circularstudios.com/dash/api/latest/) [![Gitter Chat](http://img.shields.io/badge/chat-gitter-brightgreen.svg?style=flat)](https://gitter.im/Circular-Studios/Dash) [![Release](http://img.shields.io/github/release/Circular-Studios/Dash.svg?style=flat)](http://code.dlang.org/packages/dash)

If you're reading this page, chances are you fall into one of the following categories:

Expand Down
15 changes: 10 additions & 5 deletions dub.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash",
"description": "A 3D game engine in dlang.",
"description": "A free and open 3D game engine written in D.",
"copyright": "Circular Studios 2013 - 2014",
"license": "MIT",
"homepage": "http://circularstudios.com",
Expand All @@ -21,10 +21,12 @@
"derelict-fi": "~>1.0",
"derelict-assimp3": "~>1.0",
"dyaml": "~>0.5",
"gl3n" : "~master",
"dlogg": "~>0.3",
"gl3n": "==1.0.0",
"gfm:sdl2": "==1.3.8",
"logger": "==0.3.3",
"colorize": "==1.0.5",
"msgpack-d": "==0.9.2",
"vibe-d": "==0.7.21-alpha.4",
"vibe-d": "0.7.21-rc.4",
"x11": { "version": "~>1.0", "optional": true }
},

Expand All @@ -35,7 +37,10 @@
"sourcePaths": [ "source/" ],
"importPaths": [ "source/" ],

"versions": [ "VibeCustomMain" ],
"versions": [
"DashUseGl3n",
"VibeCustomMain"
],

"-ddoxFilterArgs": [ "--min-protection=Protected" ],

Expand Down
85 changes: 50 additions & 35 deletions source/dash/components/animation.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,62 @@
*/
module dash.components.animation;
import dash.core.properties;
import dash.components.component;
import dash.components;
import dash.utility;

import derelict.assimp3.assimp;
import gl3n.linalg;
import std.string: fromStringz;
import std.conv: to;

mixin( registerComponents!() );

/**
* Animation object which handles all animation specific to the gameobject
*/
class Animation : Component
{
private:
/// Asset animation that the gameobject is animating based off of
AssetAnimation _animationData;
@ignore
AnimationData _animationData;
/// Current animation out of all the animations in the asset animation
@ignore
int _currentAnim;
/// Current time of the animation
@ignore
float _currentAnimTime;
/// Bone transforms for the current pose
mat4[] _currBoneTransforms;
@ignore
mat4f[] _currBoneTransforms;
/// If the gameobject should be animating
@ignore
bool _animating;

/// Animation to return to if _animateOnce is true
@ignore
int _returnAnimation;
/// If the animation is animating once, then returning to _returnAnimation
@ignore
bool _animateOnce;

public:
/// Bone transforms for the current pose (Passed to the shader)
mixin( Property!_currBoneTransforms );

this()
{
_currentAnim = 0;
_currentAnimTime = 0.0f;
_animating = true;
}

/**
* Create animation object based on asset animation
*/
this( AssetAnimation assetAnimation )
this( AnimationData assetAnimation )
{
_currentAnim = 0;
_currentAnimTime = 0.0f;
this();
_animationData = assetAnimation;
_animating = true;
}

/**
Expand Down Expand Up @@ -107,7 +120,7 @@ public:
_currentAnimTime = startAnimTime;
}
else
logWarning( "Could not change to new animation, the animation did not exist." );
warning( "Could not change to new animation, the animation did not exist." );
}
/**
* Runs an animation once, then returns
Expand All @@ -122,7 +135,7 @@ public:
_currentAnimTime = 0;
}
else
logWarning( "Could not change to new animation, the animation did not exist." );
warning( "Could not change to new animation, the animation did not exist." );
}

/**
Expand All @@ -137,7 +150,7 @@ public:
/**
* Stores the animation skeleton/bones, stores the animations poses, and makes this information accessible to gameobjects
*/
class AssetAnimation
class AnimationData : Asset
{
private:
/// List of animations, containing all of the information specific to each
Expand Down Expand Up @@ -165,8 +178,10 @@ public:
* mesh = Assimp mesh/bone object
* nodeHierarchy = Hierarchy of bones/filler nodes used for the animation
*/
this( const(aiAnimation**) animations, int numAnimations, const(aiMesh*) mesh, const(aiNode*) nodeHierarchy )
this( Resource res, const(aiAnimation**) animations, int numAnimations, const(aiMesh*) mesh, const(aiNode*) nodeHierarchy )
{
super( res );

for( int i = 0; i < nodeHierarchy.mNumChildren; i++)
{
string name = nodeHierarchy.mChildren[ i ].mName.data.ptr.fromStringz().to!string;
Expand Down Expand Up @@ -307,17 +322,17 @@ public:
*
* Returns: The boneTransforms, returned to the gameobject animation component
*/
mat4[] getTransformsAtTime( int animationNumber, float time )
mat4f[] getTransformsAtTime( int animationNumber, float time )
{
mat4[] boneTransforms = new mat4[ _numberOfBones ];
mat4f[] boneTransforms = new mat4f[ _numberOfBones ];

// Check shader/model
for( int i = 0; i < _numberOfBones; i++)
{
boneTransforms[ i ] = mat4.identity;
boneTransforms[ i ] = mat4f.identity;
}

fillTransforms( animationSet[ animationNumber ].bonePoses, boneTransforms, boneHierarchy, time, mat4.identity );
fillTransforms( animationSet[ animationNumber ].bonePoses, boneTransforms, boneHierarchy, time, mat4f.identity );

return boneTransforms;
}
Expand All @@ -330,18 +345,18 @@ public:
* time = The animations current time
* parentTransform = The parents transform (which effects this bone)
*/
void fillTransforms( BonePose[] bonePoses, mat4[] transforms, Bone bone, float time, mat4 parentTransform )
void fillTransforms( BonePose[] bonePoses, mat4f[] transforms, Bone bone, float time, mat4f parentTransform )
{
BonePose bonePose = bonePoses[ bone.boneNumber ];
mat4 finalTransform;
mat4f finalTransform;
if( bonePose.positionKeys.length == 0 && bonePose.rotationKeys.length == 0 && bonePose.scaleKeys.length == 0 )
{
finalTransform = parentTransform * bone.nodeOffset;
transforms[ bone.boneNumber ] = finalTransform * bone.offset;
}
else
{
mat4 boneTransform = mat4.identity;
mat4f boneTransform = mat4f.identity;

if( bonePose.positionKeys.length > cast(int)time )
{
Expand All @@ -351,7 +366,7 @@ public:
}
if( bonePose.rotationKeys.length > cast(int)time )
{
boneTransform = boneTransform * bonePose.rotationKeys[ cast(int)time ].to_matrix!( 4, 4 );
boneTransform = boneTransform * bonePose.rotationKeys[ cast(int)time ].toMatrix!4;
}
if( bonePose.scaleKeys.length > cast(int)time )
{
Expand All @@ -372,21 +387,21 @@ public:
}

/**
* Converts a aiVectorKey[] to vec3[].
* Converts a aiVectorKey[] to vec3f[].
*
* Params:
* quaternions = aiVectorKey[] to be converted
* numKeys = Number of keys in vector array
*
* Returns: The vectors in vector[] format
*/
vec3[] convertVectorArray( const(aiVectorKey*) vectors, int numKeys )
vec3f[] convertVectorArray( const(aiVectorKey*) vectors, int numKeys )
{
vec3[] keys;
vec3f[] keys;
for( int i = 0; i < numKeys; i++ )
{
aiVector3D vector = vectors[ i ].mValue;
keys ~= vec3( vector.x, vector.y, vector.z );
keys ~= vec3f( vector.x, vector.y, vector.z );
}

return keys;
Expand All @@ -400,13 +415,13 @@ public:
*
* Returns: The quaternions in quat[] format
*/
quat[] convertQuat( const(aiQuatKey*) quaternions, int numKeys )
quatf[] convertQuat( const(aiQuatKey*) quaternions, int numKeys )
{
quat[] keys;
quatf[] keys;
for( int i = 0; i < numKeys; i++ )
{
aiQuatKey quaternion = quaternions[ i ];
keys ~= quat( quaternion.mValue.w, quaternion.mValue.x, quaternion.mValue.y, quaternion.mValue.z );
keys ~= quatf( quaternion.mValue.w, quaternion.mValue.x, quaternion.mValue.y, quaternion.mValue.z );
}

return keys;
Expand All @@ -419,9 +434,9 @@ public:
*
* Returns: The matrix in mat4 format
*/
mat4 convertAIMatrix( aiMatrix4x4 aiMatrix )
mat4f convertAIMatrix( aiMatrix4x4 aiMatrix )
{
mat4 matrix = mat4.identity;
mat4f matrix = mat4f.identity;

matrix[0][0] = aiMatrix.a1;
matrix[0][1] = aiMatrix.a2;
Expand All @@ -446,7 +461,7 @@ public:
/**
* Shutdown the animation bone/pose data
*/
void shutdown()
override void shutdown()
{

}
Expand All @@ -465,9 +480,9 @@ public:
*/
class BonePose
{
vec3[] positionKeys;
quat[] rotationKeys;
vec3[] scaleKeys;
vec3f[] positionKeys;
quatf[] rotationKeys;
vec3f[] scaleKeys;
}
/**
* A bone in the animation, storing everything it needs
Expand All @@ -484,7 +499,7 @@ public:
int boneNumber;
Bone[] children;

mat4 offset;
mat4 nodeOffset;
mat4f offset;
mat4f nodeOffset;
}
}
Loading

0 comments on commit 0eea55a

Please sign in to comment.