detecting collisions

Hi , i have two questions.

i'm planning to write a script that can help avoid poking through something when posing a character  (a kind of basic physics engine) 

is there a method to detect collision on and between characters ,  how the smoothing modifier knows what part of the body it should morph ?  

is there a callback (signal?)  that fires while or after you change the position of an object or a character on the scene?

if you have some advices and some examples , it will be helpful , thanks

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,990

    There isn't, as far as I know, a method available to scripting to detect collision - the Smoothing Modifier and dForce use their own (complied) code as far as I can tell.

    Yes, there are signals for changed poses, though I suspect you are really trying more than a script could handle easily and might be better off looking at the SDK.

  • Revln9Revln9 Posts: 4

    Hi Richard ,  i'll take a look at it , in fact i was planning to do something "small"  just push a button to correct some poke through  , but since there's no 'shortcut' for this i don't think i have the time/dedication to dig deep in the sdk because when you reach that far you should go for a real physics engine like physx or bullet , but anyway thanks

  • Revln9Revln9 Posts: 4

    I am posting the first draft if someone want to help , not the best code but good enough to start with , there's one problem the sensitivity variable needs to be re adjusted when the collision involves the hip or the chest , need to invistigate more about this , richard if you have some suggestions , please feel free to comment 

    var figs = Scene.getSkeletonList();var chars = [];var sensitivity = 8;for (var fig_idx = 0; fig_idx != figs.length; ++fig_idx) {if(figs[fig_idx].name === "Genesis8Male" || figs[fig_idx].name === "Genesis8Female") {	var newobj =  {idx:fig_idx , name:figs[fig_idx].name };	chars.push(newobj)}}var bones1 = figs[chars[0].idx].getAllBones()var bones2 = figs[chars[1].idx].getAllBones()for (var i = 0; i < bones1.length; i++) {		var vec1 = bones1[i].getWSPos()		var a = bones1[i].name;	for (var j = 0 ; j < bones2.length; j++) {		var b = bones2[j].name;			var vec2 = bones2[j].getWSPos();		var result = getVectorDistance(vec1 , vec2) ;			if( result < sensitivity) {				print('found overlap ' ,figs[chars[0].idx].name,  a ,figs[chars[1].idx].name, b)			}			}}function getVectorDistance( v1, v2 ){     var dx = v1.x - v2.x;    var dy = v1.y - v2.y;    var dz = v1.z - v2.z;    return Math.sqrt( dx * dx + dy * dy + dz * dz );}function setNewOverallPos(figure ,pose , rotation){		figure.setWSPos(pose);		if (rotation){			figure.setWSRot(rotation);		}}

     

Sign In or Register to comment.