Three.js ported to native code? - c++

I've been playing with WebGL quite a bit lately and I really dig Three.js. It's really lightweight and just serves as something that makes wrangling most of the GL calls a bit easier, and provides a quick way of creating basic primatives like a sphere.
Now, in native land, it seems that all the frameworks want to be so much more than that. Things like Oolong, UDK, Unity, Cocos, etc. I did a bit of googling, and the closest thing I could find was iSGL3D but I'm not thoroughly convinced it is the right answer.
Is there something more similar to Three.js that is written in native C, C++ or Objective-C that I can't find?

Here is a port of three to C++: https://github.com/jdduke/three_cpp
Core - 75% complete (TODO: Morph targets, shadows, plugin support)
Extras - 5-10% complete (TODO: Pretty much everything)
Examples - 25% complete (TODO: Examples involving morph targets an)

You're asking for a strict graphics engine only, in the same direction as OpenGL (in comparison to DirectX which again wants to be so much more than that). I'd advise Ogre3D for iPhone as the philosophy behind Ogre3d is to be a strict graphics engine.
The other one that comes to mind is recently perused MoSync mobile sdk which offers excellent OpenGL support across a wide range of platforms (albeit limited; to maintain portability).
If you're more interested in loading shaders and having the graphics engine manage the rest, I'd pick Ogre3D for iPhone.
You can always take the initiative (if you have the time of course) to write your own or start off from the ones mentioned here!
Or you can use a JavaScript engine (JSAPI for example) in a C++ editor and then move three.js on top of that. This is great as you'll only update the JSAPI and Three.js without breaking functionalities and your C++/JSThree engine will stay up to date with minimal maintenance.
Just some ideas of course!

Although I would also prefer to see a port of three.js for iOS, recently stumbled up on iSGL3d (http://isgl3d.com/).
This project serves a simple, encapsuled way to build an manipulate an opengl scene graph by code. Otherwise than some creative coding frameworks like cinder, iSGL3d comes in pure Objective C.
Works well for me yet.

You could also give Ejecta a go. They just added WebGL/three.js support.
https://github.com/phoboslab/Ejecta/tree/next

Three_cpp is good, but has stopped updating since 3 years ago. It does not support VS version below 2012.
Ogre is another good choice, which is much similar to the logic of Threejs:)
And the official site provides a very detailed tutorial, making it easy to use!

After some more searching I found a stripped down version of SIO2 called GFX that looks promising.

If you're looking for strictly ease-of-use, I'd highly recommend Panda3D. It's cross-platform (Windows, Unix, Mac), really easy to use, has extensive documentation, and a nice community around it.

Related

3D and UI toolkit

