Sign in to follow this  

Create Deep-Copy from dx-sdk animation Class

Recommended Posts

I'm using microsoft .x animation class:


Sub LoadAnim(ByVal fileName As String, ByVal .....)
Dim alloc As New MyAllocateHierarchy
RootFrame = Direct3D.Mesh.LoadHierarchyFromFile(fileName, Direct3D.MeshFlags.Managed, device, alloc, Nothing)


There is a robot animation artists created and I want to have 10 of them in my game so I use:


Public robot1AnimCLS As MySkinanim= New SkinMeshCLS.MySkinanim

robot1AnimCLS.LoadAnim(CharPaths & "\Robot.X")
robot2AnimCLS.LoadAnim(CharPaths & "\Robot.X")
robot3AnimCLS.LoadAnim(CharPaths & "\Robot.X")
robot10AnimCLS.LoadAnim(CharPaths & "\Robot.X")


This works fine , But this is so time consuming( 10 sec for each of them).

you know robot2AnimCLS=robot1AnimCLS doesn't work beacuse they point to the same part of memory.
I also try shallow copy using:


robot2AnimCLS = DirectCast(robot1AnimCLS.ShallowCopy, MySkinanim)

where in my anim class :


Public Function ShallowCopy() As MySkinanim
Return DirectCast(Me.MemberwiseClone(), MySkinanim)
End Function

This Works Fine for some of my class peroperties but the BIG problem is:


Dim RootFrame As Direct3D.AnimationRootFrame


which I can't have a seperate copy of it

So it seems I need a deep copy of my class And I don't know how to do that without using:
Direct3D.Mesh.LoadHierarchyFromFile (which is time consuming...)

Any ideas how to create seperate copy of my robot animation?
Or am I wrong using deep copy ?

Share this post

Link to post
Share on other sites
If you render your mesh to a vertex buffer first, with the animation applied . You only need 1 mesh of that type of object for all the same meshes. This way the skinned mesh is rendered using the vertex buffer all ready transformed. I'm at work now I'll get back when I get home.
Look up instancing to vertex buffers.

Share this post

Link to post
Share on other sites

If you render your mesh to a vertex buffer first...

Thanks for your answer .

I don't want to use that technology for this project.

don't forget that each robot may playing different position of track .

I already know what is instancing of a mesh , my problem is create a seperate copy of my animation class .

Share this post

Link to post
Share on other sites

sorry got it wrong. need Dx 10 or above.

you use stream out. and yes each buffer has its own track being played.


anyway if your looping through the list of meshes when you render. All you would need to do is call each objects GetcurrentanimationSet(if you have this)then animate that mesh and then render.


but if they only have on track and you want to play the animations at a different time stamp.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this