Ogre in CAD-program?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.

Ogre in CAD-program?

Postby kamelisko » Thu Jun 14, 2007 6:50 pm

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?
kamelisko
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 Jun 2007

yeah

Postby FlightOfHallu » Thu Jun 14, 2007 10:21 pm

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.
FlightOfHallu
Halfling
 
Posts: 72
Kudos: 0
Joined: 08 Jun 2007

Re: Ogre in CAD-program?

Postby simply » Thu Jun 14, 2007 10:30 pm

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
simply
Halfling
 
Posts: 45
Kudos: 0
Joined: 12 Jun 2006
Location: Switzerland

Re: Ogre in CAD-program?

Postby riri » Thu Jun 14, 2007 10:48 pm

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
riri
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 07 Jun 2007
Location: Nantes, France

Postby stoneCold » Thu Jun 14, 2007 11:31 pm

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)
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
 
Posts: 867
Kudos: 0
Joined: 01 Oct 2004
Location: Carinthia, Austria

Postby kamelisko » Sat Jun 16, 2007 7:56 pm

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.
kamelisko
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 Jun 2007

Postby riri » Sun Jun 17, 2007 7:41 am

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 ;-)
User avatar
riri
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 07 Jun 2007
Location: Nantes, France

Postby Entity *eMerlin; » Tue Jun 19, 2007 6:13 pm

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.
Entity *eMerlin;
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 13 Jun 2007

Postby kamelisko » Wed Jun 20, 2007 7:38 am

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...
kamelisko
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 Jun 2007

Postby Entity *eMerlin; » Wed Jun 20, 2007 7:19 pm

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 :?:
Entity *eMerlin;
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 13 Jun 2007

Postby jacmoe » Wed Jun 20, 2007 10:27 pm

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.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Postby Entity *eMerlin; » Wed Jun 20, 2007 11:16 pm

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
Kudos: 0
Joined: 13 Jun 2007

Postby Entity *eMerlin; » Thu Jun 21, 2007 3:10 pm

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
      }
  }
}
Entity *eMerlin;
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 13 Jun 2007

Postby SpaceDude » Thu Jun 21, 2007 10:50 pm

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.
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
 
Posts: 822
Kudos: 3
Joined: 02 Feb 2006
Location: Nottingham, UK

Postby kamelisko » Tue Jun 26, 2007 7:12 pm

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..
kamelisko
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 Jun 2007

Postby xavier » Tue Jun 26, 2007 7:19 pm

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
xavier
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 9481
Kudos: 23
Joined: 18 Feb 2005
Location: Dublin, CA, US

Postby SpaceDude » Tue Jun 26, 2007 9:50 pm

Programming in general is hard if you are not a programmer :twisted:
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
 
Posts: 822
Kudos: 3
Joined: 02 Feb 2006
Location: Nottingham, UK

Postby kamelisko » Tue Jun 26, 2007 9:58 pm

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..
kamelisko
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 Jun 2007

Postby jacmoe » Tue Jun 26, 2007 10:03 pm

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
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Postby Evak » Tue Jun 26, 2007 11:59 pm

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.
User avatar
Evak
Orc Shaman
 
Posts: 707
Kudos: 1
Joined: 02 Apr 2006
Location: Sacramento, CA


Return to Using OGRE in practice

Who is online

Users browsing this forum: No registered users and 0 guests