3d icons on top representation with direct x 9 in c++ - visual-c++

I'm doing a simulator visual where I have a lot of 2D icons representing elements of the simulation and I have a 3D (.x made with Blender) icon which represents another and more important element.
I need to make this one on top of the other 2d icons (.tga) but I cannot find the way to make this. Is it possible for Direct x to draw a 3d icon over the rest of the 2d icons?.
At this moment, the 2D icons apear on top of the 3D, always.
Could please someone help me with this. I'm programming in C++
Thanks very much in advance.

Disable Z-writes when you render the 2D icons. When you then render the 3D icons with Z-writes enabled it will render OVER the 2D icons.
Your problem at present is that when you render the 2D icons you are doing so with a z value which is the front of the z-buffer (most probably 0). You may also find you can set the z-value to 1 (again this is probably, it entirely depends on how you've set up your 2D rendering) to force the 2d icons to render at the back of the z buffer.
No entry in the Z-buffer is equivalent to it being at the back of the Z-order.

Assuming you have depth buffering enabled, you need to ensure that the Z value of your icons is further from your camera than your model. If you are using ID3DXSprite, you should be able to specify the Z position when you call the Draw function, or by using the ID3DXSprite::SetTransform() function.
Note that ID3DXSprite may draw your sprites with a different projection matrix than your model, depending on the flags you pass to ID3DXSprite::Begin(). You might want to use the D3DXSPRITE_OBJECTSPACE flag.

Related

Is there any code for an interactive plotting application for a two dimensional curves

Plotting packages offer a variety of methods for displaying data. Write an interactive plotting application for two dimensionsional curves. Your application should be able to allow the user to choose the mode (line strip or polyline display of the data, bar chart or pie charts), colours, and line styles.
You should start with the GUI editation like this:
Does anyone know of a low level (no frameworks) example of a drag & drop, re-order-able list?
and change it to your primitives (more points per primitive instead of one ... handle each point as (sub)object so you can change its position later).
Then just add tools like add object,del object,... For hand drawing tool use piece wise interpolation cubics
The grid can be done like this:
How to draw dynamic 2D grid that adjusts according to camera zoom: OpenGL
Mouse zooming/panning is also important
Zooming graphics based on current mouse position
Putting all above together into simple editor looks like this:
Using GPU for curve rendering might give you some nice speed and functionality boost:
Is it possible to express "t" variable from Cubic Bezier Curve equation?
Mouse selection of objects might be a speed problem if your scene contains too many objects so in such case its best to use index buffers where you can mouse select with pixel perfect precision for almost free in O(1):
OpenGL 3D-raypicking with high poly meshes
The example is for 3D , in 2D is much simpler ...
Also do not forget to implement save/load functionality to some vector file format. I recommend using SVG it might be complicated to start with it but you can quickly check it contents in any SVG viewer or browser also in notepad as its just a text file. If you use just basic path elements and ignore the rest of SVG features you will see the parsing and creating SVG is not that hard for example See these:
Get Vertices/Edges From BMP or SVG (C#)
Discrete probability distribution plot with given values
For really big datasets you might want to use spatial subdivision techniques (Bounding (Volume)Area Hierarchy, or Quad tree) to ease up the operations...
More in depth implementation details about 2D vector gfx editors depends on language, OS, gfx api and GUI api you using and task you are aiming for ...

Is there any graphics library like this?

IS there any graphic library meeting the following requirement.
can draw a point, a line, and a circle.
the size of canvas can be extended automatically.
support negative coordinates.
can output to png or any vectorgraph(like svg).
can draw characters (english only) (even characters rotated at a certain angle)
for e.g.
I draw 2 point (-1,-1) (1,1).
it will output a 2x2 sized picture. This left-top is the point(-1,-1). and the right-bottom is the point (1,1)
thanks.
Yes, of course there are a couple of them. I would suggest you take a look and learn OpenGL. You can run it on Windows, Mac, Linux, iOS, Android, you name it.
It supports 2D and 3D rendering, and, even though is more complex than a regular 2D graphics library like CoreGraphics, it also more powerful.

How to write simple game/app for 3D screens (Evo3d, LG 3d)

Can anyone give me a hint or example how to write in real 3d on canvas?
I do not mean 3d projected on 2d like OpenGL or vectors, but on a screen as LG 3d or EVO3d. What if I have 2 stereoscopic images and want to show them as one. How can I do this?
(I prefer not to use OpenGL to render the real 3d since my graphics are so simple it does not require the use of OpenGL, think of it as a standard gallery that wants to display a picture/bitmap or pre-rendered animation)
I did some research before posting this question (of course) and found that many 3d-foto's are nothing but 2 fotos next to each other, does that maybe work for a game too? That I have to write on a canvas of dimensions (2*width, height) in stead of (width, height)?

How to draw 3D images?

I am working on a simple 3d software renderer but one thing I'm no sure about is how to actually draw it all on the screen. What could I use to draw a wireframed cube ?
I am not asking HOW to write a complete 3D pipeline just the final step, the actual drawing on the screen.
Edit: I think I could do that with SDL.
You need to project the 3D object onto the 2D screen using a perspective transformation matrix.
This will generate a set of 2D lines etc. which get drawn in the same way as "normal" 2D lines get drawn.
However, without more information about the language and/or framework you are using, it's not easy to go into any more detail.
For the "actual drawing on screen" in Windows XP of your software-rendered wireframe 3D, call StretchDIBits with a pointer to the array of bytes that represents your pixels. This answer addresses maximum convenience; maximum efficiency is another matter.

Suggestion for graphics library for 2D game (PC)

I'm trying to set base to a 2D game with destructible terrain and/or particle effects, scroll, zoom, characters, etc... I'd like to know if there is a graphics library that would support those things in both software and hardware acceleration (need pixel access). I've tried SDL (even with DirectX back-end), but it seems hardware does its job only in full screen. I'd appreciate any suggestion.
Use OpenGL. Perhaps via another library e.g. SDL. I do not know why you can't get windowed HW acceleration working, it might be a platform thing (but it's certainly a different question).
Set the projection matrix to orthographic and use one of the axis (typically z) to organise 'stacking' elements. With an appropriate transformation in the display subroutine, you can align the x/y coordinates with "traditional" drawing (i.e., top-left down, rather than bottom-left up).
Build your graphical elements into bitmaps, convert them into textures and draw them on top of OpenGL Rects.

Resources