[b]Hi, all.
I have spent several months trying to find the way to accomplish some tasks in a project, without success, and I think you may have the solution.
Well, my project is written in LabView, and consists of a 3D scene where it’s displayed a robot arm. It has been represented using the 3D Picture Control (LabView toolkit for 3D scene representation). Every mechanical part of the robot is a VRML model (they’re not simple geometries) that has been loaded and placed defining relationships between them, and I can control their relative movements with some controls placed on the LabView control panel window.
The representation with the 3D Picture Control has been fairly easy and satisfactory, but now I need to add several advanced capabilities, such as collision detection (between the robot itself, with other objects and with the ground). Since the 3D Picture Control doesn’t have these functions, I began to learn OpenGL.
I don’t want to redisplay the model again in the OpenGL render window, because it’s properly displayed in the 3D Picture Control; but I want to pass geometric data to the C-OpenGL program, rebuilt in this program those mechanical parts that could collide, and use some kind of algorithm for collision detection between them. This code would run once every LabView processing cycle, and check whether there’s collision or not.
I have found several problems:
-
I’m trying to execute a C program with OpenGL in LabView. I compile it into a dll and use the Call Library Function Node. I have also replaced the glutMainLoop of GLUT for glutMainLoopEvent of freeGLUT. This is because glutMainLoop never exits the OpenGL main loop and doesn’t return the control to the calling function (LabView, in this case); but glutMainLoopEvent does. However, I found that LabView goes wrong when trying to run the program (well, more exactly, the first time I run, it goes OK; but the second, LabView crashes and closes itself).
-
Is it worth learning OpenGL or should I learn OpenSG (OpenSceneGraph, based on C++) since there are high level libraries based on it that detect collisions? Are there efficient algorithms in OpenGL for collision detection? On the other hand, I’ve found on the internet an OpenSG-based library, called CollDet, that seems to perform these calculations:
CollDet website:
http://cg.in.tu-clausthal.de/research/colldet/index.shtml http://cg.in.tu-clausthal.de/research/colldet/index.shtml[/b]
I paste here the code of the OpenGL program:
#include “stdafx.h”
#include <freeglut.h>
extern “C” __declspec(dllexport)int MyFunction();
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25,0.25,0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();
}
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}
void MyOpenGL()
{
int argc = 1;
char* argv[1] = {{“”}};
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(700,100);
glutCreateWindow(“My Window”);
init();
glutDisplayFunc(display);
glutMainLoopEvent();
}
int MyFunction()
{
MyOpenGL();
return 0;
}
[b]
Well, I hope you can help me.
Thanks in advance,
Francisco[/b]