Jump to content

ambient sequence


saindd

Recommended Posts

Yes, tsStatics and PhysicsShapes at least can play their ambient sequences by default, which can be really handy for background animation on stuff in the level, without having to go to the trouble of running it all manually.


Not sure what you mean @Duion about "when you animate a model", because this is only for the ambient sequence itself, you should give other sequences their own names.

Link to comment
Share on other sites

What do you mean "there are no other sequences"?


Ambient is one sequence, with its only special behavior AFAIK being the fact that it's the sequence that gets played automatically in many cases. However each TSShape can have a large array of other named sequences, each with its own set of keyframes stored in the nodeRotations/nodeTranslations vectors.


Obviously you've done a lot of character animating, so you know about multiple sequences on a model... so I must be misunderstanding what you're saying?

Link to comment
Share on other sites

Interesting. Sorry, I'm coming at it from the code side and am apparently not familiar with the way a lot of people work. What I'm accustomed to is having a lot of individual sequence files, and then packing them on the character in the shape constructor, ie

 

function SoldierDAE::onLoad(%this)
{
  %this.addSequence("./Anims/PlayerAnim_Lurker_Back.dae Back", "Back", "0", "-1", "1", "0");
  %this.addSequence("./Anims/PlayerAnim_Lurker_Celebrate_01.dae Celebrate_01", "Celebrate_01", "0", "-1", "1", "0");
  %this.addSequence("./Anims/PlayerAnim_Lurker_Crouch_Backward.dae Crouch_Backward", "Crouch_Backward", "0", "-1", "1", "0");
  %this.addSequence("./Anims/PlayerAnim_Lurker_Crouch_Forward.dae Crouch_Forward", "Crouch_Forward", "0", "-1", "1", "0");
  ...
}

 

And then just playing them by name after that.

Link to comment
Share on other sites

I think there is some slight confusion over a single word here.


A single model can contain single or multi track animations. As far as i am aware, the first track in a model is called ambient by torque, simply because as was state earlier 'ambient' can be switched on and played automatically by a tsstatic object.


All other models have more complex animation needs, speed of animation, multiple animations, all of which can be accessed in many ways.


Single track named segments, where you name parts of the track as explained by dwarfking.

Multi track, where each animation is named and separate inside the model.


Also if you are clever regarding your skeleton and animation designs you can turn each animation into a .DSQ file in a similar way to how Chris calef describes, the advantage here is that you can use all premade animations on all new character models if the root pose and rigging are the same.


So all in all there are several ways of working

Link to comment
Share on other sites

What BloodKnight said.


I have no particular attachment to being right here, but I would not want newcomers to leave confused, and from my understanding of what's been said here and of what goes on in the engine, you're precisely not right, @Duion. I guess it depends on what you consider a "sequence", but from the engine side, each TSShape has an array of sequences, each with its own name. There doesn't even need to be an "ambient" sequence at all, if you don't name any of them "ambient".


It is true that each shape keeps one big list of all the transforms (really two lists, nodeRotations and nodeTranslations), and each sequence stores a starting point in these lists, and a number of frames. So if you want to call those lists "a sequence", then yes, all sequences are part of that, but that is the only way I see in which you could be considered "right". It seems more helpful to me, however, to treat individual sequences, having separate names and being stored in separate dsq files, as distinct and not as one big sequence, since the only real connection is that internally they are all kept in a big list.

Edited by chriscalef
Link to comment
Share on other sites

Okay, I'm very sorry to keep beating this horse, but it is absolutely not dead yet, and it keeps kicking me. :-) After all the years I've been with Torque, I get very disturbed when I learn new "rules" that I've never heard of before, and I intend to lay this one to rest here and now.


The issue we are discussing with the ambient sequence has to be an exporter issue, not an engine issue. I have admittedly almost no knowledge of any of the Torque exporters, because I am not an artist and don't work with exporters, so someone will have to fill me in on which one(s) do this thing of forcing all sequences into one named "ambient".


But in the engine itself, there is *nothing* magical about the ambient sequence except for the fact that it often gets played by default. TSShape has a function called write(), with which you can save the model to a dts file, and when you do this on a shape that has sequences loaded, all of the sequences get saved out, with their names, and there is no stuffing them into or introduction of a special sequence called ambient. Here is a model with four named sequences, none of them ambient, created with a cs file and independent dsq files.


http://opensimearth.com/images/screenshots/m4_with_seqs.jpg


Here is the cs file with which I constructed this model, and to the left you'll see the new model I saved with the write() function, called M4_seqs.


http://opensimearth.com/images/screenshots/m4_cs.jpg


You will also note that there is no M4_seqs.cs file, meaning when I next load this model into the engine via creating a new TSStatic, it will have no shape constructor to load sequences. Here is my new model, with four working sequences, none of them named ambient.


http://opensimearth.com/images/screenshots/m4_export.jpg


