ChildModel info

Blitz3D Forums/Blitz3D Beginners Area/ChildModel info

Mr. Slat(Posted 2010) [#1]
I wanted to make a particle effect following a child of the model but I can't get the model childs position or rotation... What can I do?

Graphics3d 1024,768,32,2
entity = LoadAnimMesh(...)

for x=1 to CountChildren(Entity)
TempEntity=GetChild(Entity,x)
TempAnim=ExtractAnimSeq(TempEntity,0,10)
Animate(TempEntity,1,0.3,TempAnim)
Next

While(not(keyHit(1)))
Cls
UpdateWorld()
renderWorld()
for x=1 to CountChildren(Entity)
TempEntity=GetChild(Entity,x)
Text 1,x*12,"x "+Entityx(TempEntity)+" y "+Entityy(TempEntity)+" z "+Entityz(TempEntity)
Next
flip()
Wend


jfk EO-11110(Posted 2010) [#2]
You must parent a custom pivot to the child when the model is in static default pose. Then simply use position and rotation of the pivot.


PowerPC603(Posted 2010) [#3]
Use "EntityX(TempEntity, True)" to find the global coordinates of your children.
Using EntityX (and EntityY and EntityZ too) without the second parameter returns the local coordinates of the child, relative to the root of your entire model.


Mr. Slat(Posted 2010) [#4]
...


Mr. Slat(Posted 2010) [#5]
I have a animated character, and I wanted to make fire come out of that model child.... but the fire has to follow the model_child....


jfk EO-11110(Posted 2010) [#6]
does my suggestion not work?

something like this:


Graphics3d 1024,768,32,2
entity = LoadAnimMesh(...)


dim piv(100)

for x=1 to CountChildren(Entity)
 TempEntity=GetChild(Entity,x)
 piv(x)=createpivot()
 positionentity piv(x), entityx(TempEntity,1), entityy(TempEntity,1),  entityz(TempEntity,1), 1
 entityParent piv(x),tempentity
 ;TempAnim=ExtractAnimSeq(TempEntity,0,10) ; looks wrong to me, what's that anyway?
 ;Animate(TempEntity,1,0.3,TempAnim) ; and that?
Next

animate entity

While(not(keyHit(1)))
 Cls
 UpdateWorld()
 renderWorld()
 for x=1 to CountChildren(Entity)
 TempEntity=piv(x)
 Text 1,x*12,"x "+Entityx(TempEntity)+" y "+Entityy(TempEntity)+" z "+Entityz(TempEntity)
Next
flip()
Wend 


I think you've got something wrong there: you are animating a child? As far as I see, Animation is stored only for the top level entity of an AnimMesh.

At the other hand, it is not written in stone if all the bones you want to access are really on the first child level. You have to analyze the meshes hierarchy with some recursive code.

I would also suggest that you create only one pivot for your effect, and apply it to the hand of the character. Using a recursive search function will allow you to identify a certain Bone name, eg "L_hand". Bones in B3D are Pivots (actually a Pivot is a bone link).


Here are some samples on how to use recursive stuff like this. Eg. to set the Entitycolor etc. of an entire AnimMesh, but also a custom function for you, allowing to identify a child with a certain name (assigned in your modelling/animation app)
usage:

EntityAnimColor(mesh,red,green,blue)
or
EntityAnimAlpha(mesh,alpha#)

or in your case

kid=IndentifyChild(mesh, "L_Hand")
if kid<>0 then .....



Function IdentifyChild(m,cname$)
 If EntityClass$(m)="Pivot"
  If entityName$(m)=cname$
   return m
  endif
 Endif
 For i=1 to CountChildren(m)
  ww=GetChild(m,i)
  mkid=IdentifyChild(ww,cname$)
  if mkid<>0 then
   return mkid
  endif
 Next
End Function




Function EntityAnimColor(m,r,g,b)
 If EntityClass$(m)="Mesh"
  EntityColor m,r,g,b
 Endif
 For i=1 to CountChildren(m)
  ww=GetChild(m,i)
  EntityAnimColor(ww,r,g,b)
 Next
End Function

Function EntityAnimAlpha(m,a#)
 If EntityClass$(m)="Mesh"
  EntityAlpha m,a#
 Endif
 For i=1 to CountChildren(m)
  ww=GetChild(m,i)
  EntityAnimAlpha(ww,a#)
 Next
End Function


Then again I am not sure, maybe you can also use the Blitz Command "FindChild", maybe this is working recursively too.


jfk EO-11110(Posted 2010) [#7]
BTW, this may be essential for you:
; This recursive app will spy a Mesh Hierarchy's 
; Children Names up To 50 Generations.
Graphics3D 640,480,16,2

mesh=LoadAnimMesh("cass.3ds")
Global recursive_limit

hierarchy_tree(mesh)

WaitKey()
End

Function hierarchy_tree(m)
 If recursive_limit<=50
  recursive_limit=recursive_limit+1
  k=CountChildren(m)
  If k>0
   For i=1 To k
    m2=GetChild(m,i)
    Print String$("|",recursive_limit*3)+EntityName$(m2) + "(is a "+EntityClass$(m2)+")"
    hierarchy_tree(m2)
   Next
  EndIf
  recursive_limit=recursive_limit-1
 EndIf
End Function



puki(Posted 2010) [#8]
Hey "jfk", In your upper code, you have used ParentEntity instead of EntityParent.


jfk EO-11110(Posted 2010) [#9]
You're right, thanks. Then again. Slat didn't seem to come back anyway :)

BTW ParentEntity does exist (contrary to what the docs say), it will return the parent handle of an entity.


Mr. Slat(Posted 2010) [#10]
uoou sory haven't been here for awhile now.
My model is B3d model.
Has multiple models, for instance body/head/hair, so I have extract each model animation.

well I honestly at first sight I can't see how any of these codes will help me.