Mesh Animation

Development directions, tasks, and features being actively implemented or pursued by the development team.
Post Reply
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Mesh Animation

Post by strook »

Ok, guys here is an update. I don't want put it into the seamless flight thread cause this is another theme.

If you want to create animated meshes like walking ground units, or capital ships with opening hangar doors, radar turrets, etc. Here is the thread for it.

What I've found out is that it is possible and on the way, I'm debugging it right now.

What I need from you is animated mesh data and the actions you want to be implemented.( hangardoor open, turrets, etc.)

Then the ai code to exec an animation has to be implemented, what isn't my part, cause I have no idea of it.

The way you can supply the data is:
1. Create an animation with modeling software like blender that can save .obj files.
2. Save every single frame to an .obj file and name the files like this schema "model_action_aniXX.obj" e.g. Vulture_walk_ani21.obj . 21 is the number of the frame which must count from 0 to the end of the animation.
3. Use UnitConverter to create mesh files in a directory. You add all the .obj files to the workspace call the unit by it's Basename e.g. "Vulture". If you have multiple animations, just add it all to the single unit, it will be copied to the "Vulture" folder and recognized to be seperated by the action extension. If you mess accidently the order up yo add them, np, every frame will become a separate .bfxm file. - I know this isn't very good behavior, maybe Someone will implement the submesh feature in unitconverter in the future.
4. We have to discuss what ai for which action shall be implemented and find someone who does it.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
Deus Siddis
Elite
Elite
Posts: 1363
Joined: Sat Aug 04, 2007 3:42 pm

Re: Mesh Animation

Post by Deus Siddis »

Very nice. I'll integrate animations into all the relevant content I create in the future. And make ground units a near future goal.
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

I have messed up my units.cvs. np for me I can download it again, but that let me think about integrating them into vs.
I'll try the loadmesh func to load the animation files from a subfolder of the mesh dir tomorrow.
I think it would be better that you define a single mesh which is loaded in when the unit is created.
Then convert the animation data with unitconverter but don't press the 'copy to datadir' button and don't save unit preferences in the unit screen for it.
Simply copy all .bfxm files of the animation data to a subfolder in the mesh folder that has the same name as the unit.
I hope this will do it and be stable.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

loading in of the meshes is good, but the animation won't run.

i don't know what i did wrong maybe you have a look on it....

Code: Select all


===================================================================
--- src/cmd/unit_generic.cpp	(revision 12931)
+++ src/cmd/unit_generic.cpp	(working copy)
@@ -1209,6 +1209,48 @@
     return un+".csv";
 }
 #endif