And just to make sure the horse is good and dead, here's a screenshot from hexedit, examining the M4_seqs.dts file itself to make sure the sequence names are all there, and ambient is not. (Look toward the middle of the column on the right, you'll see TPose, root, idle etc.)


http://opensimearth.com/images/screenshots/m4_hexedit.jpg


So, while I do not doubt that one or more of the exporters force you to do this thing, I trust I have made it clear enough that the engine does nothing of the sort. Ambient is entirely optional, and it is very much possible to store multiple named sequences in a dts file without any of them being called ambient.


PS: if anyone wants to know how to use TSShape::write, it's very easy. Here's a sample method I put into PhysicsShape, but you could do a similar thing from TSStatic or ShapeBase or many other places.

 


DefineEngineMethod( PhysicsShape, write, void,  (const char *filename),,
  "@brief \n\n")
{
FileStream *outstream;
TSShape *kShape = object->mShapeInst->getShape();
if ((outstream = FileStream::createAndOpen(filename, Torque::FS::File::Write))==NULL) {
	Con::printf("whoops, name no good!"); 
} else {
	kShape->write(outstream);
	outstream->close();
}	
}

Link to comment
Share on other sites

@chriscalef

The question remains how the sequences got there, are they just renamed sequences that has been split up from the ambient sequence like frame 1-19, frame 20-30 etc or a list of animations exported to a single file and then combined again into one file.

Link to comment
Share on other sites

The answer is number two. TSShape::write saves a dts model that has sequences loaded onto it from individual dsqs, assembled with a shapeConstructor. When this model is written out, it exports as a list of separate sequences, with no necessity for even one of them to be named ambient. When you reload this file, it loads all its sequences in a list, there is no combining them into one ambient sequence and then breaking them up again.


Again, I am only speaking of what the engine does, however, with TSShape::write. What you are experiencing, I'm guessing, is a convention used by your particular exporter. As stated, I spend most of my time in Visual Studio and don't know much about the exporters, and I also don't own any of the art tools beyond Blender, so I'll have to leave it to others to figure out which of the exporter(s) do this thing.

Link to comment
Share on other sites

Interesting. Well, it must be the blender exporter doing it, then, because Torque definitely does not do that. Can you send me a sample dts that you've exported from blender with sequences on it? Or check it out yourself in hexedit - it's free and it will tell you what's on the actual dts file, without ever loading it into Torque.

Link to comment
Share on other sites

I only export as collada, since .dts is not supported, there are only really old exporters out there and I don't want to use the ancient blender version needed for it.

But it is not the export process, since by default you only have one timeline in blender to animate on, if you want more, you need to make another scene or model, or use the action strip editor which can have multiple timelines, but no idea if they can be exported and interpreted well in the engine, I don't think anyone ever tried this.

Link to comment
Share on other sites

Ah, well that's it then! Interesting. There's an "action strip" editor? I know literally nothing about blender, I've fired it up to convert some models and that's the extent of it so far. :-p


But being open source, I'm sure it wouldn't be that much of a stretch for somebody to add independent sequence support. Or just keep working around it, since you've got a functional workaround already.


You could also use that tsshape::write function to save it the model with individual sequences, after you've already split your ambient sequence once using your current method.

Link to comment
Share on other sites

Aha! Issue located! And, apologies, it *is* in the engine. :oops: But it is not a property of the dts format, it is coming from the collada importer.


Apparently, if your collada file has animations organized into "clips", then it will load your sequences with their own names, otherwise it puts together all the "library animations" into one default clip it names "ambient".


Here's the relevant source, from ts/collada/colladaImport.cpp:

 


DefineConsoleFunction( enumColladaForImport, bool, (const char * shapePath, const char * ctrl), , 
...

  // Get animation count
  for (S32 i = 0; i < root->getLibrary_animation_clips_array().getCount(); i++)
  {
     const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[i];
     stats.numClips += libraryClips->getAnimation_clip_array().getCount();
     for (S32 j = 0; j < libraryClips->getAnimation_clip_array().getCount(); j++)
     {
        domAnimation_clip* clip = libraryClips->getAnimation_clip_array()[j];
        tree->insertItem(animsID, _GetNameOrId(clip), "animation", "", 0, 0);
     }
  }
  if (stats.numClips == 0)
  {
     // No clips => check if there are any animations (these will be added to a default clip)
     for (S32 i = 0; i < root->getLibrary_animations_array().getCount(); i++)
     {
        const domLibrary_animations* libraryAnims = root->getLibrary_animations_array()[i];
        if (libraryAnims->getAnimation_array().getCount())
        {
           stats.numClips = 1;
           tree->insertItem(animsID, "ambient", "animation", "", 0, 0);
           break;
        }
     }
  }

 

So blender must be saving out anims as library anims instead of as clips, I guess.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...