Ogre in CAD-program?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
kamelisko
Gnoblar
Posts: 13
Joined: Thu Jun 14, 2007 6:25 pm

Ogre in CAD-program?

Post by kamelisko »

Hi

I'm planning to design a little CAD-program for my own needs. Not planning to program it myself, i'm just designer.

Question is: Is OGRE capable to handle real-time editing of solids and meshes? Also some 2D-graphics is needed at the same time. Oh. And platform will be OsX of course.
Is it difficult to make some integrations with Core Image and the overcoming Core Animation-systems?

Have I understood it right that OGRE has nothing to do with OpenGL - it actually replaces it?
FlightOfHallu
Halfling
Posts: 72
Joined: Fri Jun 08, 2007 10:55 pm

yeah

Post by FlightOfHallu »

I'm interested in this also. Does Ogre 3D support Nurbs? I think I read some where that it supports Bezier patches. However I would think a CAD system will need nurbs.

I suppose you could always dig through the code and implement a frame work on top of Ogre utilizing OpenGL for nurbs. You could research this topic.

Or implement your own Nurbs system on top of Ogre.
User avatar
simply
Halfling
Posts: 45
Joined: Mon Jun 12, 2006 10:45 am
Location: Switzerland
Contact:

Re: Ogre in CAD-program?

Post by simply »

kamelisko wrote:Have I understood it right that OGRE has nothing to do with OpenGL - it actually replaces it?
Ogre uses either DirectX or OpenGL for rendering. So one can say it's built upon OpenGL!

So Ogre does just the rendering tasks for you. If you wish to alter geometry while your application runs, you can do so. In a game, geometry changes on runtime, too.

NURBS: I don't know anything about that topic, sorry!
User avatar
riri
Gnoblar
Posts: 10
Joined: Thu Jun 07, 2007 5:30 am
Location: Nantes, France

Re: Ogre in CAD-program?

Post by riri »

kamelisko wrote:Is OGRE capable to handle real-time editing of solids and meshes? Also some 2D-graphics is needed at the same time. Oh. And platform will be OsX of course.
For the first question, yes, but you'll have to code the mesh editing by yourself of course: as already mentionned, Ogre does just rendering (that's already a big task).

for the second question, I'm not sure to understand :-) Maybe searching for OgreMagic ?
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

Post by stoneCold »

As for nurbs, I already have the (yet vague) plan to bring Ogre and NURBS++ together (but ogreswf comes first :wink: ).
I actually came to the idea, after seeing the interesting capabilities of NURBS in realtime/games ---> NFS: Carbon.
I also think, that in times where procedural content generation (geometry/textures) NURBS could really be helpful in this manner.

:D
my tweets | www.fuse-software.com | home of vektrix (Flash GUI for Ogre3D) and caspin (ActionScript 3 Virtual Machine Wrapper)
kamelisko
Gnoblar
Posts: 13
Joined: Thu Jun 14, 2007 6:25 pm

Post by kamelisko »

Ok. Ogre is running above OpenGL. So what is actually the benefit of Ogre instead of using just OpenGL? Is OpenGL just a standard how to describe things? I'm little newbie in this level of things..

The main assertation of the real-time renderer is speed. It should be very fast even if there is much stuff visible. Nurbs is not the thing when speaking of CAD, because all objects must be in absolute sizes. What i have experiense of nurbs those are more like visualization only things.
User avatar
riri
Gnoblar
Posts: 10
Joined: Thu Jun 07, 2007 5:30 am
Location: Nantes, France

Post by riri »

kamelisko wrote:Ok. Ogre is running above OpenGL. So what is actually the benefit of Ogre instead of using just OpenGL? Is OpenGL just a standard how to describe things? I'm little newbie in this level of things..
First, Ogre wraps OpenGL and DirectX, so the two 3D implementations are available through one consistent API. It's almost useful for Windows platform where openGL drivers are not always well implemented.

