Страница 6 из 12
Добавлено: Вс, 11 января 2015, 13:24:32
dyvniy
Аналог солюшена в QtCreator
http://forum.vingrad.ru/topic-355068.htmlКод: Выделить всё
Создаётся subdir проект,
Код
TEMPLATE=subdirs
SUBDIRS+= mylibrary myserver myclient
В подкаталогах mylibrary myserver myclient размещаются вложенные проекты.
Ресурсы в разных проектах ложить под разными префиксами - в дизайнере Qt Creator будет предлагать ресурсы из всех проектов, с одинаковым префиксом их будет не различить, а из клиента можно пользоваться ресурсами только клиента и библиотеки, но не сервера.
Добавлено: Пн, 12 января 2015, 12:20:12
dyvniy
Добавлено: Ср, 14 января 2015, 18:00:50
dyvniy
Добавлено: Пт, 30 января 2015, 18:21:31
dyvniy
Load .stl binary file
http://forums.codeguru.com/showthread.php?148668-loading-a-stl-3d-model-fileКод: Выделить всё
for now i manage to load only binary stl
i enclose my code here..( in C & opengl)
could you send you ascii stl code to me.....
however thank for your help
GLfloat lightPos[] = {-300.0f, 100.0f, 100.0f, 0.0f };
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f;
float vertex[3][3];
struct group
{
float normal[3];
float vertex1[3];
float vertex2[3];
float vertex3[3];
char unuse [2];
} ;
struct group facet[500000] ;
int i,j,num;
char filename[80];
int numfacet[1];
void ReduceToUnit(float vector[3])
{
float length;
length = (float)sqrt((vector[0]*vector[0]) +
(vector[1]*vector[1]) +
(vector[2]*vector[2]));
if(length == 0.0f)
length = 1.0f;
vector[0] /= length;
vector[1] /= length;
vector[2] /= length;
}
void calcNormal(struct group *facet, float out[3])
{
float v1[3],v2[3];
static const int x = 0;
static const int y = 1;
static const int z = 2;
v1[x] = (*facet).vertex1[x] -(*facet).vertex2[x];
v1[y] = (*facet).vertex1[y] - (*facet).vertex2[y];
v1[z] = (*facet).vertex1[z] - (*facet).vertex2[z];
v2[x] = (*facet).vertex2[x] - (*facet).vertex3[x];
v2[y] = (*facet).vertex2[y] - (*facet).vertex3[y];
v2[z] = (*facet).vertex2[z] - (*facet).vertex3[z];
out[x] = v1[y]*v2[z] - v1[z]*v2[y];
out[y] = v1[z]*v2[x] - v1[x]*v2[z];
out[z] = v1[x]*v2[y] - v1[y]*v2[x];
ReduceToUnit(out);
}
void RenderScene(void)
{
float normal[3];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-2.5,0.0,0.0);
glPushMatrix();
glRotatef(xRot,1,0,0);
glRotatef(yRot,0,1,0);
glColor3ub(128, 128, 128);
glBegin(GL_TRIANGLES);
{
for(j=0;j<num;j++)
{
facet[j].vertex1;
facet[j].vertex2;
facet[j].vertex3;
calcNormal(&facet[j],normal);
glNormal3fv(normal);
glVertex3fv(facet[j].vertex1);
glVertex3fv(facet[j].vertex2);
glVertex3fv(facet[j].vertex3);
}
}glEnd();
glPopMatrix();
glutSwapBuffers();
}
void SetupRC()
{
GLfloat ambient[]={ 0.6f,0.6f,0.7f,1.0f};
GLfloat diffuse[]={0.7f,0.7f,0.7f,1.0f};
GLfloat spec[]={1.0f,1.0f,1.0f,1.0f};
GLfloat specma[]={1.0f,1.0f,1.0f,1.0f};
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST); glFrontFace(GL_CCW); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient);
glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR,spec);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT,GL_SPECULAR,specma);
glMateriali(GL_FRONT,GL_SHININESS,128);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
}
void SpecialKeys(int key, int x, int y)
{
if(key == GLUT_KEY_UP)
xRot-= 5.0f;
if(key == GLUT_KEY_DOWN)
xRot += 5.0f;
if(key == GLUT_KEY_LEFT)
yRot -= 5.0f;
if(key == GLUT_KEY_RIGHT)
yRot += 5.0f;
glutPostRedisplay();
}
void ChangeSize(int w, int h)
{
GLfloat nRange = 3.0f;
if(h == 0)
h = 1;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, 2.0*(-nRange), 2.0*(nRange));
else
glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, 2.0*(-nRange), 2.0*(nRange));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
}
int main(int argc, char* argv[])
{
FILE *binary;
FILE *out;
if( (binary =fopen("C:\\program files\\proe2000i\\bin\\carb_restruct.stl","rb"))==NULL ){
printf(" \n the is failed to accessed");
exit(1);
}
out = fopen("C:\\my documents\\stlexperi3.txt","w");
fread(filename,sizeof(char),80,binary) ;
fread(numfacet,sizeof(int),1,binary);
for(i=0;i<80;i++)
fprintf(out,"%c",filename[i]);
for (i=0;i<1;i++)
fprintf(out,"\n%d\n\n",numfacet[i]);
num=numfacet[0];
for (j=0;j<num;j++)
{
fread(facet[j].normal,sizeof(float),3,binary);
fread(facet[j].vertex1,sizeof(float),3,binary);
fread(facet[j].vertex2,sizeof(float),3,binary);
fread(facet[j].vertex3,sizeof(float),3,binary);
fread(facet[j].unuse,sizeof(char),2,binary);
}
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow("Lighted Jet");
glutReshapeFunc(ChangeSize);
glutSpecialFunc(SpecialKeys);
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
return 0;
}
Добавлено: Пн, 13 апреля 2015, 11:03:49
dyvniy
Если image.save(&buffer, "jpg") не работает, положить qjpeg4.dll в папку imageformats к экзешнику
https://justcheckingonall.wordpress.com/2013/01/25/jpeg-in-qt-app/- Спойлер
- Can’t Save JPEG in a Deployed Qt Application
Posted by JustChecking on January 25, 2013
This has been haunting me for quite some time. When building Qt app for Windows, the QImage::save() function did not work for JPEG for deployed applications, while it did work if Qt SDK was installed on the machine.
As per docs, you just need to copy qjpeg4.dll into imageformats folder within the folder where the app’s .exe resides.
The problem was, that I just used the very first qjpeg4.dll file I could put my hands on, presuming they’re all the same.
Well, it appears there are several different versions of this file within the Qt SDK installation, and the one you really need is located in Desktop/Qt/4.x.y/mingw/plugins/imageformats. Take the qjpeg4.dll file located there, and copy it into imageformats folder inside the deployed folder, and all should be swell.
Note: If you’re deploying a debug build, copy the qjpeg4d.dll file instead.
Добавлено: Чт, 23 апреля 2015, 15:34:31
dyvniy