Muscle system for blender
Moderators: jesterKing, stiv
Firstly, I've decided against using asymmetric Gaussian functions, because I think it might be too restrictive, but the underlying idea is still the same.
Next, the muscles don't use a mesh as such but a series of cross sections. The overall muscle is like a lofted solid.
Within these cross sections are variables which define the shape and nature of a section of the muscle. i.e. how much the shape changes when the muscle is deformed. (of course this is relative and wouldn't change the overall volume of the muscle itself).
I hadn't thought about having soft body type effects on the muscle itself only on the skin and fat around it. Although, it might look more realistic if it did, especially if the amount of deformation was related to the tension of the muscle, (because a tense muscle will deform less than a relaxed one).
But for that to happen the muscle will first have to be converted to a mesh of some sort. Then the effects can be applied.
However, since,
The volume has to remain constant,
The tension will effect the deformation,
And there will be a layer of skin and fat between two colliding objects,
It might be easier to have another system to make the effects and not the soft body modifier itself, (definitely a feature for a later version).
You would think a fluid inside a soft body would make a good muscle, but instead of integrating the fluid and soft body system together it would be better if you could make a soft body which has a constant volume. (Good feature in my eyes if someone wants a project!)
As for progress so far. I've added the necessary structures for muscles so theres now a muscle type and I've started the drawing code. But unfortunately, my computer has decided to give up and it's probably going to be a few days before its fixed and I can do more work to the code.
Any other ideas or airing of thoughts would make a welcome contribution to the system.
Dan
Next, the muscles don't use a mesh as such but a series of cross sections. The overall muscle is like a lofted solid.
Within these cross sections are variables which define the shape and nature of a section of the muscle. i.e. how much the shape changes when the muscle is deformed. (of course this is relative and wouldn't change the overall volume of the muscle itself).
I hadn't thought about having soft body type effects on the muscle itself only on the skin and fat around it. Although, it might look more realistic if it did, especially if the amount of deformation was related to the tension of the muscle, (because a tense muscle will deform less than a relaxed one).
But for that to happen the muscle will first have to be converted to a mesh of some sort. Then the effects can be applied.
However, since,
The volume has to remain constant,
The tension will effect the deformation,
And there will be a layer of skin and fat between two colliding objects,
It might be easier to have another system to make the effects and not the soft body modifier itself, (definitely a feature for a later version).
You would think a fluid inside a soft body would make a good muscle, but instead of integrating the fluid and soft body system together it would be better if you could make a soft body which has a constant volume. (Good feature in my eyes if someone wants a project!)
As for progress so far. I've added the necessary structures for muscles so theres now a muscle type and I've started the drawing code. But unfortunately, my computer has decided to give up and it's probably going to be a few days before its fixed and I can do more work to the code.
Any other ideas or airing of thoughts would make a welcome contribution to the system.
Dan
Would anybody object to
in mallocn.c if I added it as part of a patch?
Dan
Code: Select all
void *MEM_reallocN(void *ptr, unsigned int len, const char *str)
{
void *tmp = MEM_callocN(len, str);
unsigned int oldlen;
if(ptr)
{
oldlen = MEM_allocN_len(ptr);
if(len > oldlen)
{
memcpy(tmp, ptr, oldlen);
}
else
{
memcpy(tmp, ptr, len);
}
MEM_freeN(ptr);
}
ptr = tmp;
}
Dan
Last edited by handydan on Fri Dec 14, 2007 2:13 pm, edited 1 time in total.
I haven't made much progress lately, partly due to lack of time but mostly because of rotation problems. I'm trying to use glrotate for the rotation. I can calculate the rotation needed (2 axis'), but when I apply one axis and then the other I get a different rotation than applying them the other way around. Is there a way to applying 2 axis' of rotation at the same time in opengl?
thanks in advance,
Dan
thanks in advance,
Dan
Rotations in general are not order independent, not just Euler angles. Blender definitely has functions to work with quaternions, and quaternions are used in various places. But you need to define what "applying two rotations at the same time" means in your case, since that could be done in different ways, for example by blending the results, or somehow adding them together, .. what is the purpose here?
Well, What I've got is the location of the root and tip of the muscle. At the moment they are only being drawn upright. What I need to do is rotate the muscle so that the tip of it is in the correct place and the rest of it is facing in the right direction, but still perpendicular to the centre line of the inside of it.
If that makes any sense.
Dan
If that makes any sense.
Dan
I think I can solve the problem. I had a flash of inspiration this morning.
P = position of point before transformation (column vector)
M = transformation matrix
^ = to the power of
MP = P'
P P^-1 = 1
MP P^-1 = M
M = MP P^-1
M = P' P^-1
and then to ensure that the transformation isn't just a skew, just make sure that the following is true
'In matrix theory, a rotation matrix is a real square matrix whose transpose is its inverse and whose determinant is +1' Wikipedia
thanks for your help
Dan
P = position of point before transformation (column vector)
M = transformation matrix
^ = to the power of
MP = P'
P P^-1 = 1
MP P^-1 = M
M = MP P^-1
M = P' P^-1
and then to ensure that the transformation isn't just a skew, just make sure that the following is true
'In matrix theory, a rotation matrix is a real square matrix whose transpose is its inverse and whose determinant is +1' Wikipedia
thanks for your help
Dan