• Create Account

# Kest

Member Since 17 Aug 2005
Offline Last Active May 12 2012 06:32 PM

### Extracting an input matrix from a final matrix

11 May 2012 - 09:06 AM

This seams like it would be rather simple, but I'm having some trouble. I have a few matrices:
output = the end result of this operation
JointToOrigin = some input matrix
OriginToJoint = The inverse of JointToOrigin
parent = parent->output (the output of this output's parent)
State = An input matrix, and the one I want to extract from output

This is how output is computed with these matrices:
MATRIX output;
output = JointToOrigin * State;
output = output * OriginToJoint;
output = output * parent;

Now assuming all of these matrices have the same values as the time of above, is it possible to determine the value of the original -State- matrix? Can anyone help me determine the order I would need to do this in? This is what I have tried, and I've tried re-arranging them, but I haven't had any luck:
State = Inverse(parent) * output;
State = State * JointToOrigin; // because JointToOrigin is the inverse of OriginToJoint
State = OriginToJoint * State; // because it is the inverse

Thank you for any help

### Convert Ragdoll matrices back to Animation matrices

10 May 2012 - 02:51 PM

Hey guys! I've been trying to figure this out for while now, with no luck.

My animated characters use a hierarchy skeletal system. Each limb has a rotational state, which is converted to a rendering matrix by multiplying it with its parents. I have easily figured out how to pose my ragdoll for physics start by determining their matrices using the character's rendering matrices. My ragdoll body parts are not in a hierarchy (which is part of what is confusing me).

Each ragdoll body part has a bind transform - a matrix that takes the body part from the zero-origin-point and places it at the limb location of the character. So when all ragdoll parts render with just their bind pose, it would look like a character in their bind pose. In order to place the ragdoll parts, I multiply each ragdoll part's bind pose with the character's rendering matrix for that bone. For instance:
Ragdoll_Leg->Transform = MUL( Ragdoll_Leg->Bind_Transform, Character->Leg->RenderMatrix );

This works, and the ragdoll starts exactly where my character is posed. However, I'm having a lot of confusion reversing this procedure and obtaining animated states for the character by using the ragdoll transforms.

My character's RenderMatrix for each bone is computed like this:
void KRaceBone::ComputeHierarchy(const MTX *states, MTX *finals, const MTX &amp;derive)
{
finals[Index] = MUL( JointToOrigin, states[Index] );
finals[Index] = MUL( finals[Index], OriginToJoint );
finals[Index] = MUL( finals[Index], derive );

// Compute Children
for(int e=0; e<Bones.GetCount(); e++)
Bones[e].ComputeHierarchy( states, finals, finals[Index] );
}

Note the inclusion of the "states[Index]". That is the pure-rotational local state of each bone. That is what I'm trying to convert my ragdoll parts back into. Anyone have any advice? Anything at all is appreciated. I've been pretty lost at this.

Thanks!

### Automatic Predefs?

20 March 2012 - 02:17 PM

When I have a header file that defines a class which uses an object:
class MyClass
{
public:
void DoSomething(OtherClass *ptr);
private:
.....
};

The compiler complains because it doesn't know what OtherClass is. Yet, as long as I don't use specific parts of OtherClass, I can just pre-def OtherClass at the top of this header:
// at the top:
class OtherClass;

My question is: Is there a way to have the compiler be okay with this, without adding pre-defs for every variable type passed to a function in the header? Perhaps some compiler option (Microsoft Visual Studio 2010)? Or maybe some type of pointer-type-hiding mechanism?

Thank you for any help.

### Scan a struct/class for members/methods

16 March 2012 - 07:05 PM

Hey everyone

Is it possible to scan a class in code to obtain information about members in that class?

For example, lets pretend I want to make a function that writes all of the data members and member functions of a class to a text file, along with their types, sizes, values, etc.

My calling code would look something like this:
class SomeClass
{
public:
int CanYouSeeMe;
int IBetYouCant;

void MyMethod();
};

template <typename vtype>
void WriteClassInfoToFile(vtype &class_ref); // the parameter might be different

..... in some function somewhere:

SomeClass test;
WriteClassInfoToFile( test );

My resulting text file would look something like this:
Class: SomeClass
Size: 8 bytes

Members:
CanYouSeeMe - Type: int
IBetYouCant - Type int

Methods:
1. MyMethod() - return type: void

Is something similar to this possible? My real reason for wanting to do this is to be capable of adding a real game-code structure to a scripting engine more easily. My scripting engine is capable of defining instances of classes, using them to change members, etc, but each class must be defined into the scripting engine by manually defining each structure member.

Thanks for any information

### Direct Input DIK_* defines are in incorrect order for keyboard

18 February 2012 - 08:10 AM

Hey guys. Haven't posted on here for a while. Looks like things have changed since I last did.

Anyway, I'm testing my game engine on a laptop, which I know has less keys than a standard keyboard, but what I didn't know is that the scan codes are in a different order for some reason. From what I read in the directX manual, DIK_* defines are supposed to line up with the dwOfs member of the DIDEVICEOBJECTDATA structure. However, on this laptop, the [ key is at offset=145, while the ] key is offset=26. IE, the DIK_LBRACKET define DOES NOT corrispond with the [ key. In fact, many of the non-ascii type keys, like brackets and symbols, do not match up with the direct input DIK_* defines. Further, when I attempted to use the "code to ascii" conversion system posted here (at http://www.gamedev.net/page/resources/_/technical/directx-and-xna/converting-scan-codes-to-ascii-r842 ), it outputs the wrong keys for these brackets.

My question is this: Is this likely..
1) Typical behavior?
2) Some type of glitch in hardware or software within the computer? IE, badly ordered keyboard scan codes.
3) A mistake in my code somewhere.

