Skeleton-Mesh lib VertexBoneAssignment(), bug?

Everything related to 3D programming
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by Psychophanta »

Function 'VertexBoneAssignment()' it seems that it does not attend to its 'Weight.f' parameter for the bone index 0:
as i understand, when this parameter is near to 0.0 there should result in almost no modification of those vertexes white rotating or moving the bone, but the effect is the same than a max value, i.e. 'Weight'=1.0
Test:

Code: Select all

InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll"):InitSprite():InitKeyboard():InitMouse()
OpenWindow(0, 0,0, 1280,720, "[Esc] to end",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
CreateCamera(0, 0, 0, 100, 100):MoveCamera(0,0,1,4):CameraLookAt(0,0,0,0):CameraBackColor(0,$446666)
CreateLight(0,$ffffff, 10, 10, 0)
CreateShaderMaterial(0,#PB_Material_ColorShader)
SetMaterialColor(0,#PB_Material_AmbientColor|#PB_Material_DiffuseColor,$4455ff):MaterialShininess(0,64,$ffffff)
MaterialCullingMode(0,#PB_Material_NoCulling)
;creacion del esqueleto
CreateCylinder(0,0.2,1,6,4,0):TransformMesh(0,0,1/2,0,1,1,1,0,0,0,0)
CreateSkeleton(0)
;juntas del esqueleto:
CreateSphere(10,0.05)
CreateMaterial(10,0,$eeeeee)
junta$="junta"
CreateBone(0,junta$,"",0,0,0,0,0,0,0,#PB_Orientation_PitchYawRoll)
CreateEntity(10,MeshID(10),MaterialID(10))
for i.a=0 to 13
  VertexBoneAssignment(0,0,i,0,0.001); <- This command does not listen to its 'Weight.f' parameter:
  ;to assign bone index 0 an influence of 0.001 to first 14 vertexes of the mesh
  ;should result in almost no modification of those vertexes white rotating the bone,
  ;but the effect is the same than a max value, i.e. 'Weight'=1.0
Next
FinishBoneAssignment(0,0)
CreateEntity(0,MeshID(0),MaterialID(0))
MaterialShadingMode(0,#PB_Material_Wireframe)
Repeat:While WindowEvent():Wend
  ExamineKeyboard():ExamineMouse()
  MouseX.f=MouseDeltaX()*5E-2:MouseY.f=MouseDeltaY()*5E-2
  RotateCamera(0,MouseY.f,MouseX.f,0,#PB_Relative)
  MoveCamera(0,0,0,MouseWheel())
  EnableManualEntityBoneControl(0,junta$,1,1)
  RotateEntityBone(0,junta$,0,0,1,#PB_Relative)
  RenderWorld()
  FlipBuffers():Delay(11)
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by miso »

Not confirmed. There is only one bone affecting the vertices, the weight is considered as 1 (full control). The first bone is considered as root bone ( bone that has no parent ). Usually we do not assign any vertices to it, use it as a base of your skeleton, and use the child bones for that matter.

Here's the code I used for test:

Code: Select all

InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll"):InitSprite():InitKeyboard():InitMouse()
OpenWindow(0, 0,0, 1280,720, "[Esc] to end",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
CreateCamera(0, 0, 0, 100, 100):MoveCamera(0,0,1,4):CameraLookAt(0,0,0,0):CameraBackColor(0,$446666)
CreateLight(0,$ffffff, 10, 10, 0)
CreateShaderMaterial(0,#PB_Material_ColorShader)
SetMaterialColor(0,#PB_Material_AmbientColor|#PB_Material_DiffuseColor,$4455ff):MaterialShininess(0,64,$ffffff)
MaterialCullingMode(0,#PB_Material_NoCulling)
;creacion del esqueleto
CreateCylinder(0,0.2,1,6,4,0):TransformMesh(0,0,1/2,0,1,1,1,0,0,0,0)
CreateSkeleton(0)
;juntas del esqueleto:
CreateSphere(10,0.05)
CreateMaterial(10,0,$eeeeee)
junta$="junta"
junta2$="junta2"
CreateBone(0,junta$,"",0,0,0,0,0,0,0,#PB_Orientation_PitchYawRoll)
CreateBone(0,junta2$,junta$,0,1,0,0,0,0,0,#PB_Orientation_PitchYawRoll)
CreateEntity(10,MeshID(10),MaterialID(10))
For i.a=0 To 26
  VertexBoneAssignment(0,0,i,0,0.9); <- This command does not listen to its 'Weight.f' parameter:
  VertexBoneAssignment(0,0,i,1,0.1); <- This command does not listen to its 'Weight.f' parameter:

  ;to assign bone index 0 an influence of 0.001 to first 14 vertexes of the mesh
  ;should result in almost no modification of those vertexes white rotating the bone,
  ;but the effect is the same than a max value, i.e. 'Weight'=1.0
Next
FinishBoneAssignment(0,0)
CreateEntity(0,MeshID(0),MaterialID(0))
MaterialShadingMode(0,#PB_Material_Wireframe)
Repeat:While WindowEvent():Wend
  ExamineKeyboard():ExamineMouse()
  MouseX.f=MouseDeltaX()*5E-2:MouseY.f=MouseDeltaY()*5E-2
  RotateCamera(0,MouseY.f,MouseX.f,0,#PB_Relative)
  MoveCamera(0,0,0,MouseWheel())
  EnableManualEntityBoneControl(0,junta$,1,1)
  EnableManualEntityBoneControl(0,junta2$,1,1)
  RotateEntityBone(0,junta$,0,0,1,#PB_Relative)
  RotateEntityBone(0,junta2$,1,1,0,#PB_Relative)
  RenderWorld()
  FlipBuffers():Delay(11)
Until KeyboardPushed(#PB_Key_Escape)
User avatar
Caronte3D
Addict
Addict
Posts: 1361
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by Caronte3D »

seems a bug to me
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by DarkDragon »

miso wrote: Tue Aug 27, 2024 5:09 am Not confirmed. There is only one bone affecting the vertices, the weight is considered as 1 (full control). The first bone is considered as root bone ( bone that has no parent ). Usually we do not assign any vertices to it, use it as a base of your skeleton, and use the child bones for that matter.
I know there are engines which do it that way, but the cleaner way is the integration of bones into the scene graph: every object in a scene graph usually has a transformation and a skeleton's bones are also just such objects. The transformation is multiplied along the scene graph hierarchy, so every bone counts and none are skipped.

Well, but at the end it doesn't matter much whether there is an additional bone to put in or not, but for usability it would be better if it wasn't necessary.
bye,
Daniel
User avatar
Caronte3D
Addict
Addict
Posts: 1361
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by Caronte3D »

Anyway, if the weight parameter has no effect no matter what you do, it seems like a bug, doesn't it?
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by DarkDragon »

Caronte3D wrote: Tue Aug 27, 2024 12:55 pm Anyway, if the weight parameter has no effect no matter what you do, it seems like a bug, doesn't it?
Yeah but as miso said the root bone is "special" in PB Ogre as it looks like a pseudo bone which isn't weighted and counts as whole body transformation.
bye,
Daniel
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Skeleton-Mesh lib VertexBoneAssignment(), bug?

Post by miso »

Caronte3D wrote: Tue Aug 27, 2024 12:55 pm Anyway, if the weight parameter has no effect no matter what you do, it seems like a bug, doesn't it?
It has effect, but the sum of the weights must be equals 1. Root bone or not, does not matter. When a vertex is affected by multiple bones, you may split the weights between them, but the sum is always 1. With only one affecting bone, you can only have a weight of 1.
For me, still looks like OK.
Yeah but as miso said the root bone is "special" in PB Ogre as it looks like a pseudo bone which isn't weighted and counts as whole body transformation.
It works with the root bone too, its just very wierd for me to use it with weights, and not as a base of the skeleton hierarchy. But one can use it (vertices can be assigned to it), if it fit's better for what's needed.
Post Reply