On 04/06/2014 at 12:07, xxxxxxxx wrote:
Cinema 4D Version: 14
Platform: Mac OSX ;
Language(s) : C++ ;
I know how to get the face that is being rendered. I can get it from the VolumeData structure. But that structure is only available when performing a real render, not when the object is being drawn in the editor.
I assume that, inside the Output module of a shader plugin, while the object is being displayed, I can onlu access the ChannelData, not the VolumeData, right?
So, is there any way to find what face is being painted in the editor?
On 06/06/2014 at 11:45, xxxxxxxx wrote:
No way of doing this?
On 07/06/2014 at 16:52, xxxxxxxx wrote:
Since nobody is offering any ideas. I'll post one from my notes.
This code will get the polygons that are facing the camera in the editor.
The only down side is that if the polygon normals are reversed. It will return polygons that you wouldn't normally want to be marked as "Rendered". So you'll have to run some code to check for reversed normals before using this.
//This code gets the faces of a polygon object that are facing/not facing the camera
PolygonObject *pobj = (PolygonObject* ) doc->GetActiveObject();
if (!pobj) return FALSE;
if (!pobj || pobj->GetType() != Opolygon) return FALSE;
//Get all of the polygons and points positions in the object
CPolygon *padr = pobj->GetPolygonW();
Vector *vadr = pobj->GetPointW();
LONG pcnt = pobj->GetPolygonCount();
//The Camera's (global) position
BaseDraw *bd = doc->GetActiveBaseDraw();
BaseObject *cam = bd->GetSceneCamera(doc);
if(!cam) cam = bd->GetEditorCamera();
Vector camPos = cam->GetMg().off;
//Get the global matrix of the active object
Matrix objmtx = pobj->GetMg();
Vector N, V;
for(LONG i = 0L; i != pcnt; ++i)
p = padr[i]; //Get each polygon in the active object
N = CalcFaceNormal(vadr, p)*objmtx; //Normal vector of polygon
V = vadr[p.a]*objmtx;
dir = N*(camPos-V); //Determine if the polygon is facing the camera
if(dir <= 0.0) GePrint("Polys Not facing the camera " + LongToString(i));
else GePrint("Polys facing the Camera " + LongToString(i));
On 08/06/2014 at 04:15, xxxxxxxx wrote:
Thank you very much, Scott. This will help me a lot.
It is amazing how, after just two or three days of coding in C++, I can already understand what all that code does