Jump to content

Equipment attaching


VeTaL
 Share

Recommended Posts

I don't know if it's fixed, or was it ever broken, or did I do something wrong, but it just didn't work for me, so I had to use SetEntityMatrix(model,GetEntityMatrix(bone)) instead.

But if your animation suddenly doesn't work anymore, try unparenting models from the bones first.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Warning, achtung, внимание !!!

Take out your wifes and childs from monitors.

 

The first test starts:

TEntity sword = LoadModel ("medievalweapons_longsword.gmf");
EntityParent(FindChild(mi1->GetModel(),"Bip01 Spine"),sword,1);

 

Control: press 1-2-3 to run different animation loops.

 

Starring: crawler, sword.

 

:):D :D

Working on LeaFAQ :)

Link to comment
Share on other sites

But honestly, i think attaching should be in next way:

we're taking vertex 1 on the hand and placing sword there.

then we're taking vertex 2, make vector and align word with that vector

at last, we're taking vertex 3 to create third point, which would fix our sword in all 3 dimensions

post-648-0-31126800-1308930082_thumb.jpg

post-648-0-54540000-1308930086_thumb.jpg

Working on LeaFAQ :)

Link to comment
Share on other sites

Second test:

SetEntityMatrix(sword,GetEntityMatrix(FindChild(mi1->GetModel(),"Bip01 R Hand")));

 

this works fine, no need in 3 points... but i wish parenting get work: while attaching there is need in delta-position

post-648-0-67029200-1309096590_thumb.png

post-648-0-74296300-1309096604_thumb.png

 

So, now i will need to add delta-matrix to sword's matrix every frame... if parenting would work as expected, i will need to add delta position only once, while parenting

Working on LeaFAQ :)

Link to comment
Share on other sites

I guess I am missing the issue here. I can parent a sword to the crawler's hand, then set the rotation and position as needed in the un-animated state. Then when I turn on the animation, the sword follows the hand automatically.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Same here. Just occationally in the past I have had issues with scaling where parenting a model to a particular parent model resulted in the parents scale being magnified many times. Never did figure that one out as it's perfectly ok with most I've tried.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

I had a parenting scale issue with a mesh entity (missiles on launch rails) and something interesting happened. When I used LoadMesh(...) for the missile objects they would scale oddly. I used LoadModel(...) on the same missile model and no scaling issue after parenting. I wondered if you guys might have come across this yourselves?

 

 

@VeTal Quick question, where is the pivot/origin of that sword model?

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

I had a parenting scale issue with a mesh entity (missiles on launch rails) and something interesting happened. When I used LoadMesh(...) for the missile objects they would scale oddly. I used LoadModel(...) on the same missile model and no scaling issue after parenting. I wondered if you guys might have come across this yourselves?

 

 

@VeTal Quick question, where is the pivot/origin of that sword model?

 

I havent tried the scaling issue but will see if i can reproduce it. Are you scaling the parent or the child meshes? Or is this just something odd that happens?

 

The origin was in the middle of the blade, instead of at the middle of the handle. I changed the origin and orientation of the sword, parented it to the hand, positioned and rotated as needed, and ran the animations and it worked just fine.

 

**Edit - If i set the parent of a model or a mesh, it will automatically take the scale of the parent. So if the parent is being scaled by .5, then the child model/mesh would have to scaled by 2 to keep it the original size. Scaling a child model/mesh has no effect of the parent.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Are you scaling the parent or the child meshes? Or is this just something odd that happens?

Just something odd that happened. It was only with a few character models that I had. Whenever I parented a gun, which I had used with many other models successfully, to them then they (the parent character model) appeared in the render about 100 times the size they should be, absolutely massive! It just seemed to do weird things to the models scaling. As this was the minority not the majority I didn't bother investigating further, I just didn't use those models.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

2 Flexman:

I used weapon from here http://www.leadwerks.com/werkspace/files/file/214-2-medieval-weapons/

macklebee is right:

//The origin was in the middle of the blade, instead of at the middle of the handle.

 

The main idea of delta-movement and delta-rotation was in correction.. but as you said that

