mhonda's picture

Porting C++ CAD system to OpenTK

I created a small CAD system on MS Windows (using C++/MFC) using OpenGL for rendering. Now I am interested in transforming this to C# DOT.NET platform. And I am looking at Open TK to achieve that. I am still new to C# but it appears very similar to C++. I am also looking into Sliverlight (for .NET) ... I am still trying to figure out how these technologies (ASP.NET, C#, DOT.NET MVC. Silverlight, OpenGL) can be integrated together. My CAD system is based on MFC's Document/View architecture (MDI-Multiple Document Interface). I do not mind reducing it to SDI (Single-Document) for web performance. My CAD is documented in my web site: www.iNet1000.com.

M


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

The direct equivalent to C++/MFC/OpenGL is C#/WinForms/OpenGL (using OpenTK.GLControl).

My advice would be to separate the core logic from the presentation as far as possible. This way, you can create a version for the desktop (using WinForms) and one for the web (using Silverlight), without rewriting everything from scratch.

ASP.Net is something entirely different: it is a web application framework that runs on a web server (whereas WinForms run on the desktop and Silverlight is a browser plugin similar to Flash).

mhonda's picture

Hi Fiddler,
Thank you for the advice.

When I say I'd like to port my current C++/MFC based CAD (www.iNet1000.com), I do not mean to rewrite my C++ code to C# just for the sake of rewriting in C#. I am specifically interested in creating a Web-based CAD system. Among various languages the DOT.NET platform supports, my natural choice is C#. That's why I need an OpenGL replacement (or wrapper) like OpenTK for rendering.

A Web-application is distinct from a desk-top application in two aspects: UI and its client-server architecture. As for UI, it seems like there is a good support for Rich Internet Application (RIA) such as Windows Presentation Foundation (WPF) and Silverlight. But I got somewhat confused.... I thought Silverlight is just a delivery mechanism of WPF, which is basically an UI entity. I do not know why it is mentioned in the context of, or compared to, say, Adobe's FLASH.

Is Silverlight more than just a "3D" UI presentation mechanism? Can it extend to do any graphical rendering, in the same sense as OpenGL is doing? Well, I guess it can render vector graphics, as in GDI, but certainly not 3D shading or anything comparable. It is the same as in MFC. That's why we need OpenGL for 3D rendering, I guess.

I studied Flash and Action Script 3.0. AC 3.0 seems to support Z-buffering, but only at object level. That means if 2 boxes intersects, only one is shown. I also studied Papervision3D which is a 3D class library on the Flash platform. This may take the place of OpenGL.... eventually.

Coming back to the basics of a Web-based CAD system, I must support a client-server model, which is entirely different software architecture than my current desktop CAD system.

To sum up, I will be very happy if I can come up with a very, very small, Web-based CAD system having the following features:

1. User goes to this CAD web site. The desktop shows two buttons, A and B.
2. Click button A and the user is in Line Creation mode.
3. Click the screen and a point is created (this is a 3D point). Click again and another point created, and so on. END it (the End key) and a multi-segmented line has been created.
4. Do the same and another multi-line is created on the screen.
5. These lines must persist (probably on the client PC) so, tomorrow, the user can continue where he left off.
6. The user can view these 3D lines from a different angle by moving the view camera using the mouse move (real-time).
7. Now, click the button B. This puts the user in Change Line mode.
8. Click an existing line ("hit test" needed) and one last segment of the line selected will be deleted, one segment per click, until there is only one segment left of the line.
9. This B process has to be done on the SERVER side.
10. Line modifications by button B must persist also. That is, the model has been changed.

That's all.

the Fiddler's picture

OpenTK is meant for desktop (and mobile) applications rather than web apps (think Google Earth rather than Google Maps). Some people have used it for server-side rendering but I don't know of anyone using inside a browser.

Silverlight has some 3d capabilities but I do not know if they are powerful enough for what you wish to do. Certainly worth a look.

Two other solutions I can think of:

  • Use the new WebGL standard to deliver 3d content to the client (the server can be implemented in whichever language). All next-generation browsers will support WebGL, with the possible exception of Internet Explorer (which might require a 3rd-party plugin).
  • Use the Unity3d browser plugin. This is scriptable through C# but the downside is that the client will need to install a plugin.