Help with animated models
#1
Hi,
i have converted quite a lot of code to vb.net, all seems to work fine, but i am having an issue with one function, been scratching my head for a while i am sure it is a simple thing but i dont know what here is the function:

Code:
Private Function GenerateSkeleton(ByVal node As Node, ByVal parentSkeletonNode As SkeletonNode, ByRef boneNodesLeftToGenerate As Integer) As SkeletonNode
            If node Is Nothing Then Return Nothing
            Dim newlyCreatedSkeletonNode As SkeletonNode
            Dim boneIndex = Array.IndexOf(_allBoneNames, node.Name)

            If boneIndex >= 0 Then
                Dim assimpBone = AssimpMesh.Bones(boneIndex)
                boneNodesLeftToGenerate -= 1
                newlyCreatedSkeletonNode = New SkeletonNode(node, assimpBone, parentSkeletonNode, boneIndex:=SkeletonNodes.Count)
            Else
                newlyCreatedSkeletonNode = New SkeletonNode(node, Nothing, parentSkeletonNode, -1)
            End If

            SkeletonNodes.Add(newlyCreatedSkeletonNode)

            If node.HasChildren AndAlso boneNodesLeftToGenerate > 0 Then

                For i = 0 To node.ChildCount - 1
                    Dim childBone = GenerateSkeleton(node.Children(i), newlyCreatedSkeletonNode, boneNodesLeftToGenerate)
                    If childBone IsNot Nothing Then newlyCreatedSkeletonNode.Children.Add(childBone)
                Next
            End If

            Return newlyCreatedSkeletonNode
        End Function
the error i get no matter which file i try is:

line that errors: Dim assimpBone = AssimpMesh.Bones(boneIndex)

Exception Thrown

system.NullReferenceException: 'Object reference not set to an instance of object

Ab3d.Assimp.Skeleton.AssimpMesh.get returned Nothing.

can anyone help please
Kevan Hampson
#2
Sorted i just changed ByVal node to ByVal MYnode :)

Now i have to work out why it cannot find any animations :(

Error starting animation:
cannot find animation with name Assimp.Animation

i assume this is another variable i need to rename just got to find it :(
Kevan Hampson
#3
(01-21-2022, 07:08 PM)GraPhiX Wrote: Sorted i just changed ByVal node to ByVal MYnode :)

Now i have to work out why it cannot find any animations :(

Error starting animation:
cannot find animation with name Assimp.Animation

i assume this is another variable i need to rename just got to find it :(

think i have found the issue this C# code :
Code:
public global::Assimp.Animation SelectedAnimation { get; private set; }
i converted to this in VB.NET i dont think its quite right :
Code:
Public Property SelectedAnimation As Animation

anyone know where i have gone wrong ?
Kevan Hampson
#4
This error is thrown from the SelectAnimation method:
Code:
        public void SelectAnimation(string animationName)
        {
            if (animationName == null)
                throw new ArgumentNullException(nameof(animationName));

            var assimpAnimation = _assimpScene.Animations.FirstOrDefault(a => a.Name == animationName);

            if (assimpAnimation == null)
                throw new Exception("Cannot find animation with name " + animationName);

            SelectAnimation(assimpAnimation);
        }

As seen from the code, this error would be thrown when the SelectAnimation was called with the animationName parameter set to "Assimp.Animation" and when there was no animation in the _assimpScene.Animations with that name.

Please put a breakpoint into SelectAnimation and check where the value of animationName came from.
Andrej Benedik
#5
(01-23-2022, 10:28 PM)abenedik Wrote: This error is thrown from the SelectAnimation method:
Code:
        public void SelectAnimation(string animationName)
        {
            if (animationName == null)
                throw new ArgumentNullException(nameof(animationName));

            var assimpAnimation = _assimpScene.Animations.FirstOrDefault(a => a.Name == animationName);

            if (assimpAnimation == null)
                throw new Exception("Cannot find animation with name " + animationName);

            SelectAnimation(assimpAnimation);
        }

As seen from the code, this error would be thrown when the SelectAnimation was called with the animationName parameter set to "Assimp.Animation" and when there was no animation in the _assimpScene.Animations with that name.

Please put a breakpoint into SelectAnimation and check where the value of animationName came from.

Thank you i found the issue i had 2 SelectAnimation() functions i renamed one to MYSelectAnimation() models now load in but the animation does not display, the text information loops through the frame numbers though.

The skeleton does animate but the asset does not, i am not sure what i have missed ?

Also i think there is something wrong with FBX skeleton no matter what i do the asset is malformed when skeleton is created any other format seems ok

   
Kevan Hampson
  


Forum Jump:


Users browsing this thread:
1 Guest(s)