Muscle system for blender

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Thu Dec 06, 2007 5:43 pm

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

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Tue Dec 11, 2007 2:24 pm

Would anybody object to

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;
}
in mallocn.c if I added it as part of a patch?

Dan
Last edited by handydan on Fri Dec 14, 2007 2:13 pm, edited 1 time in total.

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip » Tue Dec 11, 2007 8:05 pm

I don't see why it wouldn't be accepted, I think that noone has just gotten around to doing an equivalent for realloc, so I'm sure it would be appreciated.

LetterRip

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Mon Dec 17, 2007 10:15 am

Does the blender source have std rotating functions? if so where? I'm writing drawing code for the muscles. It can draw muscles upright but not slanted yet.

Dan

Koba
Posts: 0
Joined: Thu Apr 15, 2004 9:48 am

Post by Koba » Mon Dec 17, 2007 12:18 pm

I'm looking forward to seeing this!

Sounds like you are making progress! If you release a test build once useable if buggy, your work will get a lot more attention (if you want it!).

Not very useful information from me, I know, but maybe you can appreciate a little encouragement! :wink:

Koba

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Mon Dec 17, 2007 5:20 pm

Still a long way to go until a usable build, but I'll put a screen shot up once I've finished the drawing code.

thanks anyway

Dan

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Tue Jan 01, 2008 9:04 pm

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

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip » Tue Jan 01, 2008 11:35 pm

Dan,

that is a common problem of using Euler rotations - they are not 'order independent' - you should be using quaternions instead.

LetterRip

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Wed Jan 02, 2008 9:58 am

grrr. I suppose I assumed opengl would use either quaternions or a rotation matrix, but it means there's no quick fix solution. Unless blender has its own quaternion implementation?

Dan

brecht_
Posts: 0
Joined: Mon Sep 25, 2006 11:06 am

Post by brecht_ » Wed Jan 02, 2008 10:30 am

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?

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Wed Jan 02, 2008 2:55 pm

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

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Fri Jan 04, 2008 11:44 am

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

stingslang
Posts: 0
Joined: Sat Jun 23, 2007 12:37 am

Post by stingslang » Sat Jan 05, 2008 12:18 am

how far along is this project?

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Sat Jan 05, 2008 11:27 am

Well, I think its about just under half way. I started some time in November, so I think I could be finished by the end of march, but it could be a lot sooner or later depending on how many problems I encounter.

Dan

handydan
Posts: 0
Joined: Mon Nov 19, 2007 4:40 pm

Post by handydan » Sat Jan 05, 2008 1:34 pm

The rotation is now all working :D

anybody know how to implement manipulators (as in user movable nodes like vertices for meshes) quickly?

Dan

p.s. sorry for relying so much on the blender community instead of doing all my own research, but I hope you can understand my "need" to get it done quickly.

Post Reply