Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forum / QtOCC and Transparency

Forum

QtOCC and Transparency
Brandt2008/02/05 10:53
I have add myVC->getContext()->SetTransparency(anAISShape,0.6) to set the transparency. But now nothing is shown.
It works if a remove the gradient background.
Is it possible to have the gradient background and transparency?
P Dolbey2008/02/05 22:19
I had a lot of fun with gradients and ColorScale.

Try putting in a
     glEnable(GL_BLEND);
     glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

after the glOrtho in paintOCC, and see what happens.

Pete

P Dolbey2008/02/06 00:01
I've now got the function looking like

void Qocc3dWidget::paintOCC( void )
{
     glDisable( GL_LIGHTING );
     glMatrixMode( GL_MODELVIEW );
     glPushMatrix();
     glLoadIdentity();
glMatrixMode( GL_PROJECTION );
     glPushMatrix();
glLoadIdentity();

     GLfloat left = -1.0f;
     GLfloat right = 1.0f;
     GLfloat bottom = -1.0f;
     GLfloat top = 1.0f;
     GLfloat depth = 1.0f;

glOrtho( left, right, bottom, top, 1.0, -1.0 );
     glEnable(GL_BLEND);
     glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
          
glBegin( GL_QUADS);
{
glColor4f ( 0.1f, 0.1f, 0.1f, 0.0f );
glVertex3d ( left, bottom, depth );
glVertex3d ( right, bottom, depth );
glColor4f ( 0.9f, 0.9f, 0.9f, 0.0f );
glVertex3d ( right, top, depth );
glVertex3d ( left, top, depth );
}
glEnd();

     glDisable(GL_BLEND);
     glPopMatrix();
     glMatrixMode( GL_MODELVIEW );
     glPopMatrix();
}

However, I did move the position of the callcack point in the occ source as well, which can affect the rendering.

Pete
Brandt2008/02/06 18:20
Many thanks for your help. This works great.

But i have another problem with a clipping plane.
I use this code to define the clipping.
     gp_Pln clipPln(gp_Pnt(m_xcut,0,0),gp_Dir(dir,0,0));
     Standard_Real A,B,C,D;
     clipPln.Coefficients(A,B,C,D);
     myPlane->SetPlane(A,B,C,D);
     myOCC->getView()->SetPlaneOn(myPlane);
     myVC->getContext()->UpdateCurrentViewer();
But this also cuts the gradient background. Depending on the rotation i can see the gradient background or a black background.
Also the grid is cut.
How can i solve this problem?

P Dolbey2008/02/07 21:22
A little bit of debugging with GLIntercept revealed one of the problems - enabled clip planes in OpenGL. So I've modifies the callback routine to fix that as below.

/*!
\brief     The OpenGL paint routine in the callback.
*/
void Qocc3dWidget::paintOCC( void )
{
     GLboolean isPlaneActive[6];
     int i;

     glDisable( GL_LIGHTING );
     glMatrixMode( GL_MODELVIEW );
     glPushMatrix();
     glLoadIdentity();
glMatrixMode( GL_PROJECTION );
     glPushMatrix();
glLoadIdentity();

     GLfloat left = -1.0f;
     GLfloat right = 1.0f;
     GLfloat bottom = -1.0f;
     GLfloat top = 1.0f;
     GLfloat depth = 1.0f;

     for (i = 0; i < 6; i++)
     {
          isPlaneActive[i] = glIsEnabled(GL_CLIP_PLANE0 + i);
          glDisable(GL_CLIP_PLANE0 + i);
     }

glOrtho( left, right, bottom, top, 1.0, -1.0 );
     glEnable( GL_BLEND );
     glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR );
          
glBegin( GL_QUADS );
{
glColor4f ( 0.1f, 0.1f, 0.1f, 0.0f );
glVertex3d ( left, bottom, depth );
glVertex3d ( right, bottom, depth );
glColor4f ( 0.9f, 0.9f, 0.9f, 0.0f );
glVertex3d ( right, top, depth );
glVertex3d ( left, top, depth );
}
glEnd();

     glDisable(GL_BLEND);
     glPopMatrix();
     glMatrixMode( GL_MODELVIEW );
     glPopMatrix();

     for (i = 0; i < 6; i++)
     {
          if (isPlaneActive[i])
          {
               glEnable(GL_CLIP_PLANE0 + i);
          }
     }
}

I'm still having problems with clipping when using some of the "Action" buttons to change the view orientation properly when clipping is active, unless I double up calls to SetProj like

void Qocc3dWidget::viewAxo()
{
     if( !myView.IsNull() )
     {
      myView->SetProj( V3d_XnegYnegZpos );
      myView->SetProj( V3d_XnegYnegZpos );
     }
}

which looks really stupid but works! I'd like to be able to stop the grid from clipping, but that looks like I need to unpick the OpenCASCADE source from the inside. I'm still looking at that one.

Pete
Brandt2008/02/10 17:53
Thank you very for the your fast help. Now the gradient background is not cut anymore.

But i still have two small problems. The triedron and the grid are still cut. Maybe the cut of the grid is good idea. But the triedron should be fully displayed.
P Dolbey2008/02/10 18:52
Actually, I am working on the tri(h)edron problem. I've already made various changes to the the zbuffer tri(h)edron code in TKOpenGL library, along with Fotis and various others. It might be nice to come up with a community agreed fix for the various problems with the tri(h)edra.

Anyway in principle the solution is the same as for paintOCC - cache and unset the clip planes while drawing the tri(h)edron and put them back at the end.

Grids are more difficult in that they are rendered as presentations, so do not have their own nice routine that can be patched in the same way. We may to live with this, or else develop our own new grid drawing routine implemented in a routine called from paintOCC - with clipping off!

Pete



Pete
P Dolbey2008/02/11 21:20
Does anyone know of a way to determine the location of the "near" clipping plane in OpenGL. And I don't mean the location of the viewing plane, as I've just discovered these are separate entities. I'm trying to move the triedron to just behind the near clipping plane so that it is always in view.

Alterative options are always gratefully received.

Pete
P Dolbey2008/02/12 04:29
I found another solution using a two-pass approach. The result of my hackings on the ZBUFFER triedron can now be found here - use at your own risk (or at least backup your original version).

http://qtocc.sourceforge.net/data/OpenGl_triedron.c

Basically this version fixes: -
The colors changing
The lights changing
Clip plane clipping

and
Its always in front of the geometry
Fotis's larger ball!

I've only tested this on win32, but its mostly pure opengl so should be OK on Unix-like OS's

Pete
Mathieu2010/03/04 18:12
Hello,

This thread is very interesting for me, thank you very much !

Your link above is now invalid. Can you tell me where can I found this patch please ? Thank you again !

Mathieu
Mathieu2010/03/05 13:07
Hello,

I'm using OpenCascade with Qt 4.4 and I'm having this problem : when I activate a cut plane, the gradient background is also cut.

I don't understand how to modify the void Qocc3dWidget::viewAxo() function because I don't use Qocc3dWidget.cpp file.

How can I solve my issue please ? I've patched Opencascade with the files given there : https://qtocc.svn.sourceforge.net/svnroot/qtocc/occ630/ros

Thank you for your help, I'm lost ! :)

Mathieu
 
 
Latest news
  • FAQ section updated
  • OPEN CASCADE Uses Intel ® Parallel Studio XE to Introduce Parallelism into SALOME SMESH Module
  • Open CASCADE Technology 6.5.2 is available for download!

  • © OPEN CASCADE 2000 - 2012  |  Search  |  Contacts   |  Site map