1) I changed the origin and orientation of the sword, parented it to the hand, positioned and rotated as needed, and ran the animations and it worked just fine.

2) I guess I am missing the issue here. I can parent a sword to the crawler's hand, then set the rotation and position as needed in the un-animated state. Then when I turn on the animation, the sword follows the hand automatically.

3) If i set the parent of a model or a mesh, it will automatically take the scale of the parent. So if the parent is being scaled by .5, then the child model/mesh would have to scaled by 2 to keep it the original size. Scaling a child model/mesh has no effect of the parent.

this is great information to sum up the most number of attaching questions.

 

PS: but i'm missing nice-working Parenting, it should be more productive :D

Working on LeaFAQ :)

Link to comment
Share on other sites

that above is from parenting :D

 

but since the crawler model's hand is already at a rotated angle, I had to position and rotate the sword just initially after I set the parent to make it look correct. Afterwards, just playing the animations made it follow the hand correctly.

 

I moved the origin of the sword to the handle and changed the orientation so the blade is pointing up (mostly because it just made more sense for me to set the angle that way).

medievalweapons_longsword.zip

 

then i attached the sword by using this for the crawler script:

require("scripts/class")
local class=CreateClass(...)

function class:CreateObject(model)
local object=self.super:CreateObject(model)

object.hand = object.model:FindChild("Bip01 R Hand")
if object.hand~=nil then 
	object.sword = LoadModel("abstract::medievalweapons_longsword.gmf",object.hand)
	object.sword:SetRotation(Vec3(230,-20,0))
	object.sword:SetPosition(Vec3(.12,.05,-.05))
end
end

 

as for your video, i have no idea why that would happen... i have not had that issue. its almost like the bone hierarchy has been broken... did you by chance set the sword as the parent of the bone? dunno... weird.

 

EDIT*** - uploaded the wrong sword...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

as for your video, i have no idea why that would happen... i have not had that issue. its almost like the bone hierarchy has been broken... did you by chance set the sword as the parent of the bone?

 

I'll test, maybe if you attach to finger, there is nothing to break... and if sword is attached to Spine - all other hieracy is broken...

 

That is not true. I can set every bone in the model to have a sword attached to it and the animations work fine.

post-14-0-66458200-1309412346_thumb.jpg

 

You are breaking the bone hierarchy in your code which is why the animations do not work any more.

TEntity sword = LoadModel ("medievalweapons_longsword.gmf");
EntityParent(FindChild(mi1->GetModel(),"Bip01 Spine"),sword,1);

You are setting the sword as the parent to the spine. The proper syntax for EntityParent() is:

void EntityParent( TEntity entity, TEntity parent, int global=1 ) 

as shown here: EntityParent()

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

eh, it happens... i totally missed it as well when i looked at the post the first time and apparently so did others... i just knew that parenting objects to the bones has worked for me in the past and i wanted to test to make sure something hadn't broken with any latest releases...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Okay, attaching model to bone is solved (sword, shield and so on), but what about attaching body armor/helmet?

 

1) About armor: looking like animator should create a speshial bone, which should indicate body rotation. i'm afraid that position of person's shoulder will differ from position of armor's shoulder.

2) About helmet (same for gloves and so on): as he is attaching on the head, the head is not visible (or hand in case with gloves). Wouldnt it be a waste of polygons?

 

Or its better to create separate models and just cnahge "head" -> "helmet with face", "hand" -> "glove" ?

Working on LeaFAQ :)

Link to comment
Share on other sites

well it depends i guess on whether or not the gloves and helmet will be coming off alot... if they are going to be permanent then its probably easier just to make them part of the model to begin with... if say the helmet can get knocked off, then i would probably just live with the few extra polygons hidden by the helmet, especially since LE can handle large amounts of polys being rendered relatively well. Or you could do what alot of games do, and make the head a separate attachment. As for the armor, i think most games cheat when it comes to that by making the armor not interfere with any of the arms/shoulder animations... granted i am only guessing because i am far from being a character modeling expert.

 

in any case, attaching a helmet to whatever bone controls the head's position/rotation should work just fine as long as you setup the helmet's initial position/rotation correctly for the un-animated pose just like i did for the sword.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...