Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Mi Apr 24, 2024 22:14

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Blending Matrices
BeitragVerfasst: Di Mai 03, 2005 19:40 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 11, 2003 13:23
Beiträge: 25
Wohnort: South Africa
Hi All

I am in the process of implementing a Bone Blending animation class, but I have hit a math snag.

I have gotten to the point of getting all the interpolated matrices from the active animations, but I am unsure how to change them according to the weight of each animation, and then how to merge them.

PS: My math knowledge sucks, so speak to me like i'm a three year old :wink:

Any ideas will be greatly appreciated

_________________
Im out of my mind but please leave a message...
www.sulaco.co.za


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 04, 2005 16:12 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
If i remember MD5's correct u add all the bones positions to the vertex's that it effects with the weight scale thing applyed to the bones position.

Code:
  1.  
  2. V := VertexPosition;
  3.  
  4. For x := 0 to NumOfBones do
  5. If Bone Effects Vertex then
  6. V := V + (Bone * Weight);
  7.  

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 04, 2005 23:25 
Offline
DGL Member

Registriert: Sa Jan 22, 2005 21:10
Beiträge: 225
Nearly. In the MD5 format you need to do 2 things:
First calc the skeleton. Usually there are lots of frames, so you actually don't need any interpolation. However, looks like you somehow managed to do that. Than you have to go through the whole skeleton, and multiply the matrices to get the world-space-matrix of each node. (Dunno, whether you already got that part).
Second thing to do is what Stucuk mentioned:
Code:
  1.  
  2. for i := 0 to High(Vertices) do
  3. begin
  4.      Vertices[i].Position := Vec(0, 0, 0); //At least at MD5 the position is given through the weights and the bones' matrices
  5.      For j := 0 to High(Vertices[i].Weights) do
  6.      begin
  7.           Vertices[i].Position := AddVec(Vertices[i].Position + MultVec(AddVec(MultMat(Bones[Vertices[i].Weight[j].Bone].Rot,
  8.                                                                                        Vertices[i].Weight[j].Weight),
  9.                                                                                Bones[Vertices[i].Weight[j].Bone].Pos),
  10. //I splitted it up into Position and rotation. makes things easier...
  11.                                                                         Vertices[i].Weight[j].Bias)      //And don't forget the bias...
  12.                                         );
  13.      end;
  14. end;
  15.  


This is more or less what I did for MD5s. Worked for most of the models...


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Mai 05, 2005 22:51 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 11, 2003 13:23
Beiträge: 25
Wohnort: South Africa
Thanx for the suggestions :)

I figured out a way of doing this with Nitrogens help (Thanx Dude) :D

Code:
  1.  
  2. SetLength(FMergedMatrices,0);
  3.   if Count > 0 then // We have animations to check
  4.   begin
  5.     for i := 0 to Count - 1 do
  6.     begin
  7.       lAnim := Anims[i];
  8.       if lAnim.Active then
  9.       begin
  10.         lAnim.CalulateCurrentBoneMatrix(FCurrentTime); // Get the interpolated matrix list
  11.         { Merge With Other Bone Matrices }
  12.         for j := 0 to Length(lAnim.MergedMatrices) - 1 do
  13.         begin
  14.           lMergedMatrix := lAnim.MergedMatrices[j];
  15.           { If FMergedMatrices is too small, make it bigger}
  16.           if Length(FMergedMatrices) < j + 1 then
  17.           begin
  18.             SetLength(FMergedMatrices,j + 1);
  19.           end;
  20.           { Scale the matrix according to the Influence the animation has on the mesh }
  21.           ScaleMatrix(lMergedMatrix,lAnim.Influence);
  22.           for n := 0 to 3 do
  23.           begin
  24.             // Concatinate the matrix to the other stored matrices
  25.             VectorAdd(lMergedMatrix[n],FMergedMatrices[j][n],FMergedMatrices[j][n]);
  26.           end;
  27.         end;
  28.       end;
  29.     end;
  30.   end;
  31.  


Obviously this in only the first part of the process, I stil need to add individual bone weights into the algo to allow for feather blending.

The current code basically allows any number of interpolated frames in several animations to be blended by their influence (Value between 0 and 1)

I had a look at doing all the calculations per vertex, but that seemed way too expensive.(My thoughts: Rather do a 16 * amount of bones calculation then an undefined number of calculations for any number of vertices in the mesh) and then just apply the resulting matrix to the correct verts in the inverted mesh.

It seems that the same theory would apply to individual bone weights, but I'll only know once I have finished that :)

PS: I'm using the VectorGeometry.pas file from glscene.

_________________
Im out of my mind but please leave a message...
www.sulaco.co.za


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 17 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.110s | 17 Queries | GZIP : On ]