CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 04-03-2012, 07:26 PM   #1
ernia
Mad Knight
 
ernia's Avatar
portfolio
Arik Thuesen
USA
 
Join Date: Jan 2005
Posts: 1,050
Different Motext Letters on Cloner Vertexes

Hello,

I'm trying to get a poly object's vertex index numbers and put them in a Motext object that is cloned with a Mograph Cloner onto each vertex of the poly object, so I can see the vertex index numbers when rendered.
How can I change each of the cloned Motext objects to read the different vertex numbers? Right now all the Motext numbers are the same because of what was entered into the Text field of the Motext object.

thanks,
Arik
__________________
C4D R14.034 Studio/MacPro/8gbRAM/Snow Leopard 10.6.8
"Yeah, it could be anything, but it's got to be something!"
 
Old 04-03-2012, 07:54 PM   #2
mayajunky
Addicted for life
 
mayajunky's Avatar
portfolio
Brian Metzger
Advanced Product Engineer
Douglas Machine
Alexandria, USA
 
Join Date: Oct 2005
Posts: 844
Sounds like would need a scripted solution, but you can make multiple text children which the cloner could index through ( very manual process though! especially if your talking a large amount of points )
__________________
www.mayajunky.com

All my favorites ~ Cinema 4D R13, After Effects, Photoshop CS5, Lightroom, Photomatic

Last edited by mayajunky : 04-03-2012 at 10:35 PM.
 
Old 04-03-2012, 09:45 PM   #3
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
what Brian said.
Although you can limit the amount of manual work.

Fastest setup I can think of :

