:: Mel Matrix   :: Python Scripting   :: Final Project   :: Mel & Python Home

:: Final Project

 

For the Final Project, I was inspired by the particle to curve exercise that we went through. Hence wanting to create a tool to generate wires.

I dont know how much I can achieve and still very new to python and mel scripting. These 4 weeks will be a challenging one.

 

q

\

 

Continuing a little more on some reference and inspirational images.

Looking at the sentinel, it has very interesting interweaving lines.

The final reference image really gave me some great ideas of how to go

about this project.

Layered thought process:

1# asking user to create curves/paths.

2# Create proxy boxes

3# Create VolumeAxis

4# Boxes snap along curve

5# VolumeAxis snap to Boxes

6# Query curves startpoints

7# Create emitter, snap emitter to startpoints

8# UI for particles attribute.

9# Dynamic relationships

10# Generate particles.

11# Create curve and do extrusion.

12# Converting curves to hair?

 

 

 

 

So i started up by exploring in maya itself to learn and understand

how its particle systems works. Also keeping an eyes to some major

steps and values that is essential to the process.

The image demonstrate that particles are directed by fields. If I place many

fields along a path, the particles will flow accordingly to the forces applied.

 

 

 

 

Ok here is a test occlusion render of the curve generated.

 

 

 

After getting a rough idea I have to plot out the structure of how this

tool is going to work.

Creating a curve, creating mulitple boxes and snaping them to the

curve line up equally. << snap align tool >>

Then fields will snap to the boxes and later generating the particles.

There were alot of tweaking to the values in the emitter, particle shape,

and the fields itself.

I discovered that most of it lies in the speed of the particle.

They have to be somewhat constant in all the 3 different nodes.

Anyways the tool will create something like that, of course with more

paths.

 

 

 

 

 

Ok here is just to show that the technique works.

Hopefully, it works fine when futher development is done.

Well a huge problem still stands out, I still cant visualize how

the wires will connect to a target. Well that i will leave for later,

first things first, get the script and UI working and see where

we can go from there.

 

 

 

 

Well moving on, its time to sit down and write out the python script that can

generate the same stuff as shown above. Taking about 3 hrs, I finally got it working.

Instead of snaping those fields to boxes at first, i realized that fields are able to move on a curve path.

[ pathAnimation] was my saver.

What I did was duplicate a volumeAxis field on every frame. This will allow maximum controls over the

particles. The Start and End Frames have to be set.

Duplicate VolumeAxis on Path Script.

 

 

 

 

Once having the duplication working.

I continued to work out the UI, using python.

Well it looks simple here, however I had trouble geting the value 50

to be recognize in the duplication def.

Simply saying the UI cannot recognize the def.

Well after asking around, I found out about lamda and *args

def deleteVolume(*args):

a = mc.ls(type='volumeAxisField')
mc.delete(a)

UI---------------

mc.button( label= 'delete', actOnPress=True, command=deleteVolume)

This example shows how buttons call in a def. (*args) is simply an array of information.

def fMasterEXE(startFrm,endFrm):

.....blahblahblah.....xyz.....

UI---------------

mc.button( label= 'Generate Fields', actOnPress=True, command=lambda x: fMasterEXE( stFrm, etFrm) )

 

 

 

 

Here shows the particles moving along the duplicated volumeAxisfields.

Seems that it works out preety fine so far.

Next is to implement the UI for defining attributes within the particleshapes and volumeAxisFields.

For some weird reason the video is not uploading. Plays fine on local.

Click here to link to video.

Click to see - Duplicate VolumeAxis on Path UI Script.

 

 

 

Ok here shows that the idea and the tool works pretty fine.

It shows the particles followed the fields and then from there

creating curves from the paths the particles took.

Well its not easy to control those particles.

However I found out some attributes that helps in giving some controls.

Particle - conserve (attr), fields- magnitude(attr), directional Speed(attr).

Playing with this three attributes seems to give some good control over the particles.

 

 

 

Ok here is a better UI. However, my focus here is to investigate into particle and curve dynamics.

Therefore the UI will be at its most basic.

Having a field for number of copies as well as

the frame range for the caching of particles.

Add emitter to Curve will snap a emitter to Curve starting point.

Select all Volume allows me to play arround with the attributes of all VolumeAxis nodes

in one go.

Lastly is basically creating curve from those particle paths recorded over time.

 

 

 

Well here is a first test rendered curve generated by using the tool.

Not so satisfying due to the lack of understanding and familiarity.

 

Click to look at script:

Main Gwire Script

Tool Script

 

 

 

After more playing around, and working around those suggested attributes

and some Terbulance.

The particles move in a more controlled manner.

I think I have achieve making wires on one curve.

Next step is to recognize multiple curves and generating wires on those curves.

