object position in shader

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/10/2009 at 00:50, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   r11 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi there,

in a shader plugin i am trying to get the position of all objects in a scene, to do some further calculations. I am doing it this way:

> `

  
\>  if (volumeData)  
\>  {            
\>  RayObject *parent = volumeData->op;  
\>  if (parent)  
\>  {  
\>  oC = volumeData->GetObjCount()-1;  
\>  for (int i=0;i<oC;i++)  
\>  {  
\>  rObj = volumeData->GetObj(i);  
\>  p1 = rObj->mp;  
\>  p2 = parent->mp;   
\>  //using p2 works and gives some colors, but p1 returns black  
\>  value += p2/10000;   
\>  }  
\>  return value;  
\>  }  
\>  }  
\>  

`

any ideas what i am doing wrong ? Thanks in advance for your input

cheers,
Ello

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/10/2009 at 01:36, xxxxxxxx wrote:

i tried this one, too, just to check
_
BaseObject *rObj = volumeData- >GetObj(i)->link;
if (rObj) value.x = 1.0;//rObj->GetPos().x;
else value.y = 1.0;
_
the objects are rendered red, so the rObj is found. but using rObj->GetPos().x; gives only black..

but why?? i dont understand

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/10/2009 at 03:19, xxxxxxxx wrote:

You should get the position through the rayobject's matrix for instance.

Something like this works (spherical gradient from the world orign) :

> \> Vector MandelbrotData::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      if (cd->vd && cd->vd->op) \>      { \>           LReal len = Len(cd->vd->op->mg.off); \>           return LClamp(0.0, 1000.0, len) / 1000.0; \>      } \> \>      return 0.0; \> } \>

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/10/2009 at 04:59, xxxxxxxx wrote:

ah.. ok, that seems to work.

thank you

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/10/2009 at 12:03, xxxxxxxx wrote:

hi again, i need a little advice on what is wrong here. i want to check, wether objects have other objects nearby, but its not working. here is my snippet, where is my fault?

> `

  
\>  RayObject *parent = volumeData->op;  
\>  if (!parent) goto endit;  
\>  pPos = parent->mg.off;  
\>  LONG oc = volumeData->GetObjCount();  
\>  for (int i=0;i<(oc-1);i++)  
\>  {  
\>  RayObject* robj = volumeData->GetObj(i);  
\>  if (Len(pPos - robj->mg.off)<100) result = 1.0;  
\>  }  
\>  return result;  
\>  

`

i was thinking that with this shader every object that has another object in the 100 units range should be whitem but well, it isnt working like that.

thanks for your help,
ello