- put multiple Copies of your MoText under the Cloner ( at least as many as there's Vertex Points )
- The Cloner puts 1 Clone onto each vertex point so it takes care of the counting.
- Use a Hierarchy Node to loop through the MoText Objects and input the index number into the Text field of each corresponding MoText.


If you put a lot more copies under the Cloner than you actually need you can even add Points to the Mesh or keep the Object Parametric and the changes in Point Count automatically get reflected by the MoText Objects, until you run out of copies ( in which case you would need to add more copies) .

I'm sure you get the picture.

In case of doubt,
check out this quick setup :
http://www.mediafire.com/file/gidss...otext-ernia.c4d

hope this helps,
d
__________________
-----------> douwe on vimeo
 
Old 04-03-2012, 10:38 PM   #4
mayajunky
Addicted for life
 
mayajunky's Avatar
portfolio
Brian Metzger
Advanced Product Engineer
Douglas Machine
Alexandria, USA
 
Join Date: Oct 2005
Posts: 844
aww yes nice, iterating through the hierarchy to populate the text input fields will definitely remove a lot of the manual work I was thinking. slick. still are you talking 100 points or 50,000 points?
__________________
www.mayajunky.com

All my favorites ~ Cinema 4D R13, After Effects, Photoshop CS5, Lightroom, Photomatic
 
Old 04-03-2012, 11:18 PM   #5
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
To manage more Points it may be a good idea to use Per Anders' Clone-Info-hierarchy with simple Text Objects. An Extrude Nurbs parenting the Reference of the Hierarchy allows you to quickly enable / disable the geometry as needed for faster preview.

It also auto-generates the exact number of Text Objects you need, on the fly.
Check out this example with an animated Point Count

http://www.mediafire.com/file/kr6oz...xtrudeNurbs.c4d

It takes a bit more preparation to set up, but it's far more flexible.

hope this helps,
d
__________________
-----------> douwe on vimeo
 
Old 04-04-2012, 12:41 AM   #6
tcastudios
Steady now!
 
tcastudios's Avatar
...
Sweden
 
Join Date: Jan 2003
Posts: 4,246
My guess is using a Generator would be more efficient.
See code example for use in a PyGenerator.
As I have no experience with the FontData, I made a simple
hack to do font selection from a MoText object placed as a child
of the generator.
[edited code]
Cheers
Lennart

Code:
# moNUMBERS example tcastudios.com©2012 # moNUMBERS must have a MoText Object as a child for Font control. # Place the moNUMBERS Generator as a child of a PointObjects or # a Correction Deformer. import c4d def main(): p = c4d.BaseObject(c4d.Onull) poly = op.GetUp() if not poly or (not poly.CheckType(c4d.Opoint) and not poly.CheckType(1024542)): return p mo = op.GetDown() if not mo or not mo.CheckType(1019268): return p mo[c4d.PRIM_TEXT_TEXT] = '' pcount = poly.GetPointCount() point = poly.GetAllPoints() for i in xrange(pcount): nr = c4d.BaseObject(1019268) nr[c4d.PRIM_TEXT_FONT] = mo[c4d.PRIM_TEXT_FONT] nr[c4d.MGTEXTOBJECT_SPLINEMOVE] = mo[c4d.MGTEXTOBJECT_SPLINEMOVE] nr[c4d.PRIM_TEXT_ALIGN] = mo[c4d.PRIM_TEXT_ALIGN] nr[c4d.PRIM_TEXT_HEIGHT] = mo[c4d.PRIM_TEXT_HEIGHT] nr[c4d.PRIM_TEXT_TEXT] = str(i) nr.SetAbsPos(point[i]+mo[c4d.ID_BASEOBJECT_ABS_POSITION]) nr.SetAbsRot(mo[c4d.ID_BASEOBJECT_ABS_ROTATION]) nr.InsertUnder(p) return p
__________________
MSA | OSX | xfiles ...Cinema4D Tools

Last edited by tcastudios : 04-04-2012 at 12:57 AM.
 
Old 04-04-2012, 01:54 AM   #7
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
very nice, Lennart.

I was playing with a variable Point Count and animated Points, and at first I ran into some problems with real time updating the Generator, but turned out to be nothing that unchecking Optimize Cache couldn't fix .

Also had some issues with Effectors in Point Mode (for moving the Reference Object's Points), since they also affected the MoText Letters, but rearranging the hierarchy and the route in your code fixed that as well.

This is definitely flexible, and super easy to setup.
Nice and clean.

great stuff !
__________________
-----------> douwe on vimeo
 
Old 04-04-2012, 02:22 AM   #8
tcastudios
Steady now!
 
tcastudios's Avatar
...
Sweden
 
Join Date: Jan 2003
Posts: 4,246
Thanks.

I see, then maybe this would be more efficient.
Still needs a MoTex object as a child for font control
but also a UserData Linkfield for a Cloner or Matrix Object.
This way the resulting mo numbers are free to be placed
according to the Cloner and its effectors etc.

Cheers
Lennart
Code:
# motexCLONE example tcastudios.com©2012 # motexCLONE must have a MoText Object as a child for font control. # Add a UserData LinkField for Cloner/Matrix Object. import c4d from c4d import gui from c4d.modules import mograph as mo def MoCheck(obj): md = mo.GeGetMoData(obj) if md == None: return None,None,None clist = [] marr = md.GetArray(c4d.MODATA_MATRIX) farr = md.GetArray(c4d.MODATA_FLAGS) ccount = len(marr) # Initial Clone count for i in xrange(ccount): if ((farr[i]&(c4d.MOGENFLAG_CLONE_ON)) and (not (farr[i]&(c4d.MOGENFLAG_DISABLE)))): #Only if the clone is visible clist.append(marr[i]) # Add Clone Matrix to the list else: ccount -= 1 # Adjust Clone count return len(marr),ccount,clist def main(): p = c4d.BaseObject(c4d.Onull) cl = op[c4d.ID_USERDATA,1] # <--- UserData LinkField for Cloner/Matrix Object if not cl or (not cl.CheckType(1018544) and not cl.CheckType(1018545)): return p mot = op.GetDown() if not mot or not mot.CheckType(1019268): return p mot[c4d.PRIM_TEXT_TEXT] = '' try: pdata = MoCheck(cl) except: return p for i in xrange(pdata[1]): nr = c4d.BaseObject(1019268) nr[c4d.PRIM_TEXT_FONT] = mot[c4d.PRIM_TEXT_FONT] nr[c4d.MGTEXTOBJECT_SPLINEMOVE] = mot[c4d.MGTEXTOBJECT_SPLINEMOVE] nr[c4d.PRIM_TEXT_ALIGN] = mot[c4d.PRIM_TEXT_ALIGN] nr[c4d.PRIM_TEXT_HEIGHT] = mot[c4d.PRIM_TEXT_HEIGHT] nr[c4d.PRIM_TEXT_TEXT] = str(i) nr.SetMg(pdata[2][i]) nr.InsertUnder(p) return p
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 04-04-2012, 03:29 AM   #9
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
That works nicely, Lennart, and it's a lot more practical to control the positioning of the clones with Mograph indeed, but alas, that was not what I meant.

I was thinking about deforming the Reference Mesh.

Let me walk you through my reasoning :
This is the "normal" hierarchical setup :
- Primitive
-- Correction Deformer
---- Python Generator
------ moText

If I now want to deform the shape of my Primitive, for example with a Random Effector set to Point Deformation, I would place the Random Effector under the Primitive, right before the Correction Deformer.

Ayayay... That deforms the Generator as well, though !! :(

So to fix this I would alter the hierarchy to something like
-Null
-- Primitive
---- Random Effector
---- Correction Deformer
-- Python Generator
---- moText

Now the Correction Deformer can read the Deformation nicely, but the Python Generator doesn't get deformed.
In moNUMBERS I would only need to edit the poly line to something like "poly = op.GetPred().GetDown().GetNext()"
and I am good to go.

This is no longer easily possible with motexCLONE :(

d

(learning tons from your examples.)
__________________
-----------> douwe on vimeo
 
Old 04-04-2012, 03:30 AM   #10
ernia
Mad Knight
 
ernia's Avatar
portfolio
Arik Thuesen
USA
 
Join Date: Jan 2005
Posts: 1,050
Fantastic guys!

@Brian: I probably won't be using more than a handful of vertices, so I can go the manual route if I have to.

@douwe: Great! This will work just fine. I'm partial to your solution that uses Per's Null generator. Thanks.

@Lennart: This solution looks very interesting! More Python to study

This is an example of why this is such a great forum.
Thanks guys
__________________
C4D R14.034 Studio/MacPro/8gbRAM/Snow Leopard 10.6.8
"Yeah, it could be anything, but it's got to be something!"
 
Old 04-04-2012, 03:53 AM   #11
ernia
Mad Knight
 
ernia's Avatar
portfolio
Arik Thuesen
USA
 
Join Date: Jan 2005
Posts: 1,050
Yip. That works, douwe.

That's the first thing I tried when I got Lennart's PyGenerator working was to put a deformer in there. I also tried a stop tag and that didn't work. I wonder if it has anything to do with the fact that the MoText objects are not inserted into the hierarchy and just remain in the generator.
__________________
C4D R14.034 Studio/MacPro/8gbRAM/Snow Leopard 10.6.8
"Yeah, it could be anything, but it's got to be something!"
 
Old 04-04-2012, 05:56 AM   #12
tcastudios
Steady now!
 
tcastudios's Avatar
...
Sweden
 
Join Date: Jan 2003
Posts: 4,246
Class, pay attention!

The second example solves all that.
Simply add a Matrix object in Object Mode to the scene.
Have your mesh as Object source.
Then put the Matrix into the linkfield of the PyGenerator,
-not- as a child of anything, done!..

The second, less ideal, solution would be to use a linkfield for
the mesh in my first example, for keeping it outside the hierarchy,
but then you're into making your own "clone to deformed mesh" mess (using GetCashe/DeformCache etc.)

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools

Last edited by tcastudios : 04-04-2012 at 06:02 AM.
 
Old 04-04-2012, 01:11 PM   #13
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
Of course you're right, Lennart.

It took me a good night's sleep to realize that motexCLONE doesn't require the same hierarchical structure as its predecessor.

No need for a Correction Deformer. No need for the Generator to be a Child of the mesh.
No need for adapting the route to the mesh in the code.

It works right out-of-the-box.

Lesson learned.
you're a clever fellow, Lennart. (and it's amazing how fast you work)

d
__________________
-----------> douwe on vimeo
 
Old 04-04-2012, 01:40 PM   #14
ernia
Mad Knight
 
ernia's Avatar
portfolio
Arik Thuesen
USA
 
Join Date: Jan 2005
Posts: 1,050
Aaaah, beautiful! The Matrix object works perfectly, Lennart.

I'm getting an error when I use the Cloner object in the link field instead of the Matrix object. The error is "TypeError: an integer is required".

Thanks Teach! Nothing like a well deserved rap on the knuckles to get a student going in the morning
__________________
C4D R14.034 Studio/MacPro/8gbRAM/Snow Leopard 10.6.8
"Yeah, it could be anything, but it's got to be something!"
 
Old 04-04-2012, 01:49 PM   #15
douwe
Know-it-All
 
douwe's Avatar
portfolio
douwe
Brussels, Belgium
 
Join Date: May 2010
Posts: 472
Quote:
Originally Posted by ernia
I'm getting an error when I use the Cloner object in the link field instead of the Matrix object. The error is "TypeError: an integer is required".


That's only because you're using a Cloner Object without a Child. It needs something to clone. Simply feeding it a Null will do.

d
__________________
-----------> douwe on vimeo
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:46 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.