| ARToolKit | Mailing List Archive |
|
| From: | "alex gillet" <gillet@s ..........> | Received: | Mar 6, 2003 |
| To | artoolkit@h .................. | ||
| Subject: | front and back faces coloring on 3D object | ||
This is a multi-part message in MIME format.
--------------080903000209040206050406
Content-Type:
Content-Transfer-Encoding: 8bit
Hi,
I would like to know if anyone has encounter a problem with displaying a 3D
object with both front and black faces colored.
I did modify the simpleTest example from ARToolKit-2.52.vrml to be able to
assign a different color to the back face of the teapot (front is blue, back
is red).I also make sure to light both the front and the back faces of the
object.
When I run the test, the object displays with the back face in front of the
front face. The outside of the teatpot is red and the inside is blue.
I was wondering if anyone has a fix for it. Is it due to the rotation of 180
degree around x of the transformation matrix?
I attached my version of the simpleTest.cpp.
Thanks
Alex
--------------080903000209040206050406
Content-Type: text/plain; charset=windows-1252;
name="simpleTe.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="simpleTe.cpp"
//#ifdef _WIN32
#include <windows.h>
//#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <AR/gsub.h>
#include <AR/param.h>
#include <AR/ar.h>
#include <AR/ARFrameGrabber.h>
char *vconf = "";
int xsize, ysize;
int thresh = 100;
int count = 0;
char *cparam_name = "Data/camera_para.dat";
ARParam cparam;
char *patt_name = "Data/patt.hiro";
int patt_id;
int patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];
static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop(void);
static void draw( void );
ARFrameGrabber camera;
int main()
{
CoInitialize(NULL);
//initialize applications
init();
//start the video capture
camera.Init(0,xsize,ysize);
camera.DisplayProperties();
//camera.SetFlippedImage(false);
camera.SetFlippedImageHorizontal(false);
camera.SetFlippedImageVertical(true);
//start the main event loop
argMainLoop( NULL, keyEvent, mainLoop );
CoUninitialize();
return 0;
}
static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed */
if( key == 0x1b ) {
printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}
/* main loop */
static void mainLoop(void)
{
ARUint8 *dataPtr;
ARMarkerInfo *marker_info;
int marker_num;
int j, k;
/* grab a video frame */
camera.GrabFrame();
if( (dataPtr = (ARUint8 *)camera.GetBuffer()) == NULL ) {
arUtilSleep(2);
return;
}
if( count == 0 ) arUtilTimerReset();
count++;
argDrawMode2D();
argDispImage( dataPtr, 0,0 );
/* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
cleanup();
exit(0);
}
/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
if( patt_id == marker_info[j].id ) {
if( k == -1 ) k = j;
else if( marker_info[k].cf < marker_info[j].cf ) k = j;
}
}
if( k == -1 ) {
argSwapBuffers();
return;
}
/* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
draw();
/* get ready to grab a new video frame */
argSwapBuffers();
}
static void init( void )
{
ARParam wparam;
/* Note: the video image captured is hard coded to 320x240 */
xsize = 320; ysize = 240;
printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
printf("Camera parameter load error !!\n");
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf("*** Camera Parameter ***\n");
arParamDisp( &cparam );
if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
printf("pattern load error !!\n");
exit(0);
}
/* open the graphics window */
argInit( &cparam, 2.0, 0, 0, 0, 0 );
}
/* cleanup function called when program exits */
static void cleanup(void)
{
argCleanup();
}
static void draw( void )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_ambientB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flashB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_BACK, GL_SPECULAR, mat_flashB);
glMaterialfv(GL_BACK, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_BACK, GL_AMBIENT, mat_ambientB);
glMatrixMode(GL_MODELVIEW);
glRotatef( 90, 1.0, 0.0, 0.0 );
glTranslatef( 0.0, 35.0, 0.0 );
glutSolidTeapot(30);
//glutSolidCube(50.0);
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
}
--------------080903000209040206050406--
|
|||
| From: | "alex gillet" <gillet@s ..........> | Received: | Mar 6, 2003 |
| To | artoolkit@h .................. | ||
| Subject: | front and back faces coloring on 3D object | ||
This is a multi-part message in MIME format.
--------------070903060602090606060604
Content-Type:
Content-Transfer-Encoding: 8bit
Hi,
I would like to know if anyone has encounter a problem with displaying a 3D
object with both front and black faces colored.
I did modify the simpleTest example from ARToolKit-2.52.vrml to be able to
assign a different color to the back face of the teapot (front is blue, back
is red).I also make sure to light both the front and the back faces of the
object.
When I run the test, the object displays with the back face in front of the
front face. The outside of the teatpot is red and the inside is blue.
I was wondering if anyone has a fix for it. Is it due to the rotation of 180
degree around x of the transformation matrix?
I attached my version of the simpleTest.cpp.
Thanks
Alex
--------------070903060602090606060604
Content-Type: text/plain; charset=windows-1252;
name="simpleTe.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="simpleTe.cpp"
//#ifdef _WIN32
#include <windows.h>
//#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <AR/gsub.h>
#include <AR/param.h>
#include <AR/ar.h>
#include <AR/ARFrameGrabber.h>
char *vconf = "";
int xsize, ysize;
int thresh = 100;
int count = 0;
char *cparam_name = "Data/camera_para.dat";
ARParam cparam;
char *patt_name = "Data/patt.hiro";
int patt_id;
int patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];
static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop(void);
static void draw( void );
ARFrameGrabber camera;
int main()
{
CoInitialize(NULL);
//initialize applications
init();
//start the video capture
camera.Init(0,xsize,ysize);
camera.DisplayProperties();
//camera.SetFlippedImage(false);
camera.SetFlippedImageHorizontal(false);
camera.SetFlippedImageVertical(true);
//start the main event loop
argMainLoop( NULL, keyEvent, mainLoop );
CoUninitialize();
return 0;
}
static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed */
if( key == 0x1b ) {
printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}
/* main loop */
static void mainLoop(void)
{
ARUint8 *dataPtr;
ARMarkerInfo *marker_info;
int marker_num;
int j, k;
/* grab a video frame */
camera.GrabFrame();
if( (dataPtr = (ARUint8 *)camera.GetBuffer()) == NULL ) {
arUtilSleep(2);
return;
}
if( count == 0 ) arUtilTimerReset();
count++;
argDrawMode2D();
argDispImage( dataPtr, 0,0 );
/* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
cleanup();
exit(0);
}
/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
if( patt_id == marker_info[j].id ) {
if( k == -1 ) k = j;
else if( marker_info[k].cf < marker_info[j].cf ) k = j;
}
}
if( k == -1 ) {
argSwapBuffers();
return;
}
/* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
draw();
/* get ready to grab a new video frame */
argSwapBuffers();
}
static void init( void )
{
ARParam wparam;
/* Note: the video image captured is hard coded to 320x240 */
xsize = 320; ysize = 240;
printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
printf("Camera parameter load error !!\n");
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf("*** Camera Parameter ***\n");
arParamDisp( &cparam );
if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
printf("pattern load error !!\n");
exit(0);
}
/* open the graphics window */
argInit( &cparam, 2.0, 0, 0, 0, 0 );
}
/* cleanup function called when program exits */
static void cleanup(void)
{
argCleanup();
}
static void draw( void )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_ambientB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flashB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_BACK, GL_SPECULAR, mat_flashB);
glMaterialfv(GL_BACK, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_BACK, GL_AMBIENT, mat_ambientB);
glMatrixMode(GL_MODELVIEW);
glRotatef( 90, 1.0, 0.0, 0.0 );
glTranslatef( 0.0, 35.0, 0.0 );
glutSolidTeapot(30);
//glutSolidCube(50.0);
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
}
--------------070903060602090606060604--
|
|||
| From: | "alex gillet" <gillet@s ..........> | Received: | Mar 6, 2003 |
| To | artoolkit@h .................. | ||
| Subject: | front and back faces coloring on 3D object | ||
This is a multi-part message in MIME format.
--------------020707060905020506080308
Content-Type:
Content-Transfer-Encoding: 8bit
Hi,
I would like to know if anyone has encounter a problem with displaying a 3D
object with both front and black faces colored.
I did modify the simpleTest example from ARToolKit-2.52.vrml to be able to
assign a different color to the back face of the teapot (front is blue, back
is red).I also make sure to light both the front and the back faces of the
object.
When I run the test, the object displays with the back face in front of the
front face. The outside of the teatpot is red and the inside is blue.
I was wondering if anyone has a fix for it. Is it due to the rotation of 180
degree around x of the transformation matrix?
I attached my version of the simpleTest.cpp.
Thanks
Alex
--------------020707060905020506080308
Content-Type: text/plain; charset=windows-1252;
name="simpleTe.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="simpleTe.cpp"
//#ifdef _WIN32
#include <windows.h>
//#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <AR/gsub.h>
#include <AR/param.h>
#include <AR/ar.h>
#include <AR/ARFrameGrabber.h>
char *vconf = "";
int xsize, ysize;
int thresh = 100;
int count = 0;
char *cparam_name = "Data/camera_para.dat";
ARParam cparam;
char *patt_name = "Data/patt.hiro";
int patt_id;
int patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];
static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop(void);
static void draw( void );
ARFrameGrabber camera;
int main()
{
CoInitialize(NULL);
//initialize applications
init();
//start the video capture
camera.Init(0,xsize,ysize);
camera.DisplayProperties();
//camera.SetFlippedImage(false);
camera.SetFlippedImageHorizontal(false);
camera.SetFlippedImageVertical(true);
//start the main event loop
argMainLoop( NULL, keyEvent, mainLoop );
CoUninitialize();
return 0;
}
static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed */
if( key == 0x1b ) {
printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}
/* main loop */
static void mainLoop(void)
{
ARUint8 *dataPtr;
ARMarkerInfo *marker_info;
int marker_num;
int j, k;
/* grab a video frame */
camera.GrabFrame();
if( (dataPtr = (ARUint8 *)camera.GetBuffer()) == NULL ) {
arUtilSleep(2);
return;
}
if( count == 0 ) arUtilTimerReset();
count++;
argDrawMode2D();
argDispImage( dataPtr, 0,0 );
/* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
cleanup();
exit(0);
}
/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
if( patt_id == marker_info[j].id ) {
if( k == -1 ) k = j;
else if( marker_info[k].cf < marker_info[j].cf ) k = j;
}
}
if( k == -1 ) {
argSwapBuffers();
return;
}
/* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
draw();
/* get ready to grab a new video frame */
argSwapBuffers();
}
static void init( void )
{
ARParam wparam;
/* Note: the video image captured is hard coded to 320x240 */
xsize = 320; ysize = 240;
printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
printf("Camera parameter load error !!\n");
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf("*** Camera Parameter ***\n");
arParamDisp( &cparam );
if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
printf("pattern load error !!\n");
exit(0);
}
/* open the graphics window */
argInit( &cparam, 2.0, 0, 0, 0, 0 );
}
/* cleanup function called when program exits */
static void cleanup(void)
{
argCleanup();
}
static void draw( void )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_ambientB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flashB[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_BACK, GL_SPECULAR, mat_flashB);
glMaterialfv(GL_BACK, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_BACK, GL_AMBIENT, mat_ambientB);
glMatrixMode(GL_MODELVIEW);
glRotatef( 90, 1.0, 0.0, 0.0 );
glTranslatef( 0.0, 35.0, 0.0 );
glutSolidTeapot(30);
//glutSolidCube(50.0);
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
}
--------------020707060905020506080308--
|
|||