March 20, 2019, 03:57:43 AM

Author Topic: FindChild and GetChild are broken  (Read 1133 times)

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
FindChild and GetChild are broken
« on: October 23, 2017, 06:40:33 PM »
I've been working on making lipsyncing in my project, however when I begin to use 3D models I find out that FindChild and GetChild don't work at all.  :o
In regular Blitz3D I can move and rotate the childs fine, as long as it's after updateworld.
However in MiniB3D nothing happens at all, I can't even hide the child. However it finds the child without a crash so I'm not sure what's going on.
Does anyone know of a fix?

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FindChild and GetChild are broken
« Reply #1 on: October 24, 2017, 04:24:31 AM »
It looks like I can get the current positions of the bones etc with FindChild, but I can't actually set them.
Which makes it difficult for me to hold objects on my V_Model (such as a grenade or brick), turn NPC heads when you're nearby, or move the mouth.

So it's half broken

Offline RonTek

  • Sr. Member
  • ****
  • Posts: 357
Re: FindChild and GetChild are broken
« Reply #2 on: October 24, 2017, 04:44:46 PM »
Hey KippyKip, I haven't tried MiniB3D on Max that much (only the Monkey-X version), but I think you could search for improved versions with fixes posted on the old forums/archives. Is this also an issue with OpenB3D?


Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FindChild and GetChild are broken
« Reply #3 on: October 24, 2017, 05:08:07 PM »
Hey KippyKip, I haven't tried MiniB3D on Max that much (only the Monkey-X version), but I think you could search for improved versions with fixes posted on the old forums/archives. Is this also an issue with OpenB3D?
Yeah I tested this on OpenB3D, same issue

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 351
Re: FindChild and GetChild are broken
« Reply #4 on: October 25, 2017, 12:48:06 AM »
Hi,

this works in Openb3d but doesn't seem to in Minib3d. Angros added a manual animation mode (4) as animation is a little different than Blitz3d. In Openb3d the mesh is deformed by UpdateWorld which also handles animation, this means you have to use manual animation with SetAnimTime which also disabled the mode, so restart it with Animate m,4. The other difference with Blitz3d is bones need to be moved before UpdateWorld.

Code: BlitzMax
  1. ' rotate_bones.bmx
  2.  
  3. Strict
  4.  
  5. Framework Openb3d.B3dglgraphics
  6.  
  7. Graphics3D DesktopWidth(),DesktopHeight()
  8.  
  9. Local camera:TCamera=CreateCamera()
  10. Local anim_ent:TMesh=LoadAnimMesh("../media/zombie.b3d")
  11.  
  12. PositionEntity camera,0,10,-30
  13. 'Animate anim_ent,1,0.1
  14.  
  15. Local joint1:TEntity = FindChild(anim_ent,"Joint8")
  16. Local joint2:TEntity = FindChild(anim_ent,"Joint10")
  17. Local anim_time#=0, joint1_y#, joint2_y#
  18.  
  19.  
  20. While Not KeyHit(KEY_ESCAPE)
  21.  
  22.         If KeyDown(KEY_A) Then joint1_y:-1
  23.         If KeyDown(KEY_D) Then joint1_y:+1
  24.         If KeyDown(KEY_Q) Then joint2_y:-1
  25.         If KeyDown(KEY_E) Then joint2_y:+1
  26.        
  27.         ' unlike Blitz3d, animated meshes are deformed by UpdateWorld so to manipulate bones we must use manual animation
  28.         anim_time:+0.25
  29.         If anim_time>20 Then anim_time=2
  30.         SetAnimTime anim_ent,anim_time ' set animation frame, also disables mode
  31.         Animate anim_ent,4 ' set mode: 1=loop, 2=ping-pong, 3=one-time, 4=manual
  32.        
  33.         ' move bones before UpdateWorld
  34.         RotateEntity joint1,0,joint1_y,0
  35.         RotateEntity joint2,0,joint2_y,0
  36.        
  37.         UpdateWorld
  38.        
  39.         RenderWorld
  40.        
  41.         Text 0,20,"+/- to animate, anim_time: "+anim_time
  42.         Text 0,40,"Q/W: rotate joint1, A/D: rotate joint2"
  43.        
  44.         Flip
  45. Wend
  46. End
  47.  

Offline RonTek

  • Sr. Member
  • ****
  • Posts: 357
Re: FindChild and GetChild are broken
« Reply #5 on: October 26, 2017, 11:15:31 AM »
nice example markcwm, thanks for sharing. btw, just a small typo with the text guide there to `Q/E`


Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FindChild and GetChild are broken
« Reply #6 on: October 27, 2017, 09:30:59 AM »
I'm thinking of starting a fork of MiniB3D, as I've changed quite at lot of the MiniB3D source for my game at this point.
I've been working on a UpdateBones(Entity:TEntity) function and so far it's working quite well, I'm just implementing rotation now. It basically sets all the bones in the entity to the current EntityXYZ coordinates.

I've also modified minib3d to have an extra texture flag that turns off the blinear filter so it's pixelated, and prevented a array out of bounds error with models with a incorrect brush count.
So should I upload it if I clean up some of the functions and finish the changed code?

EDIT: I finished UpdateBones! HORRAY!
Here's a demo