+
+//helper func for Init
+string toLowerCase( string in )
+{
+    string out;
+    for(int i = 0; i < in.length(); i++)
+    {
+        switch(in[i])
+        {
+        case 'A': out +='a'; break;
+        case 'B': out +='b'; break;
+        case 'C': out +='c'; break;
+        case 'D': out +='d'; break;
+        case 'E': out +='e'; break;
+        case 'F': out +='f'; break;
+        case 'G': out +='g'; break;
+        case 'H': out +='h'; break;
+        case 'I': out +='i'; break;
+        case 'J': out +='j'; break;
+        case 'K': out +='k'; break;
+        case 'L': out +='l'; break;
+        case 'M': out +='m'; break;
+        case 'N': out +='n'; break;
+        case 'O': out +='o'; break;
+        case 'P': out +='p'; break;
+        case 'Q': out +='q'; break;
+        case 'R': out +='r'; break;
+        case 'S': out +='s'; break;
+        case 'T': out +='t'; break;
+        case 'U': out +='u'; break;
+        case 'V': out +='v'; break;
+        case 'W': out +='w'; break;
+        case 'X': out +='x'; break;
+        case 'Y': out +='y'; break;
+        case 'Z': out +='z'; break;
+        default:
+            out += in[i];
+        }
+    }
+    return out;
+}
+
 void Unit::Init( const char *filename,
                  bool SubU,
                  int faction,
@@ -1217,6 +1259,37 @@
                  int fg_subnumber,
                  string *netxml )
 {
+    std::vector< Mesh* > meshes;
+    int i = 1;
+    char count[2] = "1";
+    string dir = string(filename);
+    while(true)
+    {
+        sprintf( count, "%d", i );
+        string unit_name = toLowerCase(string(filename)) + "_";
+        if(i < 10)
+        	unit_name += "0";
+        if(i < 100)
+            unit_name += "0";
+        if(i < 1000)
+            unit_name += "0";
+        if(i < 10000)
+            unit_name += "0";
+        if(i < 100000)
+            unit_name += "0";
+
+        unit_name += count;
+        string path = dir + "/" + unit_name + ".bfxm";
+        if( FileExistsData( path, MeshFile ) != -1 )
+        {
+            Mesh *m = Mesh::LoadMesh( path.c_str(), Vector(1,1,1), faction, flightgrp );
+            i++;
+            meshes.push_back( m );
+        }
+        else
+            break;
+    }
+
     static bool UNITTAB = XMLSupport::parse_bool( vs_config->getVariable( "physics", "UnitTable", "false" ) );
     CSVRow unitRow;
     this->Unit::Init();
@@ -1353,6 +1426,15 @@
     calculate_extent( false );
     pilot->SetComm( this );
     ///	  ToggleWeapon(true);//change missiles to only fire 1
+
+    if( meshes.size() != 0 ) {
+        //FIXME:animation vars is initialized for first mesh only, not for submeshes
+        AnimationVars *av = new AnimationVars(meshdata.at(0));
+        av->addAnimation(meshes);
+        meshdata.at(0)->aniVars = av;
+        int numFrames = meshes.size();
+        cerr << "Animation data loaded for unit: " << string(filename) << " - with: " << numFrames << " frames." << endl;
+    }
 }
 
 vector< Mesh* >Unit::StealMeshes()
Index: src/cmd/planet.cpp
===================================================================
--- src/cmd/planet.cpp	(revision 12931)
+++ src/cmd/planet.cpp	(working copy)
@@ -365,11 +365,26 @@
     if (!wormhole) {
         static int stacks = XMLSupport::parse_int( vs_config->getVariable( "graphics", "planet_detail", "24" ) );
         atmospheric = !(blendSrc == ONE && blendDst == ZERO);
-        meshdata.push_back( new SphereMesh( radius, stacks, stacks, textname.c_str(), technique, NULL, inside_out, blendSrc, blendDst ) );
+  //      meshdata.push_back( new SphereMesh( radius, stacks, stacks, textname.c_str(), technique, NULL, inside_out, blendSrc, blendDst ) );
 
+    //FIXED BUG: the radius of the sphere (the surface) must be a little bit smaller than the athmosphere in order to see the athmosphere
+ //   SphereMesh* m = new SphereMesh( radius * 0.95, stacks, stacks, textname.c_str(), technique, NULL, inside_out, blendSrc, blendDst, false, 0.0, M_PI, 0.0, 2*M_PI, MIPMAP, false, false);
+
+ //   meshdata.push_back( m );
+
+        //-----------unittesting
+        string filename = "Blah2";
+        //----------------
+        Unit *u = UnitFactory::createUnit( filename.c_str(), false, faction );
+        meshdata.push_back( u->meshdata.at(0) );
+
+
         meshdata.back()->setEnvMap( GFXFALSE );
         meshdata.back()->SetMaterial( ourmat );
         meshdata.push_back( NULL );
+
+        if(u->meshdata.at(0)->aniVars)
+        u->meshdata.at(0)->aniVars->StartAnimation();
     }
     calculate_extent( false );
     if (wormhole) {
Index: src/gfx/mesh.cpp
===================================================================
--- src/gfx/mesh.cpp	(revision 12931)
+++ src/gfx/mesh.cpp	(working copy)
@@ -104,6 +104,7 @@
     draw_sequence = 0;
 
     initTechnique( "fixed" );
+    aniVars       = NULL;
 }
 
 Mesh::Mesh()
@@ -285,6 +286,11 @@
     return framespersecond;
 }
 
