PDA

View Full Version : Get vertex colour from Gradient Ramp


DaveWortley
12-01-2009, 09:46 AM
I've got an animated gradient ramp black/white (solid interpolation) and I want to trigger an animation when the face changes from black to white. So what I want to do is keep an array of all the vertices, then when they change to white then trigger some code.

Can't seem to work out how I convert the vertex position to UV space and then get the rgb value of that point in uv space.... I'm sure I've done it before but forgotten it seems.

DaveWortley
12-01-2009, 11:08 AM
And another small question, how do I convert a normalized vector into a $.rotation value?

MerlinEl
12-01-2009, 12:26 PM
And another small question, how do I convert a normalized vector into a $.rotation value?

hi

try this


fn GetVectorsAngle v1 v2 =
(
theAngle = acos(dot (normalize v1) (normalize v2))
)
GetVectorsAngle [10,0,0] [10,20,0]

arbAxis <point3>
Returns a Matrix3 value representing an arbitrary axis system using point3 as the "up" direction.

matrixFromNormal <point3>
Returns a Matrix3 value with the normal specified by the given point as the Z axis. The translation portion of the Matrix3 value will be [0,0,0]. The components of the scale portion are the inverse of the values required to normalize the point3 value.

DaveWortley
12-01-2009, 01:48 PM
Surely a normalized vector is a direction? Or have I got my understanding of vector math completely wrong? doesn't it take 0,0,0 as a base and that gives you a direction?

b = polyop.getfacenormal $ 1

returns a value of [0.370587,-0.806068,0.461432]
I'm confused how I convert this to a quat value so when I create a Point helper I can write....
Point pos:0,0,0 rotation:b

PiXeL_MoNKeY
12-01-2009, 04:16 PM
It is a direction, however direction or .dir expects and returns a point3 value. After creating the Point set its .dir property to the normal. Or you could use MaxtrixFromNormal to convert the normal to a matrix3 value for the Point.Node Transform Properties<node>.dir : Point3 -- local z-axis direction vector

Rotates node so that the node's Z axis points in the specified direction. The node is rotated around its Z axis such that the Y axis points as much as possible in the world -Z direction.

Getting and setting <node>.dir now respects the current coordinate system. Previously, this property was always in world coordinates.Point3 ValuesmatrixFromNormal <point3>

Returns a Matrix3 value with the normal specified by the given point as the Z axis. The translation portion of the Matrix3 value will be [0,0,0]. The components of the scale portion are the inverse of the values required to normalize the point3 value-eric

DaveWortley
12-01-2009, 05:11 PM
Perfect Pixel Monkey. Wasn't aware of the dir property. That will be very useful in this project.

So... back to my original issue with testing vertices for colour change....
I'm wondering do i have to use RenderTexturemap, then match uv co-ords to texture co-ords to test? Or is there a simpler way... Anyone?

PiXeL_MoNKeY
12-01-2009, 05:40 PM
You can look up Barycentric Coordinates here and in the Maxscript Help.
Barycentric coordinates are the coordinates relative to the triangular face. The barycentric coordinates of a point p relative to a triangle describe that point as a weighted sum of the vertices of the triangle.

If the barycentric coordinates are b0, b1, and b2, then



p = b0*p0 + b1*p1 + b2*p2



where p0, p1, and p2 are the positions of the vertices of the triangle.

The Point3 returned by this method has the barycentric coordinate stored in its three component values. The coordinate is relative to the triangular face that was intersected.

Barycentric coordinates can also be used to interpolate any quantity whose value is known at the vertices of the triangle.-Eric

CGTalk Moderation
12-01-2009, 05:40 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.