FindChild and GetChild are broken

Started by Kippykip, October 23, 2017, 18:40:33

Previous topic - Next topic

Kippykip

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?

Kippykip

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

RonTek

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?


Kippykip

Quote from: RonTek on October 24, 2017, 16:44:46
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

markcwm

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) Select
' rotate_bones.bmx

Strict

Framework Openb3d.B3dglgraphics

Graphics3D DesktopWidth(),DesktopHeight()

Local camera:TCamera=CreateCamera()
Local anim_ent:TMesh=LoadAnimMesh("../media/zombie.b3d")

PositionEntity camera,0,10,-30
'Animate anim_ent,1,0.1

Local joint1:TEntity = FindChild(anim_ent,"Joint8")
Local joint2:TEntity = FindChild(anim_ent,"Joint10")
Local anim_time#=0, joint1_y#, joint2_y#


While Not KeyHit(KEY_ESCAPE)

If KeyDown(KEY_A) Then joint1_y:-1
If KeyDown(KEY_D) Then joint1_y:+1
If KeyDown(KEY_Q) Then joint2_y:-1
If KeyDown(KEY_E) Then joint2_y:+1

' unlike Blitz3d, animated meshes are deformed by UpdateWorld so to manipulate bones we must use manual animation
anim_time:+0.25
If anim_time>20 Then anim_time=2
SetAnimTime anim_ent,anim_time ' set animation frame, also disables mode
Animate anim_ent,4 ' set mode: 1=loop, 2=ping-pong, 3=one-time, 4=manual

' move bones before UpdateWorld
RotateEntity joint1,0,joint1_y,0
RotateEntity joint2,0,joint2_y,0

UpdateWorld

RenderWorld

Text 0,20,"+/- to animate, anim_time: "+anim_time
Text 0,40,"Q/W: rotate joint1, A/D: rotate joint2"

Flip
Wend
End

RonTek

nice example markcwm, thanks for sharing. btw, just a small typo with the text guide there to `Q/E`


Kippykip

#6
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
https://www.youtube.com/watch?v=CbQUARwxUR0