Hello all,
I am experimenting with Radiance code, with the purpose of creating a
calculation engine for Groundhog.
In the process, I have managed to write a C++ program (early tests have
passed, so far) that can read SketchUp model and export it in Radiance
format. However, my intention is to allow it to calculate things, thus
avoiding the need of exporting and handling thousands of files and
scripting.
My idea is to generate a program that basically receives a SketchUp model
and perform several calculations... a very simple call
gh_calc_engine Model.skp > results.txt
The program will need, of course, to create the octree (not from a text
file, but from the internal data structure) and run rtrace or something
like that. I am checking how to do it and haven't gotten very far... could
you guys help me?
For what I understand, a program would need some sort of structure as shown
below my signature, but I am unsure. I am far from compiling.... for now, I
am trying to understand how Radiance works underneath.
Your help/hints and other things will be very appreciated
Kind regards,
Germán
/* Groundhog RTRACE analog */
/* START */
extern CUBE thesene = {{0.0, 0.0, 0.0}, 0.0, EMPTY}; // Define "the scene"
extern OBJECT nsceneobjs; // number of objects
... // some more externs such as raynum, nrays, etc. present in
"src/rt/ray.h"
/* OCONV */
for (size_t i=0; i < nobjects; i++){
// THIS WILL BE DONE WITH MATERIALS AS WELL
// as shown in getobject function in readobj.c
if(obj = newobject() == OVOID)
error("Out of space")
objp = objptr(obj);
// translate
groundhog_object = objects[i];
objp->omod = groundhog_object.material.name; // this would be an int
objp->otype = groundhog_object.type;
objp->oname = groundhog_object.name;
groundhog_object.setRadianceArguments(&objp->oargs); // arguments are
validated by Groundhog
// insert
insertobject(obj);
}
/* RTRACE --- as seen in rt/rtmain.c*/
FVECT orig;
FVECT dir;
RAY thisray;
COLOR rayvalue;
marksources();
setambient();
for(size_t i=0; i < nrays; i++){
origin= groundhog_rays[i].origin; // need to normalize
orig[0] = origin.getX();
orig[1] = origin.getY();
orig[2]= origin.getZ();
direction = groundhog_rays[i].direction; // need to normalize
dir[0] = direction.getX();
dir[1] = direction.getY();
dir[2]= direction.getZ();
// Set up and trace rays … as in rtcompute
rayorigin(&thisray,PRIMARY,NULL,NULL);
if (imm_irrad) { // What does this do? acts like the +i param in RTRACE?
VSUM(thisray.rorg, org, dir, 1.1e-4);
thisray.rdir[0] = -dir[0];
thisray.rdir[1] = -dir[1];
thisray.rdir[2] = -dir[2];
thisray.rmax = 0.0;
thisray.revf = rayirrad;
} else {
VCOPY(thisray.rorg, org);
VCOPY(thisray.rdir, dir);
thisray.rmax = dmax;
if (castonly)
thisray.revf = raycast;
}
// Get value
rayvalue(&thisray); // not sure what this does
rayvalue = thisray.rcol; // Will this give me the RGB values to convert
into Lux or whatever?
// Sync ambient
ambsync(); // How do I initialize this ambient file???
}