View Full Version : colorPP with closestPointOnMesh ?
papicrunch 07-04-2008, 11:53 AM hello,
I would like to control my colorPP with a texture mapped on an object in fuction of the
position of each particles to this object.
I try to used closestPointOnMesh (bonus tools maya2008), to do this. It's work fine with
simple object but i don't understand how i could find PP world position and connect this array onto closestPointOnMesh node and then return a rgbPP ...
here (http://www.2dots.fr/colorpp.rar) a test scene with connection obj worked and particles ' problem
Perhaps some of you have a solution or an other network/expression to do this.
thank
sorry for my poor English
edit : new test scene (http://www.2dots.fr/colorppV2.rar)
little progression with CPOM, now the particles have a color pick up to the texture but
all have the same ... i dont understand how pass "per particle" onto CPOM
|
|
Aikiman
07-05-2008, 03:45 AM
Im not sure, it might have more to do with parentU and V from using the surface for emission. Although this can easily be achieved by inputing a texture into the emitter attributes once you have set up your particles to emit from a surface.
papicrunch
07-05-2008, 06:26 AM
thank for reply
But i dont think parent uv work in my case (or i dont know how to use it)
what i try to do, it 's for example :
when particles fly over the plane, Each particles take this color of the nearest surfacePlane 's point
I dont know if I 'm clear .... I really need to work my english
papi,
Bernard397
07-05-2008, 12:00 PM
Hello,
do you mean this sort of effect...
I'm trying to do it also with Maya, but I didn't find the sollution yet....
bern
Aikiman
07-05-2008, 08:29 PM
Hello,
do you mean this sort of effect...
I'm trying to do it also with Maya, but I didn't find the sollution yet....
bern
gotta love that Houdini
thank for reply
But i dont think parent uv work in my case (or i dont know how to use it)
what i try to do, it 's for example :
when particles fly over the plane, Each particles take this color of the nearest surfacePlane 's point
I dont know if I 'm clear .... I really need to work my english
papi,
its okay, I understand what you mean, I was just offering another solution partly because I didnt know what your setup was and partly because I havnt been able to hook up particles to the closestPointOnSurface node before.
I think it may be posible to color your particles using colorAtPoint Im just not sure you can connect per particle positions to the inPosition of the CPOS node, I had a quick play and failed, sorry.
papicrunch
07-06-2008, 10:35 AM
yes Bernard397, it's exatly this sort of effect.
thank Aikiman to try,
perhaps i must try to find an another way to finish this effect. But in theory it 's seem possible to query each PPposition, find the nearest point on a mesh, pike the color
and apply to the corresponding particule ....
the problem for the moment , it's CPOM don't return vector array for possitionPP. I try
to play some connect with an array mapper without sucess ...
here (http://www.2dots.fr/colorPP.rar) my test scene where CPOM seem to return only the value of the second particle
Anyone can help or an other idea ?
thank
papi,
Bernard397
07-06-2008, 10:46 AM
Hello,
would it not be possible to use the colorAtPoint command to querry the surface color at position U and V ?
Just guessing...
bern
Aikiman
07-06-2008, 11:19 AM
Yeah thats exactly what the colorAtPoint does, the problem is though you cant hook the per particles position into the cpom node so that colorAtPoint knows which u and v to sample.
papicrunch
07-06-2008, 12:17 PM
oups wrong link file in my previous post
colorppV3 (http://www.2dots.fr/colorppV3.rar)
yeap bernard397, i use colorAtPoint to find the color,
here the expression in rgbPP :
float $cpomU, $cpomV;
vector $pos = particleShape1.position;
closestPointOnMesh2.inPositionX = $pos.x;
closestPointOnMesh2.inPositionY = $pos.y;
closestPointOnMesh2.inPositionZ = $pos.z;
$cpomU = closestPointOnMesh2.parameterU;
$cpomV = closestPointOnMesh2.parameterV;
vector $colorPP = `colorAtPoint -o RGB -u $cpomU -v $cpomV ramp1`;
particleShape1.rgbPP = << $colorPP.x,$colorPP.y,$colorPP.z >>;
it 's seem to work only for the second particle (or last particleID) the first have the same color.
Bernard your test image come from Houdini ? I 'm currently learning Houdini, so i 'm intersting to know how you do that ...
thank,
papi
Bernard397
07-06-2008, 12:25 PM
Hello papicrunch,
This scene uses a simple AttributeTransfer node .
( I can't send you the scene file because hipnc extensions won't work here...,
maybe you can give me your mail and I will send it there?)
Hopefully we will find a method to get this done in Maya?....
thanks,
bern
Remember also that there's a command called "nearestPointOnMesh". You have to load the plugin of the same name before you can use the command.
Using that, here's a runtime expression to get colors from a texture, ramp1, at the point on a mesh, pPlane1, nearest to the particle.
vector $pos = particleShape1.position;
float $uv[] = `nearestPointOnMesh -ip ($pos.x) ($pos.y) ($pos.z) -q -u -v "pPlane1"`;
vector $color = `colorAtPoint -o RGB -u ($uv[0]) -v ($uv[1]) ramp1`;
particleShape1.rgbPP = $color;
Bernard397
07-06-2008, 03:43 PM
Thanks ctp.
Maybe a stupid question, but how can I create a Mesh?
When I use a NURBS plane, I get an error saying: "Only a mesh or its transform can be specified!"
bern
papicrunch
07-06-2008, 04:07 PM
hello,
work in progress ... base on two other threads
from Aikiman ;) here (http://forums.cgsociety.org/showthread.php?f=86&t=645921&highlight=attach+particle) and Ryokukitsmue here (http://forums.cgsociety.org/showthread.php?f=89&t=647998&highlight=attach+particle)
with this expression, i can assign a single unique color to my particle :
vector $colorPP[];
$colorPP[0] = <<1,0,0>>;
$colorPP[1] = <<0,1,0>>;
$colorPP[2] = <<0,0,1>>;
if (particleShape1.particleId == 0){
particleShape1.rgbPP = $colorPP[0];
}
if (particleShape1.particleId == 1){
particleShape1.rgbPP = $colorPP[1];
}
if (particleShape1.particleId == 2){
particleShape1.rgbPP = $colorPP[2];
}
clear($colorPP)
so that great now i try this :
vector $colorArray[];
for ($i = 0; $i < 5; $i++){
$colorArray[$i]=$i;
}
print $colorArray;
yeah i create an array, so i think why dont combine those 2 codes ?
vector $colorPP[];
float $cpomU, $cpomU;
int $count;
$count = `particle -q -count particleShape1`;
for ($i = 0; $i < $count; $i++) {
float $loc[] = `particle -attribute position -id $i -q particleShape1`;
closestPointOnMesh1.inPositionX = $loc[0];
closestPointOnMesh1.inPositionY = $loc[1];
closestPointOnMesh1.inPositionZ = $loc[2];
$cpomU = closestPointOnMesh1.parameterU;
$cpomV = closestPointOnMesh1.parameterV;
$colorPP[$i] = `colorAtPoint -o RGB -u $cpomU -v $cpomV ramp1`;
clear($loc);
}
if (particleShape1.particleId == 0){
particleShape1.rgbPP = $colorPP[0];
}
if (particleShape1.particleId == 1){
particleShape1.rgbPP = $colorPP[1];
}
if (particleShape1.particleId == 2){
particleShape1.rgbPP = $colorPP[2];
}
clear($colorPP)
damned ! again only the last particle (lastId) take the color .... i dont understand why
my $colorPP[] array don't keep the correct value at the correct index.
i desperate,
papi
papicrunch
07-06-2008, 04:25 PM
yeah, ctp many many thank ...
it's perfectly work !
sorry for the last post .... i had not seen your reply when i wrote last one.
thank again my saver ;)
Bernard if i replace my polyPlane by a nurbPlane i have the same error. perhaps this plugins
only work with polygon object
Just for my culture someone have the answer why my colorPP[] array don't keep the value at the index in my expression runtime ?
papi,
Bernard397
07-06-2008, 04:38 PM
Thanks ctp. Now it works perfect.
Now let's say if I put the particle emitter away from the center (near the pPlane), the particles start emitting the nearest color...
If I want no colors if the emitter is not in the 'bounding box' of the pPLane, what must I do then?
Great work!
bern
...well, using the node approach, I do get som strange results with closestPointOnMesh... liek it's not updating properly... ah well, later.
But for nurbs surfaces and using a closestPointOnSurface node it works fine. Then the runtime expression could look like this:
vector $pos = particleShape1.position;
setAttr closestPointOnSurface1.inPosition ($pos.x) ($pos.y) ($pos.z);
float $u = `getAttr closestPointOnSurface1.parameterU`;
float $v = `getAttr closestPointOnSurface1.parameterV`;
vector $color = `colorAtPoint -o RGB -u ($u) -v ($v) ramp2`;
particleShape1.rgbPP = $color;
for the bounding box question, a suggestion could be:
vector $pos = particleShape1.position;
vector $bBoxMin = `getAttr nurbsPlane1.boundingBoxMin`;
vector $bBoxMax = `getAttr nurbsPlane1.boundingBoxMax`;
if($pos.x > $bBoxMin.x && $pos.x < $bBoxMax.x && $pos.z > $bBoxMin.z && $pos.z < $bBoxMax.z) {
setAttr closestPointOnSurface1.inPosition ($pos.x) ($pos.y) ($pos.z);
float $u = `getAttr closestPointOnSurface1.parameterU`;
float $v = `getAttr closestPointOnSurface1.parameterV`;
float $np[] = `getAttr closestPointOnSurface1.position`;
vector $color = `colorAtPoint -o RGB -u ($u) -v ($v) ramp2`;
particleShape1.rgbPP = $color;
particleShape1.nearestPoint = <<($np[0]),($np[1]),($np[2])>>;
}
else {
particleShape1.rgbPP = <<0.5,0.5,0.5>>;
}
Here it's only checking for x and z position, and assuming that the particles are floating above or below the plane - above or below meaning y-axis.
However, just checking for the boundingBox this way may give a too simple or a too 'rough' estimate. Anyways, it's a start.
Bernard397
07-06-2008, 05:37 PM
...well, using the node approach, I do get som strange results with closestPointOnMesh... liek it's not updating properly... ah well, later.
But for nurbs surfaces and using a closestPointOnSurface node it works fine. Then the runtime expression could look like this:
vector $pos = particleShape1.position;
setAttr closestPointOnSurface1.inPosition ($pos.x) ($pos.y) ($pos.z);
float $u = `getAttr closestPointOnSurface1.parameterU`;
float $v = `getAttr closestPointOnSurface1.parameterV`;
vector $color = `colorAtPoint -o RGB -u ($u) -v ($v) ramp2`;
particleShape1.rgbPP = $color;
Hello,
This simulation seems to be a litlle slower than the 'nearestPointOnMesh' routine....
How can I color the particles when they are exactly above the plane?
thanks,
bern
If the plane is really truly a flat plane and its y-coordinates are exactly the same everywhere, meaning it is not tilted, then this would do:
vector $pos = particleShape1.position;
setAttr closestPointOnSurface1.inPosition ($pos.x) ($pos.y) ($pos.z);
vector $closestPoint = `getAttr closestPointOnSurface1.position`;
vector $vectorToSurface = $closestPoint - particleShape1.position;
float $angle = angle($vectorToSurface, <<0,-1,0>>);
if($angle == 0) {
float $u = `getAttr closestPointOnSurface1.parameterU`;
float $v = `getAttr closestPointOnSurface1.parameterV`;
vector $color = `colorAtPoint -o RGB -u ($u) -v ($v) ramp2`;
particleShape1.rgbPP = $color;
}
else {
particleShape1.rgbPP = <<0.5,0.5,0.5>>;
}
it relies on the angle from the particle down to the point on the surface. If the angle between the y-axis and the vector from the particle to the closest surface point is zero, then do the color thing.
There's probably a more flexible way of doing this....
Aikiman
07-06-2008, 10:11 PM
...well, using the node approach, I do get som strange results with closestPointOnMesh... liek it's not updating properly... ah well, later.
But for nurbs surfaces and using a closestPointOnSurface node it works fine. Then the runtime expression could look like this:
vector $pos = particleShape1.position;
setAttr closestPointOnSurface1.inPosition ($pos.x) ($pos.y) ($pos.z);
float $u = `getAttr closestPointOnSurface1.parameterU`;
float $v = `getAttr closestPointOnSurface1.parameterV`;
vector $color = `colorAtPoint -o RGB -u ($u) -v ($v) ramp2`;
particleShape1.rgbPP = $color;
good stuff ctp! I was trying to assign my pp positions the wrong way, seems so simple now. Thats awesome why didnt I think of that hehehe, I just piped in my scalePP so my particles change in size according to ramp. :beer:
CGTalk Moderation
07-06-2008, 10:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.