+GFXVertexList *Mesh::getVertexList() const
+{
+    return vlist;
+}
+
 float Mesh::getFramesPerSecond() const
 {
     return orig ? orig->framespersecond : framespersecond;
Index: src/gfx/mesh.h
===================================================================
--- src/gfx/mesh.h	(revision 12931)
+++ src/gfx/mesh.h	(working copy)
@@ -47,6 +47,96 @@
 
 #define MESH_HASTHABLE_SIZE (503)
 
+/*
+ **************************************************************************************
+ **** ANIMATION STUFF                                                       ***
+ **************************************************************************************
+ */
+class AnimationVars
+{
+protected:
+    std::vector< std::vector<Mesh *> > vecAnimations;
+
+    bool animatedMesh;
+    unsigned int activeAnimation;
+    double timeperframe;
+    unsigned int     activeMesh;
+    unsigned int     nextactiveMesh; //It is computable, but it's much more convenient this way
+    double curtime;
+
+    bool   constframerate;
+    bool   done;
+    unsigned int    loopCount;
+    bool   infiniteLoop;
+    unsigned int posInAniMeshes;
+public:
+    static vector<Mesh *> AniMeshes;
+
+    AnimationVars(Mesh *mesh) :
+    animatedMesh(true),
+    activeAnimation(0),
+    timeperframe(4.0),
+    activeMesh(0),
+    nextactiveMesh(1),
+    curtime(0.0),
+    constframerate(true),
+    done(true),
+    loopCount(0),
+    infiniteLoop(true)
+    {
+    	posInAniMeshes = AniMeshes.size();
+    	AniMeshes.push_back( mesh );
+    }
+
+    static void DrawNow();
+
+    static void UpdateAllFrame();
+
+    void clear();
+
+    ~AnimationVars() { clear(); }
+
+    void ChangeAnimation( unsigned int AnimNumber );
+
+    //set how_many_times to 0 for continuous loop animation
+    void StartAnimation( unsigned int how_many_times = 0 );
+
+    void AnimationStep( GFXVertexList *vertexList_to_modify );
+
+    void StopAnimation();
+
+    bool isAnimatedMesh() const;
+
+    unsigned int getLoopCount() const;
+
+    bool isContinuousLoop() const;
+
+    bool animationRuns() const;
+
+    int numAnimations();
+
+    void addAnimation( std::vector<Mesh *> &meshes );
+
+    void setTime( double tim );
+
+    double curTime() const;
+
+    unsigned int actAnimNumFrames() const;
+
+    double framesPerSecond() const;
+
+    bool constFrameRate() const;
+
+    void SetContinuousLoop( bool loop );
+
+    void ToggleAnimationRun( bool on );
+
+    void ToggleAnimatedMesh( bool on );
+
+    void SetAniSpeed( float speed );
+};
+
+
 // Struct polygon format returned by GetPolys, usually a triangle
 struct mesh_polygon
 {
@@ -244,6 +334,7 @@
 public: Mesh();
     Mesh( const Mesh &m );
 
+    GFXVertexList *getVertexList() const;
     float getFramesPerSecond() const;
     float getCurrentFrame() const;
     void setCurrentFrame( float );
@@ -415,6 +506,15 @@
         this->mn   = mn;
         this->mx   = mx;
     }
+/*
+**************************************************************************************
+**** ANIMATION STUFF                                                       ***
+**************************************************************************************
+*/
+    AnimationVars *aniVars;
+
+    //called to do an mesh update if needed
+    void UpdateFrame();
 };
 #endif
 
Index: src/gfx/mesh_gfx.cpp
===================================================================
--- src/gfx/mesh_gfx.cpp	(revision 12931)
+++ src/gfx/mesh_gfx.cpp	(working copy)
@@ -398,6 +398,7 @@
         if (orig->refcount == 0)
             delete[] orig;
     }
+    delete aniVars;
 }
 
 void Mesh::Draw( float lod, const Matrix &m, float toofar, int cloak, float nebdist, unsigned char hulldamage, bool renormalize, const MeshFX*mfx ) //short fix
@@ -1886,3 +1887,165 @@
     }
 }
 
