Adding clothing, weapons, shields to 3d model.

Started by cyberkilla, November 22, 2006, 02:30:39 AM

Previous topic - Next topic

cyberkilla

Hello, i am in big trouble if i dont come up with a trick to do this!
Could someone give me any ideas?

In the 2d sprites, i simply superimposed them on in the paint function.


In 3d however, im stumped. I need a way to change hair, guns, boots, etc
on a generic 3d model i made.

If you help me, I will be your best friend.
It just occured to me that this would need to be done too, if i were
to move to 3d sprites!

Thanks in advance!

EDIT: Really, any ideas are great!
I prefer ONLY vertex colouring. No texturemapping if possible.

I know i can change colours of vertexes to give effect of clothing,
but things such as hoods, capes, etc, would not work like that.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

In the words of pink floyd, "Hello... Is there anybody out there? Just nod if you can hear me....Is there anyone at home?":P
Well, something like that.

Just your standard NUDGE:P
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Melssj5

define each part on separate 3ds files, for example the hair, the cloths, etc etc etc, then when you load the correct parts merge them all in one Object3D, its an approximation of what you used to do in 2d!
Nada por ahora

cyberkilla

Finally a response! Thanks!:)

I need them animated though.

This is how im doing it now.....

One 3ds file for each frame of animation.

Is there another way of loading animation from a single 3ds file?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Melssj5

Of course there is another way, loading a 3ds file and adding it to a World for each key, and making them appear and disappear is super resource consuming and it will defintely slow your app.

you can load an entire animation and define the range to animate!

make your animation and load it, the define an animator or something like that and you can load the animation juist by defining the range of keys.

I have no the code with me, but is quite easy!
Nada por ahora

cyberkilla

I currently load each 3ds frame file into an animation,
with a new sequence index for each STATE(idle,walk,sit).

So, i end up with a whole Object3D with everything in.
Its cached as a buffered image, so its not a speed worry really:).


I might not have understood your answer, but what I meant to ask was...

Is it possible to extract the keyframes from a single 3ds. For one state i mean.
So i could have one 3ds file for walking, one for sitting, one for standing idle etc:)

Sorry if im just being dumb.

I know animation in 3ds isnt supported by the api by default, but, any help in this respect?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

raft did something similar. I don't know if he's active in the forums atm..maybe you should try to PM him.

cyberkilla

http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

raft

i originally store each key frame on a seperate 3ds file and each animation sequence in a different folder. then to use in karga a serialize animation sequence after stripping it. this way loading time drops to almost one fifth of loading it directly from key frames.  

r a f t

cyberkilla

Thats a nice idea. Thats how I ended up doing it too:)

Any idea how I can get clothes onto the naked 3d models?

Edit: I have considered making a gun model, a child of a hand, but this is not possible as I have merged each frame into a single Object3D.

The only other thing that is apparent to me is:

Rendering a naked 3d model...
Drawing clothes on this mode in blender, but making the naked model itself invisible...
Rendering the clothing...
Drawing the clothes render ontop of the naken body with java2d.

Now, i found a link like this...

http://www.christiancoders.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum5&topic=000196

It refers to the use of "envmap" to make the body invisible, and stop it from coming through the clothes.

Is this environment mapping trick possible with jpct?

Whether it is or not, can you see a better way?

One thing is for sure. Whoever manages to get me an answer here, will be on the credits of my game as a saviour;).

This is definately looking like the way to go. The guy's
animation is a little jumpy, but I am confident I can sort that out myself.
Looks like his frames are slightly out of step...He's using javascript and layered divs so he cant really synchronize the img tags. It wont be an
issue in java. Also, im using firefox which he complains about in his post:P


http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

raft

well, the link you found seems to be written for 2d enviroments. luckily jPCT is a 3d engine and you dont need that kind of tricks ;)