I have to develop a basic inventory system, and my client wants to see all the objects in the inventory in 3D and their positions in the warehouse. The thing is that I have to develop this as soon as possible, delivery time is my priority here. So I came to the conclusion that I would need a powerful 3D graphics engine and an UI toolkit that can be easily integrated with it. I've plenty of experience with C++, Qt, OpenGL, VTK, C# and WinForms. In my experience, VTK is not so good with textures and it would involve more work to add the eye candy my client wants (like animations, visual effects, etc). I've tried Axiom with WinForms. I went through hell making a sample load and run (framework incompatibilities, rendering engines not found, codec native dependencies missing, etc).
I have been evaluating different options:
Qt + Ogre (C++)
WinForms + Axiom (.NET)
Qt + Irrlicht (C++)
Which do you think would be the best option? Could you recommend me some other possibility?
Thanks in advance!
I spent a heap of time developing with Mogre (a C# wrapper around Ogre) and WinForms. In my opinion it's a good combination because you can develop the GUI much faster in C# WinForms than any of the C++ options.
If you don't mind using a C# wrapper around the C++ Ogre library I recommend using Mogre rather than Axiom. It is very stable, has some good maintainers and keeps up with the latest version of Ogre pretty well. Any code on the Ogre forums can easily be ported to C# because most of the API is identical.
Axiom is a pure .NET port of Ogre, although it lags a few versions behind and may have some missing features. I haven't spent a lot of time with it but I believe it's main strength is that it's all managed code, if that's important to you.
There's an open source project called Glue Editor that I started a while ago. It's no longer maintained but it has a lot of code you can use to get Mogre working with WinForms. You should be able to download the repository and compile it out of the box. You're welcome to take the code and use it however you like.
https://bitbucket.org/glue/glueeditor/src
If you decide to go down the Qt + Ogre path there's a project called Ogitor you might want to check out.
https://bitbucket.org/jacmoe/ogitor/src
You might also want to check out XNA and MonoGame. XNA is Microsofts framework for making games in C#. It is fairly bare bones but it has a much lower learning curve than Ogre, Mogre or Axiom. MonoGame is an open source implementation of the XNA framework that works on non-Microsoft platforms (e.g. Android, iOS, Linux).
http://monogame.codeplex.com/
I recommend Qt + Ogre (C++), although I have to confess this is the only combination from your list I have much experience with. The good thing about Ogre is the amount of documentation and the active community. So many questions are answered and documented. The graphics itself can probably be created in all library combinations. However, I like the easy intergration of object interaction in Ogre. The standard is based on bounding boxes, however there is code available for triangle intersection as well. Wish you luck!

html5 d3d application menus/hud

I'm looking to use html5/css/js for the menu system and hud of a C++ d3d application. Ideally I'd like a 64bit MSVC10 library that I can statically link to.
So far I'm looking at:
Berkelium
chromiumembedded
QtWebKit
Awesomium
Before I commit alot of time I'd like to understand the which library would be the best for my purposes (not just from the list above). Could I use WebKit directly? Or chromium?
Even though this concept seems to be catching on right now I can hardly find a single example showing how to do it or collating relevant information.
You may also look at GUI toolkits that embed/integrate/have plugins for your listed HTML renderers (MyGUI comes to mind, with Berkelium/Awesomium integration).
Berkelium or Awesomium in general are probably a good bet, they're rather widely used for embedding Webkit and will work well. Berkelium is somewhat newer, and may have a few less features, but documentation tends to be better.
Of note is the long history Awesomium's developers have of flip-flopping licenses and suddenly trying to get money out of users (they've had free licenses before, which then were retconned into a pay-when-you-release), so that should be taken into careful consideration before touching it.
I'm not familiar with chromiumembedded and Qt has gone heavily OpenGL, severely damaging its value in graphics apps in general and likely making it useless to you.

Rudimentary 3D graphics in C++ .NET

I am looking to implement an extremely rudimentary FPS game with extremely rudimentary 3D graphics using C++ .NET and DirectX.
I'm not interested in any third party libraries or anything special like that.
Having never done graphics based programming besides 2D stuff I don't really know where to get started or even how to find the right resources online.
I have a few weeks to build this game so im trying to keep it simple.
Can anyone give me a little guidance on how to get started?
This looks as though it may give you a push in the right direction:
http://zophusx.byethost11.com/tutorial.php?lan=dx9&num=0
I always found that OpenGL was easier to learn though. So unless it's necessary for you to use DirectX, I'd suggest you have a quick look at GL and see what you think.
If you download DirectX SDK you can find plenty of samples there in C++ and C#.
May I recommend "Introduction to Game Programming in DirectX 9" by "Wordware" Publishing. I know you just want something very simple like the rotating cube classic, so do not be put off by the 'game' element. I got 3/4 the way through and wrote a screen saver! DX10 is now available but I stick to 9 - card backward compatibility.
The maths can get silly in 3D, but if you can get the basics, the rest will follow very quickly.
If you haven't done so already the "DirectX SDK" download is also a must - it contains (most important) the help files for the methods, functions etc. and a few not so helpful getting started stuff.
You might want to have a look at SlimDX, even if you're not interested in third-party libraries.
Although I don't have Visual C++ 2008/2010 Express installed, you could add SlimDX as a reference to your project. Be sure you check out the tutorial section, even though it's in C#, but if you know C++/CLI pretty well, you should be able to convert the code to C++/CLI.

What is the best approach to use openGL in the web?