Here are the scan codes I printed out from my game's log:
Key 0 / tszName= Esc / Offset = 1
Key 1 / tszName= 1 / Offset = 2
Key 2 / tszName= 2 / Offset = 3
Key 3 / tszName= 3 / Offset = 4
Key 4 / tszName= 4 / Offset = 5
Key 5 / tszName= 5 / Offset = 6
Key 6 / tszName= 6 / Offset = 7
Key 7 / tszName= 7 / Offset = 8
Key 8 / tszName= 8 / Offset = 9
Key 9 / tszName= 9 / Offset = 10
Key 10 / tszName= 0 / Offset = 11
Key 11 / tszName= - / Offset = 12
Key 12 / tszName= Backspace / Offset = 14
Key 13 / tszName= Tab / Offset = 15
Key 14 / tszName= Q / Offset = 16
Key 15 / tszName= W / Offset = 17
Key 16 / tszName= E / Offset = 18
Key 17 / tszName= R / Offset = 19
Key 18 / tszName= T / Offset = 20
Key 19 / tszName= Y / Offset = 21
Key 20 / tszName= U / Offset = 22
Key 21 / tszName= I / Offset = 23
Key 22 / tszName= O / Offset = 24
Key 23 / tszName= P / Offset = 25
Key 24 / tszName= ] / Offset = 26
Key 25 / tszName= \ / Offset = 27
Key 26 / tszName= Enter / Offset = 28
Key 27 / tszName= Ctrl / Offset = 29
Key 28 / tszName= A / Offset = 30
Key 29 / tszName= S / Offset = 31
Key 30 / tszName= D / Offset = 32
Key 31 / tszName= F / Offset = 33
Key 32 / tszName= G / Offset = 34
Key 33 / tszName= H / Offset = 35
Key 34 / tszName= J / Offset = 36
Key 35 / tszName= K / Offset = 37
Key 36 / tszName= L / Offset = 38
Key 37 / tszName= ; / Offset = 39
Key 38 / tszName= Shift / Offset = 42
Key 39 / tszName= \ / Offset = 43
Key 40 / tszName= Z / Offset = 44
Key 41 / tszName= X / Offset = 45
Key 42 / tszName= C / Offset = 46
Key 43 / tszName= V / Offset = 47
Key 44 / tszName= B / Offset = 48
Key 45 / tszName= N / Offset = 49
Key 46 / tszName= M / Offset = 50
Key 47 / tszName= , / Offset = 51
Key 48 / tszName= . / Offset = 52
Key 49 / tszName= / / Offset = 53
Key 50 / tszName= Right Shift / Offset = 54
Key 51 / tszName= * / Offset = 55
Key 52 / tszName= Alt / Offset = 56
Key 53 / tszName= Space / Offset = 57
Key 54 / tszName= Caps Lock / Offset = 58
Key 55 / tszName= F1 / Offset = 59
Key 56 / tszName= F2 / Offset = 60
Key 57 / tszName= F3 / Offset = 61
Key 58 / tszName= F4 / Offset = 62
Key 59 / tszName= F5 / Offset = 63
Key 60 / tszName= F6 / Offset = 64
Key 61 / tszName= F7 / Offset = 65
Key 62 / tszName= F8 / Offset = 66
Key 63 / tszName= F9 / Offset = 67
Key 64 / tszName= F10 / Offset = 68
Key 65 / tszName= Num Lock / Offset = 69
Key 66 / tszName= Scroll Lock / Offset = 70
Key 67 / tszName= Num 7 / Offset = 71
Key 68 / tszName= Num 8 / Offset = 72
Key 69 / tszName= Num 9 / Offset = 73
Key 70 / tszName= - / Offset = 74
Key 71 / tszName= Num 4 / Offset = 75
Key 72 / tszName= Num 5 / Offset = 76
Key 73 / tszName= Num 6 / Offset = 77
Key 74 / tszName= + / Offset = 78
Key 75 / tszName= Num 1 / Offset = 79
Key 76 / tszName= Num 2 / Offset = 80
Key 77 / tszName= Num 3 / Offset = 81
Key 78 / tszName= Num 0 / Offset = 82
Key 79 / tszName= Num Del / Offset = 83
Key 80 / tszName= F11 / Offset = 87
Key 81 / tszName= F12 / Offset = 88
Key 82 / tszName= Kana / Offset = 112
Key 83 / tszName= Convert / Offset = 121
Key 84 / tszName= No Convert / Offset = 123
Key 85 / tszName= F14 / Offset = 125
Key 86 / tszName= = / Offset = 144
Key 87 / tszName= [ / Offset = 145
Key 88 / tszName= ' / Offset = 146
Key 89 / tszName= ` / Offset = 148
Key 90 / tszName= Num Enter / Offset = 156
Key 91 / tszName= Right Ctrl / Offset = 157
Key 92 / tszName= Num / / Offset = 181
Key 93 / tszName= Prnt Scrn / Offset = 183
Key 94 / tszName= Right Alt / Offset = 184
Key 95 / tszName= Pause / Offset = 197
Key 96 / tszName= Home / Offset = 199
Key 97 / tszName= Up / Offset = 200
Key 98 / tszName= Page Up / Offset = 201
Key 99 / tszName= Left / Offset = 203
Key 100 / tszName= Right / Offset = 205
Key 101 / tszName= End / Offset = 207
Key 102 / tszName= Down / Offset = 208
Key 103 / tszName= Page Down / Offset = 209
Key 104 / tszName= Insert / Offset = 210
Key 105 / tszName= Delete / Offset = 211
Key 106 / tszName= Left Windows / Offset = 219
Key 107 / tszName= Right Windows / Offset = 220
Key 108 / tszName= Application / Offset = 221

Thank you for any help.

PARTNERS