get bounding box from clones [SOLVED]
-
On 01/04/2015 at 09:11, xxxxxxxx wrote:
MODATA_SIZE is alway none and MODATA_MATRIX give me the relative scale of an object. my plan is to use the original dimension of the spreaded object do do something with a python effector
-
On 02/04/2015 at 06:56, xxxxxxxx wrote:
Hello,
can you give us some code and some more information on what are you trying to do? What exactly is your question?
Best wishes,
Sebastian -
On 02/04/2015 at 09:41, xxxxxxxx wrote:
i got an simple python effector who is able to check nearby clones and disable them if they are to closes to each other. simple to avoid double trees on surfaces. now i want to implement a feature which is able to check the radius of a tree before removing the other clones. now i just using the MODATA_MATRIX and compare the distance from each clone with a .GetLengt()
-
On 07/04/2015 at 01:24, xxxxxxxx wrote:
Hello,
what "trees" are you talking about?
You can get the bounding box dimensions of an object with GetRad(). The clones are based on child objects of the generator object. This generator object is accessible via GetGenerator() or simply using gen. You could then calculate the child index based on the MODATA_CLONE array.
Best wishes,
Sebastian -
On 07/04/2015 at 16:25, xxxxxxxx wrote:
Distance Effektor need a INT input and a static string
import c4d from c4d.modules import mograph as mo from c4d import Vector #Welcome to the world of Python def main() : md = mo.GeGetMoData(op) distance = op[c4d.ID_USERDATA,1] killcount = 0 if op[c4d.ID_USERDATA,1]: if md==None: return False cnt = md.GetCount() marr = md.GetArray(c4d.MODATA_MATRIX) coll = md.GetArray(c4d.MODATA_COLOR) clone_offset = md.GetArray(c4d.MODATA_CLONE) clone_source = gen.GetDown() clone_source_arr = [] while clone_source != None: clone_source_arr.append(clone_source) clone_source = clone_source.GetNext() clone_source_count = len(clone_source_arr) visible = md.GetArray(c4d.MODATA_FLAGS) divider = 1 / float(clone_source_count) offset_threshold = [] for k in range (0, clone_source_count) : offset_threshold.append(divider*k) offset_threshold.append(1.0) clone_source_count_minus = clone_source_count - 1 for i in (xrange(0, cnt)) : if visible[i] == 1: ### detect clone source: for k in range(0, clone_source_count) : if k == 0: if clone_offset[i] < offset_threshold[k+1]: #print str(k) + "=k == 0 " + str(clone_offset[i]) + " < " + str( offset_threshold[k+1]) + str(clone_source_arr[k]) radius = clone_source_arr[k].GetRad() coll[i] = c4d.Vector(0,0,1) break; elif k > 0 and k != clone_source_count_minus: if (clone_offset[i] > offset_threshold[k]) and (clone_offset[i] < offset_threshold[k+1]) : #print str(k) + "=k > 0 !& "+ str(clone_source_count) + " " + str(clone_offset[i]) + " > " + str( offset_threshold[k]) + " and " + str(clone_offset[i]) + " < " + str( offset_threshold[k+1]) + str(clone_source_arr[k]) coll[i] = c4d.Vector(0,1,0) radius = clone_source_arr[k].GetRad() break; elif k == clone_source_count_minus: if clone_offset[i] > offset_threshold[k-1]: #print str(k) + "=k =="+ str(clone_source_count_minus) + " " + str(clone_offset[i]) + " > " + str( offset_threshold[k]) + " and " + str(clone_offset[i]) + " < " + str( offset_threshold[k+1]) + str(clone_source_arr[k]) coll[i] = c4d.Vector(1,0,0) radius = clone_source_arr[k].GetRad() break; for j in (xrange(0, cnt)) : if marr[i] != marr[j]: dist = (marr[i].off - marr[j].off).GetLength() dist = dist - radius.x if dist < distance: visible[j] = 0 killcount += 1 md.SetArray(c4d.MODATA_FLAGS, visible, True) md.SetArray(c4d.MODATA_COLOR, coll, True) return True
-
On 08/04/2015 at 01:10, xxxxxxxx wrote:
Hello,
what exactly is your question please?
Best wishes,
Sebastian -
On 08/04/2015 at 09:14, xxxxxxxx wrote:
at first the detection of the right clone seems to me quite complicated. is there a way to do this without this strange for loops ?
at second:
the effector works fine but self collision between clones with the same source object seems to ignoring the distance threshold.
-
On 09/04/2015 at 08:23, xxxxxxxx wrote:
Hello,
I don't really understand what you did in your code but I guess you could calculate the child index from clone_offset and then simply access your clone_source_arr array.
For questions no longer related to this thread's original topic please open a new thread. Thanks.
Best wishes,
Sebastian -
On 13/04/2015 at 04:57, xxxxxxxx wrote:
this is what the
if clone_offset _ < offset_threshold[k+1]: stuff does
solved