From c6a905f7e9d7ad29b883d354fb1d8e6ba730b058 Mon Sep 17 00:00:00 2001 From: Francis Laurence Date: Sun, 12 Jan 2003 19:48:53 +0000 Subject: Hello, *Fixed boolean buglet in the bsp lib. I have not committed any libraries so you'll have to do this to see the changes in blender. *Got the bsp test program working again with the new GHOST createWindow interface. *(Visual C++) Modfied some of the dsp in the intern library to NOT prompt when overwirting old libs and header files. This is the /Y option after XCOPY Cheers Laurence. --- intern/bsp/intern/BSP_CSGUserData.cpp | 4 +- intern/bsp/make/msvc6_0/bsplib.dsp | 4 +- intern/bsp/test/BSP_GhostTest/BSP_GhostTest.dsp | 4 - intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp | 109 +++++++++++----------- intern/bsp/test/BSP_GhostTest/BSP_TMesh.h | 51 +++++++++- 5 files changed, 107 insertions(+), 65 deletions(-) (limited to 'intern/bsp') diff --git a/intern/bsp/intern/BSP_CSGUserData.cpp b/intern/bsp/intern/BSP_CSGUserData.cpp index a22f88f2f24..fec5ff560e6 100755 --- a/intern/bsp/intern/BSP_CSGUserData.cpp +++ b/intern/bsp/intern/BSP_CSGUserData.cpp @@ -66,7 +66,7 @@ Duplicate( int output = Size(); IncSize(); - memcpy(&m_data[ m_data.size() - 1 - m_width ], record, m_width); + memcpy(&m_data[ m_data.size() - m_width ], record, m_width); return output; } @@ -80,7 +80,7 @@ Duplicate( ){ if (m_width) { IncSize(); - memcpy(&m_data[ m_data.size() - 1 - m_width ], + memcpy(&m_data[ m_data.size() - m_width ], &m_data[ record_index * m_width], m_width); } } diff --git a/intern/bsp/make/msvc6_0/bsplib.dsp b/intern/bsp/make/msvc6_0/bsplib.dsp index 2ec59bd7533..624879414f1 100644 --- a/intern/bsp/make/msvc6_0/bsplib.dsp +++ b/intern/bsp/make/msvc6_0/bsplib.dsp @@ -53,7 +53,7 @@ LIB32=link.exe -lib # ADD LIB32 /nologo /out:"..\..\..\..\obj\windows\intern\bsp\libbsp.lib" # Begin Special Build Tool SOURCE="$(InputPath)" -PostBuild_Cmds=ECHO Copying header files XCOPY /E ..\..\extern\*.h ..\..\..\..\lib\windows\bsp\include\ ECHO Copying lib XCOPY /E ..\..\..\..\obj\windows\intern\bsp\*.lib ..\..\..\..\lib\windows\bsp\lib\*.a ECHO Done +PostBuild_Cmds=ECHO Copying header files XCOPY /E /Y ..\..\extern\*.h ..\..\..\..\lib\windows\bsp\include\ ECHO Copying lib XCOPY /E /Y ..\..\..\..\obj\windows\intern\bsp\*.lib ..\..\..\..\lib\windows\bsp\lib\*.a ECHO Done # End Special Build Tool !ELSEIF "$(CFG)" == "bsplib - Win32 Debug" @@ -82,7 +82,7 @@ LIB32=link.exe -lib # ADD LIB32 /nologo /out:"..\..\..\..\obj\windows\intern\bsp\debug\libbsp.lib" # Begin Special Build Tool SOURCE="$(InputPath)" -PostBuild_Cmds=ECHO Copying header files XCOPY /E ..\..\extern\*.h ..\..\..\..\lib\windows\bsp\include\ ECHO Copying lib XCOPY /E ..\..\..\..\obj\windows\intern\bsp\debug\*.lib ..\..\..\..\lib\windows\bsp\lib\debug\*.a ECHO Copying Debug info. XCOPY /E ..\..\..\..\obj\windows\intern\bsp\debug\vc60.* ..\..\..\..\lib\windows\bsp\lib\debug\ ECHO Done +PostBuild_Cmds=ECHO Copying header files XCOPY /E /Y ..\..\extern\*.h ..\..\..\..\lib\windows\bsp\include\ ECHO Copying lib XCOPY /E /Y ..\..\..\..\obj\windows\intern\bsp\debug\*.lib ..\..\..\..\lib\windows\bsp\lib\debug\*.a ECHO Copying Debug info. XCOPY /E /Y ..\..\..\..\obj\windows\intern\bsp\debug\vc60.* ..\..\..\..\lib\windows\bsp\lib\debug\ ECHO Done # End Special Build Tool !ENDIF diff --git a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest.dsp b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest.dsp index 1e913289824..aaa45273845 100755 --- a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest.dsp +++ b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest.dsp @@ -108,10 +108,6 @@ SOURCE=.\BSP_PlyLoader.h # End Source File # Begin Source File -SOURCE=.\BSP_TMesh.cpp -# End Source File -# Begin Source File - SOURCE=.\BSP_TMesh.h # End Source File # Begin Source File diff --git a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp index 5d8410462be..fe6a2943d1e 100755 --- a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp +++ b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp @@ -64,6 +64,17 @@ #include + int +EmptyInterpFunc( + void *d1, + void * d2, + void *dnew, + float epsilon +){ + return 0; +} + + using namespace std; @@ -125,10 +136,6 @@ Swap( } - - - - MT_Transform BSP_GhostTestApp3D:: GetTransform( @@ -174,25 +181,29 @@ Operate( // describe properties. CSG_MeshPropertyDescriptor props; - props.mesh_property_flags = 0; + props.user_face_vertex_data_size = 0; props.user_data_size = 0; CSG_BooleanOperation * op = CSG_NewBooleanFunction(); props = CSG_DescibeOperands(op,props,props); - CSG_PerformBooleanOperation(op,CSG_OperationType(type), - *fA,*vA,*fB,*vB + CSG_PerformBooleanOperation( + op,CSG_OperationType(type), + *fA,*vA,*fB,*vB,EmptyInterpFunc ); - CSG_FaceIteratorDescriptor * out_f = CSG_OutputFaceDescriptor(op); - CSG_VertexIteratorDescriptor * out_v = CSG_OutputVertexDescriptor(op); + CSG_FaceIteratorDescriptor out_f; + CSG_OutputFaceDescriptor(op,&out_f); + + CSG_VertexIteratorDescriptor out_v; + CSG_OutputVertexDescriptor(op,&out_v); - MEM_SmartPtr new_mesh (BuildMesh(props,*out_f,*out_v)); + MEM_SmartPtr new_mesh (BuildMesh(props,out_f,out_v)); // free stuff - CSG_FreeVertexDescriptor(out_v); - CSG_FreeFaceDescriptor(out_f); + CSG_FreeVertexDescriptor(&out_v); + CSG_FreeFaceDescriptor(&out_f); CSG_FreeBooleanOperation(op); op = NULL; @@ -255,8 +266,8 @@ InitApp( m_window = m_system->createWindow( "GHOST crud3D!", - 100,100,640,480,GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL + 100,100,512,512,GHOST_kWindowStateNormal, + GHOST_kDrawingContextTypeOpenGL,false ); if ( @@ -312,7 +323,8 @@ processEvent( { int x,y; m_system->getCursorPosition(x,y); - + + int wx,wy; m_window->screenToClient(x,y,wx,wy); @@ -346,7 +358,8 @@ processEvent( m_rotation_settings[m_current_object].m_moving = false; m_rotation_settings[m_current_object].x_old = 0; m_rotation_settings[m_current_object].y_old = 0; - } else + + } else if (button == GHOST_kButtonMaskRight) { m_translation_settings[m_current_object].m_moving = false; m_translation_settings[m_current_object].x_old; @@ -383,9 +396,10 @@ processEvent( GHOST_Rect bounds; m_window->getClientBounds(bounds); - int w_h = bounds.getWidth(); + int w_h = bounds.getHeight(); y = w_h - wy; + x = wx; double mvmatrix[16]; double projmatrix[16]; @@ -402,16 +416,9 @@ processEvent( GLdouble ex,ey,ez; - MT_Vector3 bbox_min, bbox_max; - - bbox_min = m_meshes[0]->m_min; - bbox_max = m_meshes[0]->m_max; - - MT_Vector3 bbox_centre = (bbox_min + bbox_max)/2; - - ex = bbox_centre.x(); - ey = bbox_centre.y(); - ez = bbox_centre.z(); + ex = m_translation_settings[m_current_object].m_t_x; + ey = m_translation_settings[m_current_object].m_t_y; + ez = m_translation_settings[m_current_object].m_t_z; gluProject(ex, ey, ez, mvmatrix, projmatrix, viewport, &px, &py, &sz); gluUnProject((GLdouble) x, (GLdouble) y, sz, mvmatrix, projmatrix, viewport, &px, &py, &pz); @@ -475,24 +482,19 @@ processEvent( } case GHOST_kKeyR: - m_render_modes[m_current_object]++; - if (m_render_modes[m_current_object] > e_last_render_mode) { m_render_modes[m_current_object] = e_first_render_mode; } - handled = true; m_window->invalidate(); break; - - case GHOST_kKeyB: handled = true; m_window->invalidate(); break; - + case GHOST_kKeyQ: m_finish_me_off = true; handled = true; @@ -503,20 +505,19 @@ processEvent( m_window->invalidate(); handled = true; break; - + case GHOST_kKeySpace: - + // increment the current object only if the object is not being // manipulated. if (! (m_rotation_settings[m_current_object].m_moving || m_translation_settings[m_current_object].m_moving)) { m_current_object ++; if (m_current_object >= m_meshes.size()) { m_current_object = 0; + } } m_window->invalidate(); - - handled = true; break; default : @@ -527,9 +528,7 @@ processEvent( default : break; } - return handled; - }; BSP_GhostTestApp3D:: @@ -543,37 +542,34 @@ BSP_GhostTestApp3D:: m_system = NULL; } }; + + void BSP_GhostTestApp3D:: DrawPolies( ){ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (int i = 0; i < m_meshes.size(); ++i) { - MT_Transform trans = GetTransform(i); float opengl_mat[16]; trans.getValue(opengl_mat); - opengl_mat[14] -= 30; - glPushMatrix(); - glLoadMatrixf(opengl_mat); - + glMultMatrixf(opengl_mat); MT_Vector3 color(1.0,1.0,1.0); - if (i == m_current_object) { color = MT_Vector3(1.0,0,0); } - BSP_MeshDrawer::DrawMesh(m_meshes[i].Ref(),m_render_modes[i]); glPopMatrix(); } m_window->swapBuffers(); + } void @@ -590,28 +586,30 @@ InitOpenGl( GLfloat light_position1[] = {1.0, 0, 0, 0.0}; /* Infinite light location. */ /* Enable a single OpenGL light. */ + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse0); glLightfv(GL_LIGHT0, GL_POSITION, light_position0); glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1); glLightfv(GL_LIGHT1, GL_POSITION, light_position1); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - glEnable(GL_LIGHTING); - // make sure there is no back face culling. -// glDisable(GL_CULL_FACE); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glEnable(GL_LIGHTING); + // make sure there is no back face culling. + // glDisable(GL_CULL_FACE); // use two sided lighting model - - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE); /* Use depth buffering for hidden surface elimination. */ + glEnable(GL_DEPTH_TEST); /* Setup the view of the cube. */ + glMatrixMode(GL_PROJECTION); // centre of the box + 3* depth of box @@ -633,7 +631,8 @@ InitOpenGl( gluLookAt( centre.x(), centre.y(), centre.z() + distance*depth, //eye centre.x(), centre.y(), centre.z(), //centre - 0.0, 1.0, 0.); /* up is in positive Y direction */ + 0.0, 1.0, 0. + ); /* up is in positive Y direction */ } diff --git a/intern/bsp/test/BSP_GhostTest/BSP_TMesh.h b/intern/bsp/test/BSP_GhostTest/BSP_TMesh.h index 4322fedbed4..eeb4df3d0d9 100755 --- a/intern/bsp/test/BSP_GhostTest/BSP_TMesh.h +++ b/intern/bsp/test/BSP_GhostTest/BSP_TMesh.h @@ -80,12 +80,35 @@ public : AddFace( int *verts, int num_verts - ); + ){ + int i; + for (i= 2; i pos); }; +static + void +VertexIt_Reset( + CSG_IteratorPtr it +) { + // assume CSG_IteratorPtr is of the correct type. + VertexIt * vertex_it = (VertexIt *)it; + + vertex_it->pos = vertex_it->mesh->VertexSet().begin(); +}; + static CSG_VertexIteratorDescriptor * VertexIt_Construct( @@ -170,6 +204,7 @@ VertexIt_Construct( output->Done = VertexIt_Done; output->Fill = VertexIt_Fill; output->Step = VertexIt_Step; + output->Reset = VertexIt_Reset; output->num_elements = mesh->VertexSet().size(); VertexIt * v_it = new VertexIt; @@ -244,6 +279,17 @@ FaceIt_Step( face_it->pos ++; }; +static + void +FaceIt_Reset( + CSG_IteratorPtr it +) { + // assume CSG_IteratorPtr is of the correct type. + FaceIt * face_it = (FaceIt *)it; + + face_it->pos = face_it->mesh->FaceSet().begin(); +}; + static CSG_FaceIteratorDescriptor * FaceIt_Construct( @@ -255,6 +301,7 @@ FaceIt_Construct( output->Done = FaceIt_Done; output->Fill = FaceIt_Fill; output->Step = FaceIt_Step; + output->Reset = FaceIt_Reset; output->num_elements = mesh->FaceSet().size(); -- cgit v1.2.3