how to export object from maya into opengl application - object

Im learning openGL, basically ive created an object in Maya, im wondering how i go about exporting it, and loading it into my application ive created (it is simply a plain square room with different coloured walls at the moment.

OpenGL doesn't have the concept of models. You'll have to write your own model loader, or use one that's already out there. If you opt for writing your own, you should probably export as .obj, that's a fairly simple text based format.

Related

Move desktop game to web

I developed simple game using C#, Windows Forms and graphics library SFML.
Fire Tank Game
The game goal is to develop algorithm that performs by tanks (moving, shooting, etc) to extinguish the fire on the map.
This game can draw some kind of simple graphics, works with XML (to draw map, that opens from .xml file), has simple GUI (menu, combobox, datagridview, buttons, labels), uses API (Entity Framework) to query some data from small DB in SQL Server.
Now I would like try to turn it into web. So I need help with what languages (python, php, javascript?) and libraries I should use to develop the same game in web. In total necessary features:
Draw graphics.
Draw GUI.
Work with DB (Also, I would like to move data into some cloud DB, e.g. Azure).
Work with XML.
Also, I implemented simple "sign in/up" logic. Is there any library that registers user and adds him to the DB? So, fifth featureis:
Sign in/up feature.
Last, game uses inconvenient way to develop algorithms (users need to choose items of algorithm from combobox). Is there some library that allows to do it with "drag & drop" way?
Drag & drop items to the table (datagridview).
Aside of Unity, as suggested, I can recommend you a Javascript library called p5.
I worked with both, sfml and p5 and, saving the distances, they are pretty similar.
You can draw 2D stuff (circles, lines, rectangles, etc) with it.
It also contains GUI components to work with (buttons, sliders, etc).
If you want a web environment, you surely will have/need a server side, probably based on PHP to access database. Alternatively, you can use a JS database library, if your system is simple enough.
You can read XML files with JS but you would probably prefer to use JSON files.
Maybe this can cover your basic needs.
There are two good options:
A: Convert it: https://bridge.net/
B: Unity, as 3Dave stated

3ds Max and Python

I know that it is possible to create 3D objects and enviroments in python via using Pygame. But I wonder, if it is somehow possible to use the objects that you've created in 3ds Max within a python program. Because it seems that it takes a lot of time to code every detail in pygame to create 3D stuff.I think it would be easier if I could just use my mouse to draw objects just like in 3ds Max then to code every detail.Sorry if there are any gramattical mistakes.
3D is a world in itself - Pygame leverages 3D by providing some bindings to OpenGL - which are themselves quite low level.
So, if you happen to findout a format that can be expoted by 3DS and canbe supported directly in a call to OpenGL, the answer to your question would be "yes".
But I doubt so - even if there are object formats directly usable by OpenGL, you'd still have a tough time configuring the remainder of the scene.
The advice for you is to use a highr level binding to OpenGL, or 3D, and then check what formats are common between your binding (like Python-Ogre) and the formats 3DS can export too.
My personal recommendation would be for you to use Blender 3D for your Python environment. Not only it embeds a full game engine 100% programable in Python, as it leverages tens of different file formats to import - and certainly will be hundreds of times (no exaggeration here - I mean more than one hundred times as easy as) to code something like a finished game scene than using the raw OpenGL provided by Pygame. Also, as you get used to Blender, you might start making part of your modeling in it as well, avoiding having to switch environments between Max and Blender.

How can I create a 3D model file from geometric shapes?

I am writing a program that will output 3D model files based on simple geometric shapes (e. g. rectangular prisms & cylinders) with known coordinates in 3-dimensional space. As an example, imagine creating a 3D model of stonehenge. this question suggests that OBJ files are the easiest to generate, but I'm struggling to find a good tutorial or easy-to-use library for doing so.
Can anyone either
(1) describe step-by-step how to create a simple file OR
(2) point me to a tutorial that describes how to do so
Notes:
* Using a GUI-based program to draw such files is not an option for me
* I have no prior experience with 3D modeling
* Other formats such as WRL or DAE would work for me as well
EDIT:
I do not need to use textures, just combinations of simple geometric shapes positioned in 3D space.
I strongly recommend to use some ASCII exchange format there are many out there I usually use these:
*.x DirectX object (it is a C++ source code)
this one is easiest to implement !!! But there are not many tools that can handle them. If you do not want to spend too much time coding then this is the right choice. Just copy the templates (at the start) from any *.x file to get started.
here some specs
*.iges common and importable on most CAD/CAM platform (Catia included)
this one is a bit complicated but for export purposes it is not that bad. It supports Volume operation like +,-,&,^ which are VERY HARD to implement properly but you do not have to use them :)
*.dxf AutoCAD exchange format
this one is even more complicated then IGES. I do not recommend to use it
*.ac AC3D
I first saw this one in flight gear.
here some specs
at first look it is quite easy but the sub-object implementation is really tricky. Unless you use it you should be fine.
This approach is easily verifiable in note pad or by loading to some 3D model viewer. Chose one that is most suitable for your needs and code save/load function to your Apps internal model class/struct. This way you will be compatible with other software and eliminate incompatibility problems which are native to creating 'almost known' binary formats like 3ds,...
In your case I would use IGES (Initial Graphics Exchange Specification)
For export you do not need to implement all just few basic shapes so it would not be too difficult. I code importers which are much much more complicated. Mine IGES loader class is about 30KB of C++ source code look here for more info
You did not provide any info about your 3D mesh model structure and capabilities
like what primitives you use, are your object simple or in skeleton hierarchy, are you using textures, and more ... so it is impossible to answer
Anyway export often looks like this:
create header and structure of target file format
if the format has any directory structure fill it and write it (IGES)
for sub-objects do not forget to add transformation matrices ...
write the chunks you need (points list, faces list, normals, ...)
With ASCII formats you can do this inside String variable so you can easily insert into or modify. Do all thing in memory and write the whole thing to file at the end which is fast and also add capability to work with memory instead of files. This is handy if you want to pack many files to single package file like *.pak or send/receive files through IPC or LAN ...
[Edit1] more about IGES
fileformat specs
I learned IGES from this pdf ... Have no clue where from I got it but this was first valid link I found in google today. I am sure there is some non registration link out there too. It is about 13.7 MB and original name IGES5-3_forDownload.pdf.
win32 viewer
this is free IGES viewer. I do not like the interface and handling but it works. It is necessary to have functional viewer for testing yours ...
examples
here are many tutorial files for many entities there are 3 sub-links (igs,peek,gif) where you can see example file in more ways for better understanding.
exporting to IGES
you did not provide any info about your 3D mesh internal structure so I can not help with export. There are many ways to export the same way so pick one that is closest to your App 3D mesh representation. For example you can use:
point cloud
rotation surfaces
rectangle (QUAD) surfaces
border lines representation (non solid)
trim surface and many more ...