+vector<Mesh *> AnimationVars::AniMeshes;
+
+void Mesh::UpdateFrame()
+{
+    if(aniVars)
+    {
+    	double elapsed = GetElapsedTime();
+        aniVars->setTime( aniVars->curTime()+elapsed );
+
+//    if( (int)round(aniVars->curTime()) % (int)round(aniVars->framesPerSecond()) == 0 ) {
+    	aniVars->AnimationStep( vlist );
+//    }
+    }
+}
+
+void AnimationVars::UpdateAllFrame()
+{
+    for(int i = 0; i < AnimationVars::AniMeshes.size(); i++)
+    	AnimationVars::AniMeshes.at(i)->UpdateFrame();
+}
+
+void AnimationVars::DrawNow()
+{
+    for(int i = 0; i < AnimationVars::AniMeshes.size(); i++)
+    	AnimationVars::AniMeshes.at(i)->DrawNow( AniMeshes.at(i)->getNumLOD(), false );
+}
+
+void AnimationVars::addAnimation( std::vector<Mesh *> &meshes )
+{
+    if( (meshes.size() > 0) && animatedMesh )
+        vecAnimations.push_back( meshes );
+}
+
+
+void AnimationVars::StartAnimation( unsigned int how_many_times )
+{
+    ToggleAnimationRun(false);
+    if(!how_many_times)
+        infiniteLoop = true;
+    else
+        infiniteLoop = false;
+    loopCount = how_many_times;
+    activeMesh = 0;
+    nextactiveMesh = 1;
+}
+
+void AnimationVars::AnimationStep( GFXVertexList *vertexList_to_modify )
+{
+    if(!animationRuns())
+        return;
+    else if((!isContinuousLoop())&&(getLoopCount()==0)) {
+        StopAnimation();
+        return;
+    }
+    activeMesh = nextactiveMesh;
+    if(!(nextactiveMesh < actAnimNumFrames())) {
+        nextactiveMesh = 0;
+        loopCount--;
+    }
+    GFXVertex *vdst = vertexList_to_modify->BeginMutate( 0 )->vertices;
+    GFXVertexList *vlsource = vecAnimations.at(activeAnimation).at(activeMesh)->getVertexList();
+    int numvertices   = vlsource->GetNumVertices();
+
+    int numTris, numPolys;
+    vlsource->GetPolys(&vdst, &numPolys, &numTris );
+    vertexList_to_modify->EndMutate( numvertices );
+}
+
+void AnimationVars::StopAnimation()
+{
+    ToggleAnimationRun(false);
+}
+
+void AnimationVars::ChangeAnimation( unsigned int AnimNumber )
+{
+    if( (AnimNumber < numAnimations()) && isAnimatedMesh() )
+        activeAnimation = AnimNumber;
+}
+
+bool AnimationVars::isAnimatedMesh() const
+{
+    return animatedMesh;
+}
+
+void AnimationVars::setTime( double tim )
+{
+    curtime = tim;
+}
+
+double AnimationVars::curTime() const
+{
+    return curtime;
+}
+
+unsigned int AnimationVars::actAnimNumFrames() const
+{
+    return vecAnimations[activeAnimation].size();
+}
+
+double AnimationVars::framesPerSecond() const
+{
+    return 1/timeperframe;
+}
+
+bool AnimationVars::constFrameRate() const
+{
+    return constframerate;
+}
+
+void AnimationVars::SetContinuousLoop( bool loop )
+{
+    infiniteLoop = loop;
+}
+
+int AnimationVars::numAnimations()
+{
+    return vecAnimations.size();
+}
+
+void AnimationVars::ToggleAnimatedMesh( bool on )
+{
+    animatedMesh = on;
+}
+
+void AnimationVars::ToggleAnimationRun( bool on )
+{
+    done = !on;
+}
+
+void AnimationVars::SetAniSpeed( float speed )
+{
+    timeperframe = speed;
+}
+
+void AnimationVars::clear()
+{
+    for (unsigned int i = 0; i < vecAnimations.size(); i++)
+    	for(unsigned int j = 0; j < vecAnimations[i].size(); j++) {
+    		delete vecAnimations[i][j];
+    		vecAnimations[i].clear();
+    	}
+    vecAnimations.clear();
+    vector<Mesh *>::iterator pos = AniMeshes.begin();
+    pos += posInAniMeshes;
+    AniMeshes.erase(pos);
+}
+
+unsigned int AnimationVars::getLoopCount() const
+{
+    return loopCount;
+}
+
+bool AnimationVars::animationRuns() const
+{
+    return !done;
+}
+
+bool AnimationVars::isContinuousLoop() const
+{
+    return infiniteLoop;
+}
+
Index: src/gfx/mesh_server.cpp
===================================================================
--- src/gfx/mesh_server.cpp	(revision 12931)
+++ src/gfx/mesh_server.cpp	(working copy)
@@ -104,6 +104,7 @@
         if (orig->refcount == 0)
             delete[] orig;
     }
