I'm planning to draw these shapes in WPF. It's for an educational software.
What idea's do you have in how to implement these cubes and views?
I was planning at the beginning starting using canvas and draw, but I guess it will be become eternal. So I supposed if exists some library to help me drawing them?
The ability to draw 3D shapes (such as cubes) and render them from different angles is built right into WPF. From the look of your cubes, you're going to want an orthographic camera, rather than a perspective camera, because the lines composing your cubes are parallel.
You might also find the Petzold.Media3D library helpful, because it has objects like cubes built in (you don't have to write your own algorithms to build them).
Finally, you might this primer helpful in getting started with WPF 3D.
Once you have some idea of how to use 3D, it will just be a matter of putting cubes in your scene at the proper locations and positioning the cameras properly for viewing the cubes. You will probably want to keep reusing the same four camera positions: one for the "3D view", and one each for the top, side, and front views.
This should be a lot less work than trying to draw the cubes using 2D.
Related
I have a really peculiar question. I want to deteriorate the graphics in Unity of just a part of the screen. For example, if I'm playing a game with the screen split in two, one player can be playing with ultra graphics and the other, low ones. Is there a simple way of doing this, like setting the graphics quality on each camera? Thank you so much for your help!
I don't imagine and easy way to do that.
Graphics are the conglomerate of multiple things (at least for me); the number of polygons of an object, the size of the textures, etc.
So the only thing I know you can do, is to duplicate the scene (like if you are making and on-line game) and load this duplicate scene with different materials, models and textures on one player scene. Then synchronize the rest of the scene, so both players are looking the "same" scene.
Also you can "deform" the image, with shaders or camera filters, like a Blurr effect! But this won't really affect the "graphics".
I don't think that's currently possible. The game would have to render the same objects on 2 different ways, but that's just not possible in a good-performance scenario. You could very simple use prefabs with a lower quality on one of the screens or images with a lower resolution in the UI.
Do you really need this for your game? If u do some changes in the quality settings or change your game core mechanics, maybe the performance becomes good enough to skip this.
I currently have a WinForms C# application. I have a .txt file with GPS coordinates of some points (borders of buildings, roads etc.), and using Graphics.FillPolygon method in System.Drawing I am drawing these on a Panel. However, I got an idea that for what I am trying to do (it basically is a 2D game), a Unity 2D project would be more suitable and easy to use (mainly because of easier view handling using the cameras). However, I don't know how to do this drawing in it. I just need to somehow get these coordinates drawn in Unity, but I don't know how to do it.
Note: I already have some minor expirience with 3D in Unity, but I am a total newbie to 2D.
Thanks
There is no GDI/canvas implementation built into Unity. Drawing these in rastered 2D would be quite hard in Unity (basically putpixel level, or finding some third party library).
You have an alternative, though - you can draw these shapes in 3D, ignoring the third dimension. You have a few methods for this:
Line renderers - this one will be the easiest, but forget about anything else than just drawing the outline, no fill etc.
Make your own mesh - This will let you use the geometry with your scene. It's an retained mode API (you init your geometry once)
Use the GL namespace - This will be only rendered on the screen, no interaction with the scene. It's an immidiate mode API (draw everything on every frame)
Hello
I saw that there are some laptops with 3D support. I know that they use polarization for each eye. How can I write a program in C# that shows a simple 3D object in such system? I don't want to show a 3D object in a 2 D medium (Perspective view), but showing a 3D object similar to what you can see in a 3D film using a 3D glass.
Any suggestion for further study is highly appreciated.
Regards
What you need to do is display two images one for each eye. Each image is a perspective view but taken from two slightly different viewpoints - about the distance of your eyes apart.
When viewed through polarising or more likely LCD Shutter glasses you get the illusion of 3D objects.
In this case each eye's view is presented on the screen alternately and a signal is sent to the glasses to become clear or opaque so that the correct image is seen in each eye.
For a passive system you have to use two projectors for the left and right eye images and make sure that they are perfectly aligned so the images overlap correctly. If you get it wrong you won't get a very good 3D effect.
In both cases you need to create two views of your model and render each one for each frame you display. I used to work in this area and a while back wrote a blog post which included an overview on how we did stereo systems.
I think that you need to program directly using OpenGL or Direct3D. For the screen to display the polarized views necessary to achieve the 3D effect, the graphics card will need to know what it has to display. See here for some ideas.
For our game we have to create collision detection.
The problem is that the collided objects are in different canvasses/layers, which makes collision detection by pointlocation inpossible.
Does anyone have an idea how to solve this?
It's hard to give a great answer without some more information, but if all your layers are the same size then you can just roll your own collision detection. All you need to know is the locations and sizes of two things to be collision detected. Then you just test to see if one rectangle intersects with the other rectangle.
There is also a function that might be useful to use called TranslatePoint. This translates from one UIElements coordinates to another. So if you had a ball bouncing around in a smaller area of the screen with it's own local coordinate system, you could get the ball's coordinates relative to the entire screen with this function.
Can I suggest you try using the Farseer physics engine just to save yourself some pain?
http://farseerphysics.codeplex.com/
It's very good and is in use in some WP7 games already.
http://www.farseergames.com/
There's also some Blend behaviors and helpers to make using it even easier:
http://physicshelper.codeplex.com/
I would like to do something like this: a rotating cube on a form. I don't want to use any external library or dll, just pure .NET 3.5 (without directx). And a cube build with lines only. Could you please tell me how to do this?
I don't want to use external libraries because I don't need > 100 MB library to do this thing right? I want only to animate a rotating cube made with lines.
This is how you go about making a Cube in GDI+
C# 3D Drawing with GDI+ Euler Rotation
http://www.vcskicks.com/3d-graphics-improved.html
C# 3D-Drawing Cube with Shading
http://www.vcskicks.com/3d_gdiplus_drawing.html
Study assignment? This can be done with some simple 3D maths. You just need to understand the basics of matrix algebra, 3D transformations, and 3D->2D view transformation. The DirectX tutorial covers this, but you can google for it and you'll get plenty of other tutorials.
Added: Just to clarify - I'm not suggesting to use DirectX or anything. You can do this with standard System.Drawing tools. You just need to understand the math, and that's explained in the DirectX tutorials.
You might try using WPF and the 3D Tools source code released by the WPF team.
3DTools
Assuming you are using WPF for your GUI:
Make an animated PNG of the cube using a graphics program.
Use the APNG WPF Control to insert the image into your GUI.
This will yield a small assembly size and transparent background if needed.
You need a way to represent 3d points. There is no ready struct for that in .NET unless you use directx or WPF.
Then with a standard euler rotation matrix applied to the points you get the transformed points. If you only do rotations you can get away with 3x3 matrix, but if you want translation you better use 4x4 matrices and homogenous points.
After this you need a way to project those 3d points to the 2d canvas. Depending whether you are using perspective or orthographic projection the projection matrix will look a bit different.
Look into WPF in general, it will help you do this with a few measly lines of code. You can also host a WPF window in Forms.
http://msdn.microsoft.com/en-us/library/aa970268.aspx