Then, Ogre provides other interesting features, like the Unified shader scripts, resources management (this could be out of Ogre, but I guess the resource loading is optimized for the Ogre internal storage of polygons - again, I guess, I didn't verified).

That's the advantages I can explain from my newbee point of view ;-)
Entity *eMerlin;
Gnoblar
Posts: 10
Joined: Wed Jun 13, 2007 8:45 pm

Post by Entity *eMerlin; »

It can be done. I've written a custom module for Pro/Engineer, utilizing the Pro/TOOLKIT API, which exports "all" assembly information, including geometry, cosmetic features (such as text), mass properties etc, to a customized, highly compressed format (about 1-2% of the original size of the Pro/E model). I then wrote a "CAD" viewer using Ogre for this exported file. Some degree of manipulation is also possible, but no geometry is currently constructed/modeled through the interface. That would be the logical next step though.

To get some idea of how complex CAD modeling can be, I suggest downloading Open CASCADE (http://www.opencascade.org) and take a look at the source. All I can say is wow.
kamelisko
Gnoblar
Posts: 13
Joined: Thu Jun 14, 2007 6:25 pm

Post by kamelisko »

Entity *eMerlin; wrote:It can be done....

To get some idea of how complex CAD modeling can be, I suggest downloading Open CASCADE (http://www.opencascade.org) and take a look at the source. All I can say is wow.
Well I wasn't thinking so complex CAD-modeling. This CAD will be for building modeling. It doesn't need so complex objects like splines. More important is information beneath the model. At start if I just could do a wall.. :D (which is a simple box of a modeling point of view)

I tried to get those OSX examples work, but only one of them did. (The rotating head - with a little bug) I don't know what is wrong.
I also tried the Xcode example project but it didn't work either. Maybe I should learn using Xcode first...
Entity *eMerlin;
Gnoblar
Posts: 10
Joined: Wed Jun 13, 2007 8:45 pm

Post by Entity *eMerlin; »

Regarding a CAD/Ogre hybrid, one solution may be to write a simplified wrapper using Open CASCADE to do CAD stuff such as constructing primitives (only what you need), solid boolean operations, and tesselation. Then...take the triangular mesh returned from your Open CASCADE wrapper's solid tesselation routine, and then render this triangle list in Ogre, following essentially the same steps as that shown here: http://www.ogre3d.org/wiki/index.php/ManualSphereMeshes

See "Construction of Primitives" and "Boolean Operations" from the Open CASCADE:
http://www.opencascade.org/showroom/shapefactory

Overkill :?:
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

If it support real geometry (indices and vertices) it could be very useful. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Entity *eMerlin;
Gnoblar
Posts: 10
Joined: Wed Jun 13, 2007 8:45 pm

Post by Entity *eMerlin; »

A good example of how to obtain usable mesh info (after primitive construction, boolean operations), complete with vertices/indices from the resulting solid shape, can be found in the Open CASCADE source file StlTransfer.cxx found under the downloaded OpenCASCADE directory structure, under .\ros\src\StlTransfer:

Code: Select all

void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape&  Shape,
					const Standard_Real  Deflection,
					const Handle(StlMesh_Mesh)& Mesh)
The hypothetical wrapper may allow for calls similar to:

Code: Select all

OgreCascade::addSolid
OgreCascade::cutSolid
OgreCascade::getMesh
May seem like messin' with fire though.... :twisted: :!:
Entity *eMerlin;
Gnoblar
Posts: 10
Joined: Wed Jun 13, 2007 8:45 pm

Post by Entity *eMerlin; »

Does OgreOC sound better?

The OC code from above for creating a mesh (not that different than Ogre::Mesh) once you have the resultant solid Shape:

Code: Select all

void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape&  Shape,
					const Standard_Real  Deflection,
					const Handle(StlMesh_Mesh)& Mesh)
{
  if (Deflection <= Precision::Confusion ()) {
    Standard_ConstructionError::Raise ("StlTransfer::BuildIncrementalMesh");
    }
  
  Standard_Integer NbVertices, NbTriangles;
  BRepMesh::Mesh (Shape, Deflection);
  for (TopExp_Explorer itf(Shape,TopAbs_FACE); itf.More(); itf.Next()) {
    TopoDS_Face face = TopoDS::Face(itf.Current());
    TopLoc_Location Loc, loc;
    Handle(Poly_Triangulation) theTriangulation = BRep_Tool::Triangulation(face, Loc);
    if (theTriangulation.IsNull()) continue; //Meshing was not done for this face!
    Poly_Array1OfTriangle theTriangles(1,theTriangulation->NbTriangles());
    theTriangles.Assign(theTriangulation->Triangles());
    Mesh->AddDomain (Deflection);
    
#ifdef DEB
    TopAbs_Orientation orientation = 
#endif
      face.Orientation();
    
    TColgp_Array1OfPnt thePoints(1, theTriangulation->NbNodes());
    thePoints.Assign(theTriangulation->Nodes());
    //compute normal of face
    const TColgp_Array1OfPnt& Nodes = theTriangulation->Nodes();
    TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
    Poly_Connect pc(theTriangulation);
    Normal(face, pc, NORMAL);
    Standard_Integer i;
    for(i=1;i<=thePoints.Length();i++) {
      Standard_Real X1, Y1, Z1;
      gp_Pnt p = thePoints.Value(i);
      p.Transform(Loc.Transformation());
      p.Coord (X1, Y1, Z1);
      NbVertices = Mesh->AddVertex (X1, Y1, Z1);
    }
    try {
      for (i=1;i<=theTriangles.Length();i++) {
	Standard_Integer V1, V2, V3;
	Poly_Triangle triangle = theTriangles.Value(i);
	triangle.Get(V1, V2, V3);
	gp_Pnt P1, P2, P3;
	P1 = Mesh->Vertices(Mesh->NbDomains()).Value(V1);
	P2 = Mesh->Vertices(Mesh->NbDomains()).Value(V2);
	P3 = Mesh->Vertices(Mesh->NbDomains()).Value(V3);
	gp_Vec average = NORMAL(V1);;   
	
	//check angle between vectors
	gp_Vec V1V2(P1, P2), V2V3(P2, P3);
	Standard_Integer A,B,C;
	gp_Vec vec = V1V2^V2V3;
	Standard_Real modul1, modul2;
	modul1 = average.XYZ().Modulus();
	modul2 = vec.XYZ().Modulus();
	if (modul2>Precision::Confusion ()) vec.Divide(modul2);
	A=V1;B=V2;C=V3;
	//	vec.Transform(loc);
	if (modul1>Precision::Confusion () && modul2>Precision::Confusion ()) {
	  Standard_Real an = vec.Angle(average);
	  if ( an > PI/2)  {
	    A = V3;B=V2;C=V1;
	  }
	  else {
	    A=V1;B=V2;C=V3;
	  }
	}
	NbTriangles = Mesh->AddTriangle (A, B, C, average.X(), average.Y(), average.Z());
      }
    }
    catch(Standard_Failure)
      {
#ifdef DEB
	cout << "Fail in StlTransfer::BuildIncrementalMesh"   << endl;
#endif
      }
  }
}
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

Post by SpaceDude »

You may want to have a look at the Visualization Toolkit Library (VTK) which may be more suitable for CAD work than Ogre is (it has good support for 2D graphics as well as 3D):

http://www.vtk.org/

It is specifically aimed at scientific applications. I must warn you however that the documentation is very lacking. Although the library is open source, they seem to make profit by selling books describing how to use the thing. I have just about managed to get by without the books but it hasn't been a pleasurable experience.

Ogre on the other hand has great documentation, and if you ever run into trouble the people on this forum are generally very helpful.
kamelisko
Gnoblar
Posts: 13
Joined: Thu Jun 14, 2007 6:25 pm

Post by kamelisko »

SpaceDude wrote:You may want to have a look at the Visualization Toolkit Library (VTK) which may be more suitable for CAD work than Ogre is (it has good support for 2D graphics as well as 3D):

http://www.vtk.org/
...
i checked that out. There was one big thing that doesn't match to my idea:
What's UnCool About VTK
Not a super-fast graphics engine...VTK uses C++ dynamic binding and a device independent graphics model.
My idea is really to be super-fast. Even if we're talking of CAD why shouldn't it use real-time intelligent optimization to view things smoothly?

One thing I haven't asked is that does Ogre have possibility to have paraller view and change it to perspective view on-the-fly?

Maybe my first step is to get the OGRE work and test it a little altough I'm not a programmer..
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

kamelisko wrote: One thing I haven't asked is that does Ogre have possibility to have paraller view and change it to perspective view on-the-fly?
Yes.
Maybe my first step is to get the OGRE work and test it a little altough I'm not a programmer..
Yes.

Creating a CAD tool is also going to be rather tough if you aren't a programmer.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

Post by SpaceDude »

Programming in general is hard if you are not a programmer :twisted:
kamelisko
Gnoblar
Posts: 13
Joined: Thu Jun 14, 2007 6:25 pm

Post by kamelisko »

SpaceDude wrote:Programming in general is hard if you are not a programmer :twisted:
Yeah! That's why i'm planning to leave the actual programming to someone else! :P
I'm just a visionare and designer... And I just "know" how things should look and feel like..
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

SpaceDude wrote:Programming in general is hard if you are not a programmer :twisted:
It's even harder if you are one.. Just on a different level, that's all.. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Evak
Orc Shaman
Posts: 707
Joined: Sun Apr 02, 2006 7:51 pm
Location: Sacramento, CA
x 1
Contact:

Post by Evak »

Well good luck, it's all well and good having ideas and vision. You don't have to be a programmer to come up with a good design so long as you have done good research and have plenty of hands on experience with render engines, how they work, the limitations and how you overcome them.

Otherwise you really can't conceptualize a product, then communicate in realistic terms things your programmers can understand and make real. You will need a competent programmer to pull off some of the basic things you require.
Post Reply