Exporting mtl files from 3ds max problem

I'm having a small problem with exporting mtl files in 3ds max. I would like to use an obj + its material library in an opengl program. The model gets exported just fine, but I loose all the reflective/refractive parameters of my materials when I export them (colors and such seem to be fine so it finds them just not completely but all materials get changed to standard). I tried exporting materials from the scene and from the mat. library aswell with the same results. Could anyone help me how to keep the reflective parameters of materials after exporting?
As you stated in the email you use Glut as API. there are several tutorials for this,
I initially thought you used a engine, and just needed some values.
But you needed more then this.
To use reflection \ environment mapping in opengl you need a shader that supports this.
So what you need to do is to implement a reflection shader, and pass the bitmap into your shader.
In the sample file it worked fine for rendered image (because 3dsmax supports it's own raytrace materials), but this does not get exported in any way.

Fast, Pixel Precision 2D Drawing API for Graphics App?

I woud like to create a cross-platform drawing program. The one requirement for writing my app is that I have pixel level precision over the canvas. For instance, I want to write my own line drawing algorithm rather than rely on someone elses. I do not want any form of anti-aliasing (again, pixel level control is required.) I would like the users interactions on the screen to be quick and responsive (pending my ability to write fast algorithms.)
Ideally, I would like to write this in Python, or perhaps Java as a second choice. The ability to easily make the final app cross-platform is a must. I will submit to different API's on different OS'es if necessary as long as I can write an abstraction layer around them. Any ideas?
addendum: I need the ability to draw on-screen. Drawing out to a file I've got figured out.
I just this week put together some slides and demo code for doing 2d graphics using OpenGL from python using the library pyglet. Here's a representative post: Pyglet week 2, better vertex throughput (or 3D stuff using the same basic ideas)
It is very fast (relatively speaking, for python) I have managed to get around 1,000 independently positioned and oriented objects moving around the screen, each with about 50 vertices.
It is very portable, all the code I have written in this environment works on windows and Linux and mac (and even obscure environments like Pypy) without me ever having to think about it.
Some of these posts are very old, with broken links between them. You should be able to find all the relevant posts using the 'graphics' tag.
The Pyglet library for Python might suit your needs. It lets you use OpenGL, a cross-platform graphics API. You can disable anti-aliasing and capture regions of the screen to a buffer or a file. In addition, you can use its event handling, resource loading, and image manipulation systems. You can probably also tie it into PIL (Python Image Library), and definitely Cairo, a popular cross-platform vector graphics library.
I mention Pyglet instead of pure PyOpenGL because Pyglet handles a lot of ugly OpenGL stuff transparently with no effort on your part.
A friend and I are currently working on a drawing program using Pyglet. There are a few quirks - for example, OpenGL is always double buffered on OS X, so we have to draw everything twice, once for the current frame and again for the other frame, since they are flipped whenever the display refreshes. You can look at our current progress in this subversion repository. (Splatterboard.py in trunk is the file you'll want to run.) If you're not up on using svn, I would be happy to email you a .zip of the latest source. Feel free to steal code if you look into it.
If language choice is open, a Flash file created with Haxe might have a place. Haxe is free, and a full, dynamic programming language. Then there's the related Neko, a virtual machine (like Java's, Ruby's, Parrot...) to run on Mac, Windows and Linux. Being in some ways a new improved form of Flash, naturally it can draw stuff. http://haxe.org/
QT's Canvas an QPainter are very good for this job if you'd like to use C++. and it is cross platform.
There is a python binding for QT but I've never used it.
As for Java, using SWT, pixel level manipulation of a canvas is somewhat difficult and slow so I would not recommend it. On the other hand Swing's Canvas is pretty good and responsive. I've never used the AWT option but you probably don't want to go there.
I would recommend wxPython
It's beautifully cross platform and you can get per pixel control and if you change your mind about that you can use it with libraries such as pyglet or agg.
You can find some useful examples for just what you are trying to do in the docs and demos download.

Resources