Dick Rous (dick++at++demeern.sgi.com)
Thu, 03 Dec 1998 10:30:53 +0100
perfly -c 3 \ # 3 channels
-g 0 \ # no gui
-H 40,30,36 \ # hor FOV 40, vert FOV 30, offset 36 degrees
# this gives a 4 degree edge-blending area
-l 0 \ # no lighting
-p 0,0,0 \ # position the eyepoint at 0,0,0
-R 0 \ # do not optimize the mesh
<your model of a sphere>
I include a little c-program that generates 180 degree meshes in
Inventor ascii format using the following options:
mesh [shere|cylinder] rows columns radius offset
It draws markers at the viewing offsets / 2, to facilitate the
adjustment of the edge-blending.
It writes to stdout, so just rederict output to a file with
extension .iv and use this file in perfly.
Hope this helps,
regards,
Dick.
--
__________________________________________________________________
Dick Rous Senior Systems Engineer Graphics Technology
European Technical Support
phone: +31-30-6696868 fax: +31-35-6423162 voicemail: 955-6868
__________________________________________________________________
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define MAXROWS (100)
#define MAXCOLS (180)
#define DEGREES 0.017453292
float vertices[MAXCOLS * MAXROWS][3];
int cylinder;
void genHorizontalLines (int rows, int cols,
float radius, float r, float g, float b);
void genVerticalLines (int rows, int cols,
float radius, float r, float g, float b, float offset);
void genDiagonalLines (int rows, int cols,
float radius, float r, float g, float b);
void
main (int argc, char **argv)
{
float radius, offset;
int i, rows, cols;
if (argc < 6)
{
printf ("Usage: %s <cylinder | sphere> <rows> <columns> <radius> <offset>\n", argv[0]);
exit (1);
}
cylinder = strncmp(argv[1], "sphere", 1);
rows = atoi(argv[2]);
cols = atoi(argv[3]);
radius = atof(argv[4]);
offset = atof(argv[5]);
fprintf (stderr, "Creating ascii Inventor file...\n");
printf ("#Inventor V2.1 ascii\n\n");
/*** Red markers ***/
genHorizontalLines (1, cols, radius, 1.0f, 0.0f, 0.0f);
genVerticalLines (rows, 0, radius, 1.0f, 0.0f, 0.0f, offset);
genDiagonalLines (rows, cols, radius, 1.0f, 0.0f, 0.0f);
/*** White mesh ***/
genHorizontalLines (rows, cols, radius, 1.0f, 1.0f, 1.0f);
genVerticalLines (rows, cols, radius, 1.0f, 1.0f, 1.0f, offset);
}
void
genHorizontalLines (int rows, int cols, float radius, float r, float g, float b)
{
int i, j, k;
float psi, theta;
printf ("Separator {\n");
printf ("\tMaterial {\n");
printf ("\t\tdiffuseColor %f %f %f\n", r, g, b);
printf ("\t}");
printf ("\tCoordinate3 {\n");
printf ("\t\t\tpoint [\n");
k = 0;
psi = DEGREES * 180.0f / (float)cols;
for ( i = 0; i < rows + 1; i++)
{
if (cylinder)
theta = 0.0f * DEGREES;
else
theta = ((float)rows / 2.0f - (float)i) * DEGREES * 6.0f;
for (j = 0; j < cols + 1; j++)
{
if (i != rows / 2)
{
vertices[k][0] = -cosf ((float)j * psi) *
cosf (theta) * radius;
vertices[k][2] = -sinf ((float)j * psi) *
cosf (theta) * radius;
if (rows == 1)
vertices[k][1] = 0.0f;
else
{
if (cylinder)
vertices[k][1] = ((float)rows / 2.0f - (float)i) * 2.0f;
else
vertices[k][1] = sinf (theta) * radius;
}
printf ("\t\t\t\t%f %f %f , \n",
vertices[k][0], vertices[k][1], vertices[k][2]);
k++;
}
}
}
printf ("\t\t\t]\n");
printf ("\t}\n");
printf ("\tLineSet {\n");
printf ("\t\tnumVertices\t[");
for (i = 0; i < rows; i++)
printf (" %d,", cols + 1);
printf (" ]\n");
printf ("\t}\n");
printf ("}\n");
}
void
genVerticalLines (int rows, int cols, float radius,
float r, float g, float b, float offset)
{
int i, j, k;
float psi, theta;
int limit = (cols) ? cols + 1 : 7; /*** vertical mesh or 7 markers ***/
printf ("Separator {\n");
printf ("\tMaterial {\n");
printf ("\t\tdiffuseColor %f %f %f\n", r, g, b);
printf ("\t}");
printf ("\tCoordinate3 {\n");
printf ("\t\t\tpoint [\n");
for (i = 0, k = 0; i < limit; i++)
{
if (cols)
psi = 180.0f * DEGREES / (float)cols * (float)i;
else
switch (i)
{
case 0: psi = DEGREES * 0.0f;
break;
case 1: psi = DEGREES * 90.0f;
break;
case 2: psi = DEGREES * 180.0f;
break;
case 3: psi = DEGREES * (90.0f - offset);
break;
case 4: psi = DEGREES * (90.0f + offset);
break;
case 5: psi = DEGREES * (90.0f - offset / 2.0f);
break;
case 6: psi = DEGREES * (90.0f + offset / 2.0f);
break;
}
if (i != 0 && i != cols / 2 && i != cols || cols == 0)
{
for (j = 0; j < rows + 1; j++)
{
if (cylinder)
theta = 0.0f * DEGREES;
else
theta = ((float)rows / 2.0f - (float)j) * 6.0f * DEGREES;
vertices[k][0] = -cosf (psi) *
cosf (theta) * radius;
vertices[k][2] = -sinf (psi) *
cosf (theta) * radius;
if (cylinder)
vertices[k][1] = ((float)rows / 2.0f - (float)j) * 2.0f;
else
vertices[k][1] = sinf (theta) * radius;
printf ("\t\t\t\t%f %f %f , \n",
vertices[k][0], vertices[k][1], vertices[k][2]);
k++;
}
}
}
printf ("\t\t\t]\n");
printf ("\t}\n");
printf ("\tLineSet {\n");
printf ("\t\tnumVertices\t[");
for (i = 0; i < k / (rows + 1); i++)
printf (" %d,", rows + 1);
printf (" ]\n");
printf ("\t}\n");
printf ("}\n");
}
void
genDiagonalLines (int rows, int cols, float radius, float r, float g, float b)
{
int i, j, k;
float psi, theta;
printf ("Separator {\n");
printf ("\tMaterial {\n");
printf ("\t\tdiffuseColor %f %f %f\n", r, g, b);
printf ("\t}");
printf ("\tCoordinate3 {\n");
printf ("\t\t\tpoint [\n");
k = 0;
psi = DEGREES * 180.0f / (float)cols;
for ( i = 0; i < 2; i++)
{
float sign = (i == 0) ? 1.0f : -1.0f;
if (cylinder)
theta = 0.0f * DEGREES;
for (j = 0; j < cols + 1; j++)
{
if (!cylinder)
theta = ((float)rows / 2.0f -
((float)rows / (float)cols) * (float)j) *
DEGREES * 6.0f;
vertices[k][0] = -cosf ((float)j * psi) *
cosf (theta) * radius;
vertices[k][2] = -sinf ((float)j * psi) *
cosf (theta) * radius;
if (cylinder)
{
if (i == 0)
vertices[k][1] = (float)rows - ((float)j *
2.0f * ((float)rows / (float)cols));
else
vertices[k][1] = (float)rows - ((float)(cols - j) *
2.0f * ((float)rows / (float)cols));
}
else
vertices[k][1] = sinf (theta) * radius * sign;
printf ("\t\t\t\t%f %f %f , \n",
vertices[k][0], vertices[k][1], vertices[k][2]);
k++;
}
}
printf ("\t\t\t]\n");
printf ("\t}\n");
printf ("\tLineSet {\n");
printf ("\t\tnumVertices\t[");
for (i = 0; i < 2; i++)
printf (" %d,", cols + 1);
printf (" ]\n");
printf ("\t}\n");
printf ("}\n");
}
This archive was generated by hypermail 2.0b2 on Thu Dec 03 1998 - 01:31:49 PST