Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Rotate pointcloud in TOPs ?

General discussion about anything TouchDesigner

Rotate pointcloud in TOPs ?

Postby Achim » Sun Aug 11, 2019 2:17 pm

Imagine a pointcloud encoded in TOPs , so then usual rbg = xyz in 32 bit float. I can translate and scale the whole pointcloud using math TOPs (and channel masks), but is there also a way to rotate the pointcloud (completely in TOPs)?

Thx in advance

Cologne area TD artists? Let’s get in touch

Achim
 
Posts: 1711
Joined: Wed Nov 14, 2007 1:52 pm
Location: Cologne

Re: Rotate pointcloud in TOPs ?

Postby greg » Sun Aug 11, 2019 5:58 pm

We're building a few point cloud COMPs with shaders, one that acts like a Transform CHOP transforming texture pixels containing 32-bit floats in RGB. I'll see if it's releasable tomorrow.
User avatar
greg
Staff
 
Posts: 552
Joined: Tue Nov 13, 2007 1:08 am

Re: Rotate pointcloud in TOPs ?

Postby lucasm » Sun Aug 11, 2019 6:08 pm

sounds like what you want is the ability to apply a full matrix based transform to a 3d coordinate, but on the gpu as in tx,ty,tz,rx,ry,rz,sx,sy,sz ?

I've attached something I was fiddling around with the other day - may be what you're looking for.

the actual transform function is quite particular, it looks like this:

Code: Select all
vec3 Transform(vec3 p, vec3 t, vec3 r, vec3 s)
{
   float px = p.x;
   float py = p.y;
   float pz = p.z;
   
   float tx = t.x;
   float ty = t.y;
   float tz = t.z;
   
   float rx = r.x;
   float ry = r.y;
   float rz = r.z;
   
   float sx = s.x;
   float sy = s.y;
   float sz = s.z;
   
   float crx = cos(rx*PI/180);
   float cry = cos(ry*PI/180);
   float crz = cos(rz*PI/180);
   
   float srx = sin(rx*PI/180);
   float sry = sin(ry*PI/180);
   float srz = sin(rz*PI/180);
   
   px *= sx;
   py *= sy;
   pz *= sz;

   vec3 result = vec3(0.);
   result.x = (cry * crz) * px + (srx * sry * crz - srz * crx) * py + (crx * sry * crz + srx * srz) * pz + tx;
   result.y = (cry * srz) * px + (srz * srx * sry + crx * crz) * py + (crx * sry * srz - srx * crz) * pz + ty;
   result.z = -sry * px + (srx * cry) * py + (crx * cry) * pz + tz;
   
   return result;
   
}
Attachments
swirlingBalls_GLSL_Transforms.3.toe
(2.92 MiB) Downloaded 36 times
User avatar
lucasm
 
Posts: 259
Joined: Sat Apr 28, 2012 7:55 pm
Location: Dallas, TX

Re: Rotate pointcloud in TOPs ?

Postby greg » Tue Aug 13, 2019 4:23 am

That's brilliant, and beautiful, Lucas.
User avatar
greg
Staff
 
Posts: 552
Joined: Tue Nov 13, 2007 1:08 am

Re: Rotate pointcloud in TOPs ?

Postby DavidBraun » Tue Aug 13, 2019 10:56 am

transform_point_cloud.png
transform_point_cloud.png (9.58 KiB) Viewed 560 times

Here's another file: https://github.com/DBraun/TouchDesigner ... _cloud.tox

It's pretty easy to modify the code to change the order of operations. As Lucas has done, it gets cool when you augment the translation/rotation/scale parameters with another input texture.
DavidBraun
 
Posts: 346
Joined: Wed Feb 25, 2015 1:35 pm
Location: Chicago

Re: Rotate pointcloud in TOPs ?

Postby Achim » Tue Aug 13, 2019 2:14 pm

Thx a lot Lucas and David. Works perfectly.

Cologne area TD artists? Let’s get in touch

Achim
 
Posts: 1711
Joined: Wed Nov 14, 2007 1:52 pm
Location: Cologne

Re: Rotate pointcloud in TOPs ?

Postby yeataro » Wed Aug 14, 2019 1:04 am

I also share my simple tool, which can be easily integrated with object COMP:

https://github.com/yeataro/TD-PointClou ... former.tox
User avatar
yeataro
 
Posts: 20
Joined: Tue Sep 28, 2010 2:31 pm
Location: Taipei


Return to General TouchDesigner Discussion

Who is online

Users browsing this forum: No registered users and 23 guests