I wrote a program in C++/OpenGL (using Dev-C++ compiler) for my calculus 2 class. The teacher liked the program and he requested me to somehow put it online so that instead of downloading the .exe I can just run it on the web browser. Kinda like java applets run on the browser.
The question is:
How if possible, can I display a C++/OpenGL program in a web browser?
I am thinking of moving to JOGL which is a java interpretation of OpenGL but I rather stay in C++ since I am more familiar with it.
Also is there any other better and easier 3D web base API that I can consider?
There is a lot activity recently with WebGL. It is a binding for Javascript to native OpenGL ES 2.0 implementations, designed as an extension of the canvas HTML5 element.
It is supported by the nightly builds of Firefox, Safari, Chrome and Opera.
Have a look at these tutorials, based on the well known NeHe OpenGL tutorials.
Several projects based on WebGL are emerging, most notably Scenegraphs APIs.
From Indie teams: SceneJS, GLGE, SpiderGL.
From Google: the team behind O3D plugin is trying to implement a pure WebGL backend (source) for the project, so that no plugin will be necessary.
From W3C/Web3D: There is an ongoing discussion to include X3D as part of any HTML5 DOM tree, much like SVG in HTML4. The X3DOM project was born last year to support this idea. Now it is using WebGL as its render backend, and is version 1.0 since March 2010.
I'm almost sure that WebGL is the way to go in the near future. Mozilla/Google/Apple/Opera are promoting it, and if the technology works and there is sufficient customer/developer demand, maybe Microsoft will implement it on IE (let's hope that there will be no "WebDX"!).
AFAIK, there's only 3 options:
Java. it includes the whole OpenGL stack.
Google's Native Client (NaCL), essentially it's a plugin that let's you run executable x86 code. Just compile it and call it from HTML. Highly experimental, and nobody will have it already installed. Not sure if it gives you access to OpenGL libraries.
Canvas:3D. Another very experimental project. This is an accelerated 3D API accessible from JavaScript. AFAICT, it's only on experimental builds of Firefox.
I'd go for Java, if at all.
OTOH, if it's mostly vectorial works (without lots of textures and illumination/shadows), you might make it work on SVG simply by projecting your vectors from 3D to 2D. In that case, you can achieve cross-browser compatibility using SVGWeb, it's a simple JavaScript library that allows you to transparently use either the browser's native SVG support or a Flash-based SVG renderer.
Do you really have the time to rewrite it? I thought students were meant to be too busy for non-essential assignment work.
But if you really want to do it, perhaps a preview of it running as a flash movie is the easiest way. Then it's just a matter of doing that and you could provide a download link to the real application if people are interested.
Outside of Java, in-browser OpenGL is really in its infancy. Google's launched a really cool API and plugin for it though. It's called O3D:
http://code.google.com/apis/o3d/
Article about the overall initiative:
http://www.macworld.com/article/142079/2009/08/webgl.html
It's not OpenGL, but the Web3D Consortium's X3D specification may be of interest.
Another solution is to use Emscripten (a source-to-source compiler).
Emscripten supports C/C++ and OpenGL and will translate the source into html/JavaScript.
To use Emscripten you will need to use SDL as a platform abstraction layer (for getting an OpenGL context as well as loading images).
Emscripten is currently being used in Unreal Engine and will also be used in the Unity 5 engine.
Read more about the project here:
https://github.com/kripken/emscripten
Two approaches:
Switch to Java. However, your application will suffer from a loss of performance as a trade off for portability. But since Java is everywhere, this approach ensures that your code can be executed in most browsers.
Use ActiveX, which allows you to run native binary code for Microsoft Windows. This is not recommended in production because activeX is well known as a potential security hole, but since your lecturer is the one viewing it, security doesn't seem to be a big deal. This is applicable for Microsoft platform (Windows+IE) only.

Open Source sound engine

When I started using SoundEngine (from CrashLanding and TouchFighter), I had read about a few people recommending not to use it, for it was, according to them, not stable enough. Still it was the only solution I knew of to play sounds with pitch and position control without learning C++ and OpenAL, so I ignored the warnings and went on with it.
But now I'm starting to worry. The 2.2 SDK introduced AVFoundation. Using both SoundEngine from CrashLanding (for sounds) and AVAudioPlayer (for music), I found out SoundEngine behaves strangely when the only existing AVAudioPlayer is released (all sounds stop until a new AVAudioPlayer is initiated). Around the same time as the 2.2 SDK came out, the CrashLanding sample code was mysteriously removed from the ADC site. I'm worried there are more bad surprises to come.
My question is, is anyone aware of an Open Source alternative to SoundEngine? Maybe even a C++ library that uses OpenAL?
Look at this library, but i don't know is this what you need.
The Kowalski project provides a data driven and portable sound engine that currently runs on iOS, OS X and Windows. The engine is released under the zlib license and provides positional audio, pitch control etc.
ObjectAL for iPhone
Clone it. Use it. Love it. Enjoy the freedom.
Why not just use AVFoundation? It's pretty simple to handle and nicely flexible - apart from if you need exact timing (says the Apple documentation - but I've been testing it fairly extensively and yet to find any significant practical issues) I don't see any reason for not leveraging it.
AVFoundation lacks sound placement. This makes me sad.
I’ve written a simple sound engine around OpenAL. There are no position controls (I didn’t need them), but they would be trivial to add if you find the rest to your liking. And there is also some experimental sound code in the Cocos2D engine. It has both pitch and position controls and looks quite usable.