Its coming together :)..... good job chee :)

 

 

 

Well as promised. Now the tool is able to run multiple curves.

The process was a hassel. I hit many problems.

1st was not knowing the difference of how list and list of list is being read.

My Emitters were not created at the curves 1st Cv.

So the way its read is this. "object[0][1]"

Another Problem was the recognizing of particle IDs. For some weird reasons

when using 1 particle source connected to multiple Emitters and setting MaxCount attribute

the particlesToCurve Script dont recognize the Ids

However when switching to each Emitter connected to its own Particle source, particlesToCurve

Script works out fine.

Though getting it to work, the multiple particles source will slow down the cache time according to the number of particle source present.

 

 

 

Anyway I have to move on to work out some simulations. Only then will I see how things will look

with mutliple curves to set mulitple paths for the wires.

So here is my first test on two curves. The tool was able to get wires moving above each other.

 

 

 

 

 

Ok just for greater understanding how the tool is gonna work.

Here is an updated UI interface.

After puting in that particle Max Count I was thrown into hell, haha.

Took me the whole day just to figure out what went wrong with the Particle IDs as discussed above.

 

I have decided not to create more attribute controls for the Particles and VolumeFields.

While having all Particles or VolumeFields selected and changing a Attribute in attribute editor will

change the attribute in all selected.

Coming to such a conclusion was due to the fact that every test i did, all attribute values were

different. There is no golden attribute value. A BIG SET BACK for this Tool I think.

If a user have little knowledge of particles, he or she cant use this tool .

 

 

 

Ok here I want to go crazy with the tool. I created many Curves. Many overlaps..!

Well the Fields work out fine.

 

 

 

 

 

But see how it turn out when the particles where let loose.

Fields were overlaping one another and causing influence on particles that were not meant to be

influence.

As a result, the particles were creating wires that did not move as I have directed.

Its another huge problem.

 

 

 

So I back down to creating just three curves.

But this time playing around with the Attributes in Particles and VolumeFields.

The Attributes:

Particle - Count = 200, Conserve = 0.3

VolumeFields - Magnitude=5, DirectionSpeed = 30 , Turbulance = 1,

Turbulance XYZ Freq = 5

 

I realize that Magnitude was not that important, its the Directional Speed that pushes the particles.

Magnitude will somehow multiply with other fields magnitude and creating influence overlaps with

the particels.

 

 

 

So here is the Rendered Image fromt the above screen Capture.

Well there is still potential for this tool. One more week.

 

Well the tool is Called "Wire Generation Tool"

Click here for Latest Script

 

 

 

 

 

Here I have added in an option to create emitter from a box or a sphere.

This would help solve the problem of having all the curves coming out from

one point as seen from the above images. Moreover, this box can be any object.

However at this point of time a box will work for now, because I just want to

focus on the curves itself.

 

 

 

Here is an example of curves generated from particles emited from a Sphere.

I have also made the curves to extrude tubes instead of flat planes.

Tubes does look more interesting however, there is a problem with the normals as all the

curves branching out in different directions are sharing one nurbs circle reference.

 

 

 

I went on to do more test only to find out more problems.

Now I am having my emitter to generate unlimited particles but at very low rate like 1 - 2 particles per

frame. I have no idea how to solve the Id problem. If I were to generate the curves in this scene with

individaul emitter having its own particel source, it will take ages to generate those curves.

Now I am having the emitters all connected only to one particle source which works really fast and

I want to keep that speed in this tool.

Click on Image to see HD version.

I have to some how find out a way to read those IDs.

What I found out that the IDs are not set to integer numbers when set max particles are turned on.

 

 

 

Now here I am exploring what more can wires generated from particles can do.

Here I am testing it with collision and the results are pretty nice.

The particles do create a nice curve arount the tubes.

Click on Image to see the HD version.

 

 

 

Well again there is a normal problem.

Seems like making wires in Maya, defining the normals of the extruded tube at different parts of the

curve is really crucial.

However, when looking at the function in the Maya Python Guide, I can only figure out this much at

this point of time.

 

 

 

Here is a Movie Capture of how the tool works

Click to View Movie

 

 

 

Here I have managed to solve the extrusion directions/ normals. At first the wires were getting squished up. After some searching and testing, I realized some elemets that were missing from the code. Below is the corrected code.

mc.extrude( 'myCircle',eachCurve, extrudeType = 2, ucp = 1, fpt = True, upn = True, rsp=True)

Click to view Lastest Script

 

Evaluation:

 

I think I have succesfully created a tool that enables one to create multiple wires in a defined path.

However, its still far from complete. There are still problems like wires overlaping. Having the ends of

each wires having a head or a plug. Having the UI enabling users to excess dynamic attributes with

ease and many more.

I do see a real possiblity that this tool will be able to create real wires soon.