+    delete aniVars;
 }
 
 void Mesh::Draw( float lod, const Matrix &m, float toofar, int cloak, float nebdist, unsigned char damage, bool renormalize , const MeshFX*) //short fix
@@ -126,3 +127,42 @@
 void AddWarp( Unit *un, QVector, float ) {}
 void WarpTrailDraw() {}
 
+vector<Mesh *> AnimationVars::AniMeshes;
+
+void AnimationVars::clear() {}
+
+void AnimationVars::ChangeAnimation(unsigned int AnimNumber) {}
+
+void AnimationVars::StartAnimation(unsigned int how_many_times) {}
+
+void AnimationVars::AnimationStep(GFXVertexList *vertexList_to_modify) {}
+
+void AnimationVars::StopAnimation() {}
+
+bool AnimationVars::isAnimatedMesh() const {return false;}
+
+unsigned int AnimationVars::getLoopCount() const { return 0;}
+
+bool AnimationVars::isContinuousLoop() const {return true;}
+
+bool AnimationVars::animationRuns() const {return false;}
+
+void AnimationVars::addAnimation(std::vector<Mesh*> &meshes){}
+
+void AnimationVars::setTime(double tim){}
+
+double AnimationVars::curTime() const {return 0.0;}
+
+unsigned int AnimationVars::actAnimNumFrames() const {return 0;}
+
+double AnimationVars::framesPerSecond() const {return 0.0;}
+
+bool AnimationVars::constFrameRate() const {return true;}
+
+void AnimationVars::SetContinuousLoop(bool loop) {}
+
+void AnimationVars::ToggleAnimationRun(bool on){}
+
+void AnimationVars::ToggleAnimatedMesh(bool on){}
+
+void AnimationVars::SetAniSpeed(float speed){}

You do not have the required permissions to view the files attached to this post.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
Deus Siddis
Elite
Elite
Posts: 1363
Joined: Sat Aug 04, 2007 3:42 pm

Re: Mesh Animation

Post by Deus Siddis »

I'm afraid I have only a novice understanding of C++ and zero experience with VS' engine.

This probably isn't the issue, but if I recall correctly, one gotcha is that you can't have both sub units (or maybe it was sub meshes) and animation for a unit. You can only use one feature or the other for that unit.

That was with the existing mesh animation system at least. But the bigger problem with it is more that it's never been used as far as I know, so it hasn't had the testing of going through a major release.
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

i could enable it simply for the submeshes, too.
But this feature isn't used.
I'll try it today with a thread, calling the update methods.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

Loading, threading, drawing works.
I tested it today the thing still doesn't work and that's why the code above doesn't work, too, copying the data to the GFXVertexList.
I discovered that I need to set the numTris and numPolys vars in the GetPloys func.
then it should work well.
I think tomorrow I'll post a first version of mesh animation into this forum.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
charlieg
Elite Mercenary
Elite Mercenary
Posts: 1329
Joined: Thu Mar 27, 2003 11:51 pm
Location: Manchester, UK
Contact:

Re: Mesh Animation

Post by charlieg »

Good work strook! :D
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

I was testing again but no success. It won't move. I found a variable "mutable" in the constrictor, set it , no success. At least I found a func in the mesh "loadexistant" which replaces the whole mesh. For my needs the right func I thought, I used it and the mesh dissapeared in the view. Maybe this is a minor success and I need just call the draw func of the mesh.
If I only had more time.
Well I've to do this tomorrow.
Ace and www answered me not yet about having my own branch...
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