you can do in jPCT what that guy does in blender and indeed that's also what i do in karga: seperate your clothes to different textures where other parts of texture is transperent. then to create combinations, use java2d to draw that textures on top of others and finally use resulting image as your avatar's texture. this is what i called 'texture based dressing'. with a good texture artist you can create lots of combinations

for variations which cannot be done with texture, (like gun, hair etc) animate and store them in a series of 3ds files as you do for the body and attach them to body as childs (this will make them move and turn with the body) and apply the same animation as the body. that's if the body is at frame 2 of walk animation the gun and hair will be at same frame too. of course to do this, you wouldnt merge body and childs into a single 3d object

i guess there is much information about this mechanism in karga thread

hope this helps
r a f t

cyberkilla

http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

Is is possible to do the following......


load model of naked body...

load model of tshirt, both transformed to 0,0.

render....


and get something that doesnt z fight?
I havent tried it yet, but I am curious.


EDIT:

Is it possible to "envmap" in  jpct? i mean, set objects faces so they are
color of background, and so, invisible effectively. however, they keep their  position, in that objects behind are not seen either.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Mizuki Takase

If it helps any, I wanted to load all of the objects and merge them together and apply some skeletal system onto it... Since I am stupid at all of this, I decided to just try to translate code and see what happens...

PS: that approach does not seem to be a good way to learn something as seen from working on the clothing simulation...


http://darwin3d.com/gdm1999.htm
http://darwin3d.com/gamedev/articles/col1099.pdf

http://darwin3d.com/gdm1998.htm
http://darwin3d.com/gamedev/articles/col0598.pdf

raft

this is from a private message, i'm posting it here hoping it may be handy ;)

i originally store each key frame on a seperate 3ds file and each animation sequence in a different folder.

say you have 2 animations: walk and jump. create them in a 3d editor like 3d max, and store necessary keyframes in seperate 3ds files. decide how many keyframes you will use and select them. remember all jpct can do is to interpolate between keyframes. so for walk you need at least these key frames: stand, right foot up, right down and left up, left down and right up, stand again. the file structure will be like:

character/default.3ds
character/walk/frame0.3ds
character/walk/frame1.3ds
character/walk/frame2.3ds
..
character/jump/frame0.3ds
..


then your code to load this animation will be like:

Object3D character = loadDefault3ds();

Animation animation = new Animation(<total number of frames>);
int walkSeq = animation.createSubSequence("walk");
for frames in walk folder {
   Object3D o = loadObjectFromFolder(..);
   animation.addKeyFrame(o.getMesh());
}
// do same for jump

character.setAnimationSequence(animation);


for this to work vertex optimization should be disabled or else jpct will weld close vertices into a single one and which in turn will break animation sequence: all meshes in an animation sequence should have same number of vertices

Loader.setVertexOptimization(false);


after these you can walk your character around by moving it and animate it at the same time by using

character.translate(Vector)
character.animate(index, walkSeq)

you should calculate index so that walk animation should look continuos.

-- o --

for cloting and weapons as i said before there are 2 distinct methods, texture based and mesh based.

for texture based, simply change texture of your character. i dynamically create cloth texture combinations in karga but that is only an addition. you can just use a couple of textures which were prepared offline

for mesh based, say your character has a weapon in his hand. you should put it into hand of your character in 3dmax and animate it with your character and save exactly same key frames. so you will have a directory structure like:

weapon/default.3ds
weapon/walk/frame0.3ds
weapon/walk/frame1.3ds
..
weapon/jump/frame0.3ds
..


load it the same way as your character and add it as a child:
character.addChild(weapon);

then, when you animate your character you should animate weapon too. old code now becomes:

character.translate(Vector);
character.animate(index, walkSeq);
weapon.animate(index, walkSeq);


an important point is, you shouldnt move your weapon as it will move with your character since it's a child of it. when you dont need a weapon just set it unvisible. that will succesfully do the trick

hope this helps ;)
r a f t