holding items

Blitz3D Forums/Blitz3D Beginners Area/holding items

hello everyone, I just signed up for the forums, and this is my first post.

currently, i am working on creating an RPG, and i have managed to overcome most problems in my path but i cant figure this one out: how do you create a character mesh, that (depending on what weapon u equip) holds different things. the character mesh is moveing (and being animated) so how do i have the weapon move with his hand? like, if he runs his arm moves, and his sword has to stay in it...

by the way, if i wasnt clear, im talking about 3d

thanks

you have to parent the weapon to the Hand bone of your mesh.

It depends on what kind of mesh the character is. If it's skeletal animated (ie. a b3d file) then yeah what he said. If not, um, switch to skeletal animation with b3d file format.

well, the the 3D mesh editing program im useing isn't so good, and the only B3d compatable file format i can save as is .X

anyway, if i did manage a b3d file, how would i get blitz to recognize the hand bone and be abled to parent the weapon to it?

sorry for all the questions... im really bad with the graphics side of programming :(

JS

You could use FindChild(parent_mesh, child_name$) to get a handle to the bone:
mesh = LoadAnimMesh("something.b3d")
bone = FindChild(mesh, "handbone")
There is also GetChild, which requires an index.

Then, assign this bone as a parent to the object:
EntityParent pickobject, bone

Finally, probably you should move it a bit using MoveEntity.

If you don't know the name of the hand's bone, try this program to enlist all children:

Graphics3D 800, 600, 0, 2

mesh=LoadAnimMesh("mak_robotic.x")

printoutchildren(mesh)

Function printoutchildren(mesh)

	Print EntityName$(mesh)

	For i = 1 To CountChildren(mesh)
		g=GetChild(mesh, i)
		printoutchildren g
	Next
	
End Function


Something to bear in mind is that bones in a model loaded with Blitz3D are actually blitz3d pivot entities.

I'd suggest experimenting with some of the free models available at http://www.psionic3d.co.uk/cgi-bin/imageFolio.cgi?direct=Free%20Stuff/3D%20Models . I think some of these models have issues with fustrum culling due to where the center is placed, so you may encounter some visibility issues with them.

wow, that helps alot, thanks!

one more thing (i hope), bill: u said that the bones in a model are actually B3D pivot points, so say that you have an anim of the mesh swinging a sword, will the sword change the direction its pointed (depending how the hand moves) in aswell, because, i thought if it was parented to the pivot point it would move with it, but not change direction ?

thanks,
JS

The sword will rotate with the hand. If you parent one item to another item then the child item's position, rotation, and scale are all relative to the parent item.

well, i finally got back to the computer with blitz3d installed on it, and i tryed out what u guys said...2 wierd things happened:

1. blitz3d will not recognize any .b3d files i have.
it will load them fine, this command will not return any errors:

ninja_mesh=LoadAnimMesh("ninja.b3d")

however, if i try to do anything involving that mesh's handle (ninja_mesh) i will get a runtime error saying "entity does not exist"


2. the animate command is not working, when i try to use it, a runtime error occurs saying "illegal memory adress" i have not used any "loadanimseq" or "setanimseq" commands before it, i am just using the animation built into the mesh (and yes, i know the animation is there, because its the "mario" mesh from the castle demo, which btw, works fine with its animation, so its not blitz)


could u tell me what im doing wrong here?

JS

Is the b3d file in the same directory as the main code file? If not you need to specify the exact place where it is.

Are you sure the file is in the blitz b3d format? because there are other b3d formats.

mindstorms: yeah, ive tryd it in the same directory, and ive also tryd specifying the exact file where it is.

bram32: i got the b3d files that im using from the site that bill stanbrook mentioned, and also when i go to "loadanimmesh" under the command reference section, it says it can only use .3ds and .X, it says nothing about .b3d, is it supposed to?

<<Loads a mesh from an .X, .3DS or .B3D file and returns a mesh handle. >> Have you downloaded the doc update ? It is in the account section
There is another 3d format that is called b3d.
http://bcchang.com/immersive/b3d.html
To see if it is a blitzbasic b3d file, open it in notepad (or hexedit) and see if the first 4 characters are BB3D.
If they are, you could try and use a 3d editor/viewer that imports b3d. Such a program might give a better feedback on loading the file.

you can also just try out a Milkshape 3D free trial. Milkshape is actually quite powerful and can export skeletal animation to a .b3d file and can import several different files as well.

ok, i just updated blitz3d (everything), and now everything is working fine! animation, .b3d files...its all fixed.

thanks for all your help!

JS