In the Hebrew University in Jerusalem there are a few MATLAB applications, consisting of both calculations and UI. Since the UI is becoming increasingly complex, it's getting very hard to maintain it.
What I'd like to do is keep the calculations and the rendering of 2D and 3D graphs in MATLAB, but control the entire UI from elsewhere. I know MATLAB exports a COM interface, which is OK for using MATLAB calculations, but I couldn't find a way to pass rendered data (MATLAB plots, basically) back through it.
Is there a way to do that?
The simplest thing for you to do would be to issue an instruction to MATLAB to create the plot (perhaps creating it offscreen, to avoid an unwelcome popup window), adjust its appearance and size, then save it to an image file. Pass the filename back, then load it in from your UI code and display it.
However, that will not of course get you a plot that is "live", so you won't be able to edit it, or click on it/interact with it, or even resize it nicely.
If you need that, I'm afraid there's no documented or supported way to do it. But if you're willing to go undocumented, then MATLAB also has a Java interface (jmi.jar) that you can call from Java, and you can embed a live MATLAB plot within a Java GUI, attaching MATLAB or Java callbacks to plot elements.
Note that that capability is completely undocumented, and may well change from release to release without warning. If you'd like to learn how to approach that, I'd recommend reading through the blog Undocumented MATLAB, and probably buying a copy of the book by that blog's author.
Related
My question is
Gui libraries like Qt and lets say for Windows operating systems
how do they create all those graphical user interfaces(windows etc).
Does each operating system gives API's or something else to do so?If yes, then how operating systems draw all those windows and things.Do they (operating systems) "control" the screen and then draw each pixel one by one to achieve their goal the GUI?
I would like an answer that explains things at the lowest level possible but well i don't demand someone to write me everything that happens( even if i would like to) because i know many things are behind all these.So for this reason comments with links or suggested books which explain with details
on what is happening under the hood would be appreciated.
Stackoverflow answers are not supposed to use links, comments can but not answers.
Each operating system and gui library is different, but, yes in some way, shape, or form they do actually draw every one of the pixels. It is often quite organized and many peformance solutions are used, optimized routines that can update a rectangle or some chunk of a screen, sometimes hardware gets involved (these days a lot of the time the hardware or basically gpus get involved the cpu asks the gpu to draw something then the gpus are busy placing all the pixels).
You would likely for example want to create some sort of font rendering function that is given the font, the string to display, the font size, and perhaps a clipping window to not go outside, or perhaps a function that with the font, size and string returns the number of pixels then you can adjust the string to fit and wrap (look around this web page for example, drag the window wider and narrower and watch what web text does).
Definitely some sort of image drawing routines with the ability to stretch or fit the drawing to the rectangle defined.
The fun stuff, games, etc has improved so rapidly over time that it is hard to go back to a simple line draw and area fill routine, etc. But also along with the technology the games brought simple things like web pages benefit...Again look around.
There are many open source programs and libraries you should just wander around the source code and see what you see.
The operating system provides libraries that interface with the monitor/display. In short, GUI libraries such as Qt interact with those libraries of the operating system and creates an easier bridge for you, the programmer to interact with the monitor. For instance, Qt might have a drawLine feature, which underneath is taking care of pixel arrangement related to drawing on the monitor/display for the operating system.
It's known that 3D rendering is computation expensive.
And I want to use Apache Hadoop for distributed 3D rendering (rendering images or videos) to reduce rendering time. So after learning about Hadoop, I understand that I need 2 things:
Data, which will be visualized (probably it some kind of file, which contains instructions (like draw rectangle, set coordinates, set color etc.))
Some Tool/Program/Utility to render file described above. I want to invoke it from my program, pointing it to file with data. (it's good if this program has a command line API).
But I don't know anything about 3D rendering, so I need your help in suggesting tools (open-source) for render 3D images/videos. Also I don't know anything about input data. So it will be nice if you suggest me render tool + file format to render.
I heard about using Hadoop with .rib file format as data to visualize, and rndr program to render this data. So I need some analogue.
Please note, my goal is to more deeper learn about Hadoop and distributed computation, not about 3D rendering, so please suggest me simplest solution.
Thanks.
KISS: Gnuplot
If you really only care about using Hadoop, and your only requirement of the rendering is that it takes an input file and makes an image so you can show a completed animation, then I would suggest gnuplot. It is actually a graph-drawing program, but it takes scripts and produces image files, and most usefully for you you can enter mathematical formulae to draw rather than constructing 3d worlds to render.
You would simply prepare n files which are all the same except for an offset value for the time since start, and gnuplot would produce the appropriate frame.
This is the simplest option, and lets you concentrate on the Hadoop side. To show you how simple, this would produce a frame for an animation of a 3-blade fan spinning:
set xrange[-1:1]
set yrange[-1:1]
set polar
unset key
unset border
unset tics
set terminal png size 1000,1000
set output "frame_$FRAME.png"
plot cos(3*t+$FRAME/5)
A great thing about Gnuplot is that you type in commands in an interactive prompt to manipulate the graph, and these are the same commands you put in the script. So once you have something you're happy with, you can either do save 'newscript.gpt' or copy out the commands you used. You can recreate the graph by just running gnuplot newscript.gpt at a prompt.
Incidentally, it is easier to simulate hard-to-render scenes than to actually construct them, so just put a sleep command in the gnuplot script to make it take 15 seconds or however long.
The whole banana: Blender
Blender is a 3d rendering system. I believe it is used as a rendering system for some mainstream animations on server farms in exactly the manner you describe. It has quite a learning curve, but I think you should be able to pick up a tutorial or other pre-existing animation project files. From there you would need to work out how to invoke the rendering engine as a command for a specific frame. I've only ever done static rendering in blender, so I can't take you further there. This would be more impressive visually, but no more impressive academically, and you'll waste more time on that side of things.
My choice
Personally I would go with gnuplot. You can make 3d plots with the splot command rather than the 2d plot, and although it's not 3d scene rendering as you might be imagining, it achieves the purpose of making a picture using a script. You can begin with something totally basic like the above until you have your setup going, then introduce more complexity; from an implementation perspective, running a gnuplot script is easier than running a script that also requires a data file, but it's still easy to pre-generate the data and have gnuplot read that when you want to do command + script + data instead of command + script. The key is incrementally increasing the difficulty, not running before you can walk.
If you ultimately find you have spare time at the end and change it to using blender, then that's all free win, and you haven't jeopardised your hadoop project making it pretty.
I'm a structural engineering master student work on a seismic evaluation of a temple structure in Portugal. For the evaluation, I have created a 3D block model of the structure and will use a discrete element code to analyze the behaviour of the structure under a variety of seismic (earthquake) records. The software that I will use for the analysis has the ability to produce snapshots of the structure at regular intervals which can then be put together to make a movie of the response. However, producing the images slows down the analysis. Furthermore, since the pictures are 2D images from a specified angle, there is no possibility to rotate and view the response from other angles without re-running the model (a process that currently takes 3 days of computer time).
I am looking for an alternative method for creating a movie of the response of the structure. What I want is a very lightweight solution, where I can just bring in the block model which I have and then produce the animation by feeding in the location and the three principal axis of each block at regular intervals to produce the animation on the fly. The blocks are described as prisms with the top and bottom planes defining all of the vertices. Since the model is produced as text files, I can modify the output so that it can be read and understood by the animation code. The model is composed of about 180 blocks with 24 vertices per block (so 4320 vertices). The location and three unit vectors describing the block axis are produced by the program and I can write them out in a way that I want.
The main issue is that the quality of the animation should be decent. If the system is vector based and allows for scaling, that would be great. I would like to be able to rotate the model in real time with simple mouse dragging without too much lag or other issues.
I have very limited time (in fact I am already very behind). That is why I wanted to ask the experts here so that I don't waste my time on something that will not work in the end. I have been using Rhino and Grasshopper to generate my model but I don't think it is the right tool for this purpose. I was thinking that Processing might be able to handle this but I don't have any experience with it. Another thing that I would like to be able to do is to maybe have a 3D PDF file for distribution. But I'm not sure if this can be done with 3D PDF.
Any insight or guidance is greatly appreciated.
Don't let the name fool you, but BluffTitler DX9, a commercial software, may be what your looking for.
It's simple interface provides a fast learning curve, may quick tutorials to either watch or dissect. Depending on how fast your GPU is, real-time previews are scalable.
Reference:
Model Layer Page
User Submitted Gallery (3D models)
Jim Merry from tetra4D here. We make the 3D CAD conversion tools for Acrobat X to generate 3D PDFs. Acrobat has a 3D javascript API that enables you to manipulate objects, i.e, you could drive translations, rotations, etc of objects from your animation information after translating your model to 3D PDF. Not sure I would recommend this approach if you are in a hurry however. Also - I don't think there are any commercial 3D PDF generation tools for the formats you are using (Rhino, Grasshopper, Processing).
If you are trying to animate geometric deformations, 3D PDF won't really help you at all. You could capture the animation and encode it as flash video and embed in a PDF, but this a function of the multimedia tool in Acrobat Pro, i.e, is not specific to 3D.
I've created a relatively simple tower defense game using c++ and SFML. I'm very interested in creating a nice gui overlay for it, ie hud, menus, etc. I know there are a lot of gui libraries out there, but I would like to make my own (for learning purposes.
I'm very familiar with working with graphics, but I'm not as familiar with GUI systems (I just render my frames, and don't worry about widgets, title bars, etc.).
Are there any good articles out there, or perhaps suggestions anyone has regarding how to layout such an interface?
There are a couple ways I know of (at least for Java) to get a nice HUD in your game. One method is to have a separate 3D world with the UI elements placed directly in front of the camera, then overlay that camera's view over the main view. This can be buggy at times, especially when you don't have a good color filter, or when you have a high number of objects being displayed. Another method is to look at a GUI library designed for this purpose (such as NiftyGUI for Java).
A quick Google search lead me to a listing on Wikipedia of many open-source GUI libraries you could use. There are many others out there, so you should probably do the Google search yourself, or look around on GitHub and SourceForge.
I'm messing around with image manipulation, mostly using Python. I'm not too worried about performance right now, as I'm just doing this for fun. Thus far, I can load bitmaps, merge them (according to some function), and do some REALLY crude analysis (find the brightest/darkest points, that kind of thing).
I'd like to be able to take an image, generate a set of control points (which I can more or less do now), and then smudge the image, starting at a control point and moving in a particular direction. What I'm not sure of is the process of smudging itself. What's a good algorithm for this?
This question is pretty old but I've recently gotten interested in this very subject so maybe this might be helpful to someone. I implemented a 'smudge' brush using Imagick for PHP which is roughly based on the smudging technique described in this paper. If you want to inspect the code feel free to have a look at the project: Magickpaint
Try PythonMagick (ImageMagick library bindings for Python). If you can't find it on your distribution's repositories, get it here: http://www.imagemagick.org/download/python/
It has more effect functions than you can shake a stick at.
One method would be to apply a Gaussian blur (or some other type of blur) to each point in the region defined by your control points.
One method would be to create a grid that your control points moves and then use texture mapping techniques to map the image back onto the distorted grid.
I can vouch for a Gaussian Blur mentioned above, it is quite simple to implement and provides a fairly decent blur result.
James