Today i've put all the Code into the Unit Class in Order to Call it's Draw func.
Also i have to seem Found the Error. Maybe it is:
1. Didn't Call the right DrawNow() func.
2.:creating an Unit and copying the meshdata into another Vector that belongs to à Planet (for Testing) invalidates the Pointers to the Unit. The Unit As Planet will Be shown, but the Data will Be modified on the Unit that is Not shown As you See here:

Code: Select all

Unit *u = UnitFactory::createUnit(...);
meshdata.push_back(u->meshdata.at(0));
I'm pretty shure this is the error since the .at() func dereferences like [].
I need to set up the unitconverter to see the unit now.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

i went off the multithreading and it worked.

here are some pics of a basic animation.

Image

i'll add it to pheonixstorms svn branch.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

here is the diff.

to add an animation, create a folder that exactly has the same name as the folder where the unit resides, and copy the .bfxm animation data into it.

it must have the extension that is generated by the blender .obj exporter (_00001.bfxm - 99999.bfxm)

and there can optionally more than one animation be obtained by a unit.

you have to seperate them by name: etc: blah_walk_00001.bfxm blah_explode_.00001.bfxm etc.
You do not have the required permissions to view the files attached to this post.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
Deus Siddis
Elite
Elite
Posts: 1363
Joined: Sat Aug 04, 2007 3:42 pm

Re: Mesh Animation

Post by Deus Siddis »

Awesome! :)
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

The folder must be placed into the data/meshes folder.
As long as you did everything right, the first animation will be started automatically by 4fps.
You can raise the speed, of course.
On my 3year old laptop , I had no framedrops with animating over 100ships.
But I'll try out, though wether i Need to copy all the Data or wether just the Reference could Be modified. This would improve the Performance over all.
Also i'll use à static Map instead than the static vector, thus enabling deletion of elements without shuffeling it up.
We need to discuss now what actions shall be implemented.
(btw. Thx to breese for his hints)
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

i have fixed all, it runs now with 20 fps good animating about 100 ships.
You do not have the required permissions to view the files attached to this post.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Turrets

Post by strook »

Turrets

after implementing basic animation, we could use the submesh feature to install moving parts on a ship. For example gun turrets.

I'll implement it on Monday.

But I don't know how to install the AI for it in the moment...
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
Deus Siddis
Elite
Elite
Posts: 1363
Joined: Sat Aug 04, 2007 3:42 pm

Re: Mesh Animation

Post by Deus Siddis »

Rotating turrets are already implemented, which probably use simple whole object rotation of some kind.

For frame based animation, organic (skin) deformations like character animation or very complex animations involving multiple axes or chained parent-child hierarchies basically require at least this complex of an animation system.

So some good possibilities could be:

Rlaan ships or stations deforming their hulls in an organic fashion, which would look really weird and cool.

People (or aliens) visibly moving around inside a ship or station, through it's windows.

The deployment of ship undercarriages or station docking interfaces or intricate door opening sequences.
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Mesh Animation

Post by pheonixstorm »

Mesh Anim code has compiled for windows. Will play for an hour or so and provided no crashes I will svn up to my branch.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

Great :mrgreen:
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Mesh Animation

Post by travists »

Pheonixstorm alerted me to this thread. Most of what I model is decidedly low polly and rough, as I tend more toward animation. That said, I'd be happy to provide the base model for testing purposes. All I need is what kind you want. A fighter, that, like the X-wing, has flight and attack modes? A docking bay has been mentioned. Opening canopy for space flight vs. landed? Or, I can just back off and let you guys figure it out and I'll just wait and see what this interesting idea spawns. I’m here and willing to lend a hand, just don’t know how firm of a hand it will be.
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

For modifications on an unit let me know what you want to implement.
for a X-wing opening it's wings for fight mode, I could modify the unit class.
Computer players could show if they are friendly if they close their wings.
The player model should always have it's wings opened cause there is no need for defining a key for it cause I assume the multiplayer part is down now and it would complicate the gameplay.

For opening/closing hangar doors contact breese or look in the "docking automate it" thread for guys who can handle docking scripts.
If you want to open/close an hagardoor, you must animate the opening of the door in a whole.
here is the pseudo code for an one-loop animation:

Code: Select all

create a base/unit w. hangars somewhere
unit *myunit = unitfactory::createunit("mybase_w_hangardoors",etc...);
myunit->pMeshAnimation->addAnimation("close_door");
...->addAnimation("open_door");
I'll have to modify/add the addAnimation func.

Code: Select all

myunit->pMeshAnimation->ChangeAnimation("close_doors");
...->StartAnimation() with arguments for one loop, not continuous, look into the code.
The doors will now be closed.
You open the doors in the same way.
you could create the inner hangar and make some docking stuff, maybe a docking maneveour like in x3.
A landing way, blinking would also be possible, but you needed phyton scripts to enable it .
Note, by default an animation has 20fps.
You can change this by calling setAniSpeed(fps) or so.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Mesh Animation

Post by klauss »

Deus Siddis wrote:I'm afraid I have only a novice understanding of C++ and zero experience with VS' engine.

This probably isn't the issue, but if I recall correctly, one gotcha is that you can't have both sub units (or maybe it was sub meshes) and animation for a unit. You can only use one feature or the other for that unit.

That was with the existing mesh animation system at least. But the bigger problem with it is more that it's never been used as far as I know, so it hasn't had the testing of going through a major release.
It's been used at least once: the wormhole animation is an animation in the VS sense.

I don't think it's worth implementing a new animation system for anything less than rigid (one bone per submesh) skeletal animation.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

Skeletial animation is simply possible:
example:
a mech with 2 arms, skeletial animated.
I could simply add the arms as submeshes and animation would be seperated from the body.
Cause every arm has it's subset of animations.
You can position the armposition in blender and export it.
I think this is the only skeletial animation we need.
We don't need subskeletons to the arms(etc.) this is not possible with this system.

I'll make the skeletial animation done when the time will come, when I have done the planetflight.
Then I'll supply some mechs.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Mesh Animation

Post by klauss »

The point is, skeletal animation is highly efficient since it only manipulates and interpolates transformation matrices (each bone is really just a transform matrix), instead of vertices. So if you want 100 keyframes, all you need is 100 matrices, instead of 100 vertex lists.

VS already supports animation by sequencing through meshes (see the wormhole effect), what would be new and useful is matrix-based animation.

Also, skeleton format should be one of the standard formats, so modellers can animate their models in blender and export them without hassle. Skeletons have hierarchies of bones, and all that has to be properly implemented. Keyframe interpolation isn't trivial either, interpolating matrices has its subtleties.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
strook
ISO Party Member
ISO Party Member
Posts: 461
Joined: Fri Sep 03, 2010 12:10 pm

Re: Mesh Animation

Post by strook »

You want too much with minor effect.
Bone animation is useful only inside the animation program like blender(I think blender has not bone animation though)
no one wants to handle matrices for animation, that would be too much work for simple things.
Also,you can hardly define wether you want to animate a steel arm for example or an human arm, where the vertices of the both submeshes are glued together. Also shall only a part of the leg move or the whole leg? And what if you want a complicated move?
Bone animation has it's opportunities in editing.
The way one implements is animate it(maybe with bones for a better animation effect) visually and export the every single frame.
A switch between a frame to another is done in my animation system simply by switching the pointer to another mesh so it is the fastest way possible.
The only thing could be the amount of mesh data.
But in today's harddisks wouldn't this be a problem.
Also, the support for new animations wasn't imlemented in unitconverter. There was no submesh support.
I found a way to load in easily submeshes and animate them.
All is packed up in a single class.
The wormhole effect is hard to understand and I didn't know wether it worked after inspecting the code...but there is no reason why we shouldn't use the submesh feature... In animating arms,legs, doors and other extensions of units.
plz visit my vegastrike project branch here

plz support VegaOgre by donating to it!

My systems: Mac mini 1, 4gig RAM;
i5 Quad Core 2400, 300mbit WLAN, 1,3Tbyte HD, 60 GB SSD,
nvidia geforce 8400gs 512MB, 6gig RAM with Ubuntu 11.4,
win7 and hackintosh installed
Post Reply