Code to Graph XYZ coordinates - c++

I need to graph XYZ coordinates in a 3D cube that I can rotate. Im look for code that will basically take a 3d array of 1s and 0s and build a cube. Coloring of the points would also be nice. The program that creates the point is in C/C++ so I would prefer something that would play nicely will that but Im not picky. Im alright aware that Mathematica can do this , but Im looking for something that can be "live" updated so I can watch the progress
Thanks in advance

One obvious possibility would be something like Direct3D (for Windows, X-box and Windows Phone 7) or OpenGL (for pretty much anything that can do 3D except X-box or Windows Phone 7).
There are quite a few libraries and sample code for things like this.
If you're working on Unix/Linux, you may or may not have OpenGL installed. If you don't, you might want to check into Mesa3D.

I would go with Jerry's suggestion of using OpenGL. There are some good tutorials out there too - have a look at the nehe series which have examples for doing precisely what you're after.

Refer this tutorial link : http://www.directxtutorial.com/
This will help you to implement three dimensional cube.

Related

C++ Graphic API with a small learning curve - linux

i have to do some very basic drawing in Linux , like joining some points , tracing trajectory of a moving point . I am looking for a graphic library which has a very small learning curve so that i can save my time and avoid getting into things like gtk and opengl since i don't need something complicated .
Edit 1 :Can you provide links to the tutorials for SDL which explains very basic drawing also for any other libraries which you think is relevant .
You want pygame, Allegro, or SDL with SDL_gfx. All of these are available through the most popular package repositories.
Be prepared to get used to dealing with surfaces, graphics primitives, blitting, and the like. The learning curve is not large, but it's still a significant paradigm shift if you've never done graphics before.
I was taught with FLTK, and as the middle aged man says "I turned out OK didn't I?"
You might be also interested in Cocos2dx, it works on many different platforms (linux included).

OpenGL rotating textured planes in 3D space

I'm wondering if anyone could point me to any resources that would deal in rotating one or several 2D textured planes in 3D space. Something like this but with openGL (preferably C++):
I'm attempting to do pretty much the exact same thing but no matter how I order my operations I'm getting right-screwy results. So I figure asking for some resources on the subject is better than posting tons of code and asking for people to fix my problems for me. :)
If you havent already, do a search for 'NeHe tutorials'. An excellent set of OpenGL tutorials.
Here is a link to the rotation tutorial, includes all the source code in downloadable format and the tutorial walks you through each relevant line.
http://nehe.gamedev.net/tutorial/rotation/14001/
I believe this is working in a 2D space, the step up to 3D probably involves a bit more matrix math but...doable
The NeHe tutorials are a very popular place to learn the basics of OpenGL. In particular, the tutorial about texture mapping should help you:
http://nehe.gamedev.net/tutorial/texture_mapping/12038/
Mind you though that these tutorials are written for older OpenGL versions which are more beginner friendly IMHO.
You should look into scene graphs. Basically it is a way to define a bunch of objects (2D textured planes) and their transforms in 3D space. This allows you to define transforms that work on multiple nodes (objects) as well as single nodes. You can make a pretty simple one in C++ with little effort, or use one such as OpenSG or OSG (slight learning curve needed).
Wikipedia - http://en.wikipedia.org/wiki/Scene_graph

How to use C++ to draw a polygon using an array of 3d points

I would like to get help in using C++ in order to draw a polygon using an array of 3d points. I already sort my array so that my points are arranged in order(i.e one points follow the other). Any help will be appreciated in advance. Thanks
Unless I am misreading the question, you will need a 3D-Rendering API such as Direct3D or OpenGL. There are other options, but those two are by far the most popular.
You do have to be aware that Direct3D is available only on Windows, while OpenGL is supported on most major platforms. But Direct3D is part of DirectX which is an entire package of multimedia APIs while OpenGL is strictly graphics (aside from OpenAL for audio).
Whichever you choose, there are countless tutorials online about drawing basic polygons that are just a quick Google search away.

graphics programming

I would like to program some graphic figures such as line, circle,etc. I have used turboc++ 3.0 for
dos graphics. I would like to do the same with the compilers dev c++ or code blocks or vc++.
I would like to implement dda and bresenhems line and circle drawing algorithm.
how should I go about implementing these programs through these compilers (not the command line tools).
I have a really vague picture of graphics programming.please help..
please note : I have a nvidia graphics card 1gb.. so I cannot use dos graphics (I think the card is the reason).
If you're wanting to play around with graphics code to draw objects and do things with them may I suggest that you skip the whole Windows/GDI/DirectX/ thing completely and take a look at Processing?
It's basically Java, so you won't have to jump too far for the language, but more specifically it's designed for playing around and experimenting with graphics, so may suit you perfectly.
You really have a vast variety of options. Starting from GDI (not hardware accelerated), finishing with a heavy stuff like DirectX, OpenGl. There is also a nice library, called SDL. It does not really matter what technology you will use to solve your problems. If the speed is not a matter, i think GDI is the right and most simple choice.
You may want to start off with these tutorials:
http://www.tutorialized.com/tutorials/C-and-Cpp/Graphics/1
From the sound of things, you're trying to produce a program that runs on Windows. In that case, you don't need to implement basics like Bresenham's algorithm to be able to draw lines and circles. Windows provides MoveTo and LineTo to do basic line drawing, and Ellipse to draw ellipses -- and if the axes are equal, the ellipse it draws will be a circle.
Edit: It also sounds like you haven't written any code for Windows. This is quite different from writing code for DOS, so you'll probably need a good book. Charles Petzold's Programming Windows is a classic (though for C++ you'll want a somewhat older version -- I believe the current ones concentrate on the .NET languages).
I am using the powerful cross platform project: http://cimg.sourceforge.net/ .
you have there all primitives and more.
I you wish to use your GPU power you can use glut library for OpenGL.
cheers Arman.

How to use opengl to create cylinder effect

I would like to know how to create 'cylinder effect', like the top site feature in safari 4, here is a picture
http://www.macworld.com/article/139022/2009/02/safari4firstlook.html
Can you tell me what should i learn , how to get started?
I would start by working through the OpenGL tutorials on NeHe's website. You might also want to invest in the Red Book. Topics you'll be interested in: Geometry and texture mapping. I think NeHe even has an example of texture mapping on a cylinder.
Depending on what you hope to accomplish, you might be able to use the Visualization Toolkit to draw a texture on a cylinder in 100 lines of code or less. There's a bit of a learning curve to VTK (and OpenGL for that matter), but the vtkTextureMapToCylinder class and the TCL example of how to use it are good places to get started.
Please download iCarousel. It has many types of cylindrical effects in it.Use whichever is useful for you.