C# Faster Drawing Vector Graphics - c#-2.0

In my application I want to draw polygons using Windows Create Graphics method and later edit the polygon by allowing the user to select the points of the polygon and allowing to re-position them.
I use moue move event to get the new position of the point to get the new coordinates of the point being moved and use Paint event to re-draw the polygon. The application is working but when a point is moved the movement is not smooth. This is probably due to large numbe of mouse move and paint events firing while moving the point.
I dont know weather the mouse move or the paint event the performance hindrance.
Can anyone make a suggestion as to how to improve this?

look at double buffering in c#. this can speed thing up greatly.

From my Win32 expirience (not a .NET) the fastest vector graphic is Metafile. I dont know if the C# System.Drawing.Imaging.Metafile is as fast as Win32 one. Could be as fast as your video 2D hardware.

Related

Moving point with mouse

I drew a lot points in my program with webgl. Now I want to pick any point and move this point new position. The case is I don't know how to select point. So am I supposed to add actionlistener to each point?
WebGL is a rasterization library. It has no concept of movable, clickable position or points. It just draws pixels where you ask it to.
If you want to move things it's up to you to make your own data, use that data to decide if the mouse was clicked on something, update the data to reflect how the mouse changed it, and finally use WebGL to re-render something based on the data.
Notice none of those steps except the last one involve WebGL. WebGL has no concept of an actionlistener since WebGL has no actions you could listen to. It just draws pixels based on what you ask it to do. That's it. Everything else is up to you and outside the scope of WebGL.
Maybe you're using some library like three.js or X3D or Unity3d but in that case your question would be about that specific library as all input/mouse/object position related issues would be specific to that library (because again, WebGL just draws pixels)

Advice for library with GeoSpatial Mapping that allows users to place moving objects on a 2D map

I'm looking for a library/framework/toolkit that will allow me to render a 2D map from real GeoSpatial data and draw objects on the 2D map.
Requirements:
Map Tiling (when I zoom into the map, i want a more detailed image)
Pan (ability to use the mouse to move around the map)
Read various Geospatial images (satellite, street, etc)
Ability to draw objects onto the map (based on lat/longs) and have them move. For example, I want to be able to put an image of a bird on the map and have it move and rotate correctly.
Primitive shapes. It would be nice if it had built in ability to draw lines, circles, etc.
Complex drawing. For example, I want to draw a compass and have it show the heading of the current heading of the bird.
Mouse input. I want to be able to right click on the map and have a context menu appear. I want to click and hold an shape I draw on the map and drag it easily.
What I have looked at:
OpenSceneGraph with osgEarth. It's great, and fulfills my reqs, but is really slow and I had to do a lot of weird things to get things to work (especially with dragging objects on the map).
Cesium: looks promising, but somewhat slow, and I need it to work as a desktop application. I've seen online that some have managed to use Cesium inside Qt's Webkit, but I'm not sure I would want to take that risk.
EDIT:
I really want to stay away from a web-based framework if possible.
http://imgur.com/52DaJtQ
Here is a primitive picture of what I'm want to achieve. The aircraft icon should move and the degree circle along with it. I want to be able to drag the green waypoints and have the lines redraw as I move a waypoint. The red sensor footprint should adjust to what the aircraft can see.
http://imgur.com/52DaJtQ
Google Maps, Open Street Map, Bing Maps.
I use OpenSceneGraph/osgEarth extensively and am not dissatisfied with its performance.
What kind of weird things did you need to do?
If you want, you can contact me privately to troubleshoot your situation. Me website is AlphaPixel.com and there's a contact form there.

Draw order of 3D-Models in XNA

i'm having trouble with drawing 3D-Models in the right order in XNA.
Here are two images that describe the problem:
Pic1: http://imgur.com/wGPIk&L5AY1l
Pic2: http://imgur.com/wGPIkl&L5AY1
The ball is moving downwards and as soon as it intersects the terrain, the perspective is changing so that it looks like as if the ball is behind the terrain.
If i change the order of drawing, it will look like the ball is on top of the terrain all the time..
Can someone please explain how to solve this problem?
Thanks in advance
The problem is the SpriteBatch call that draws your FPS counter in the corner.
SpriteBatch changes the state of the graphics device. Whenever you're done drawing your 2D objects (in this case, your frame rate counter in the upper-left corner), you need to restore the device state.
After calling SpriteBatch.End(), add this code:
device.DepthStencilState = DepthStencilState.Default;
where device is a reference to the current GraphicsDevice that you're drawing with.
This looks like a ZBuffer problem. Have you checked that your Zbuffer is enabled and working? Try what David Lively said. if that works, check that you don't draw your 3D models Inside the Begin and End calls of the SpriteBatch class.
Begin readies the device for drawing 2D objects, if you try now to call 3D drawing this can't work. End makes sure that everything, set for 2D, is unset and reverted to the states before the Begin call.

XNA beginner question about draw method

I understand that I have to draw everything in draw(), and it's looping continuously.
But I don't want to draw texture again and again, for example I want to create a texture, draw something to texture (not spritebatch). than I will only draw that texture in draw().
Is it possible?
What can I use?
You have to draw again and again, as in short, if you dont it wont show. A wise man once wrote in a windows development book
Ask not why the text on your windows has to be constantly drawn, ask why it never used to be in DOS/Unix command line.
If something is placed over the area you're drawing too, and you dont redraw it, it just simply wont be there. You need to keep drawing it for it to be sustained on screen. Its done very quickly and wont hurt anything (especially if you're thinking in terms of background)
Not drawing it again is a performance optimisation. You should only do that if you really need to.
If you do need to do this, create a render target, draw your scene to the render target, and then draw your render target to the screen each frame (using SpriteBatch makes this easy) instead of your scene.
Take a look at this question about caching drawing using render targets.

Quartz2D good way to Draw point or line on touch?

I'm trying to develop an app that requires drawing based on user touch. I'm using Quartz2D and CoreGraphics for drawing, now I'm wondering what's a good way to manage the points that i'm drawing? Currently I'm adding each touchMoved point to an array and setNeedsDisplay them on every move. This lags the system very fast. So Therefore I'm wondering if anyone know a good way to draw smoothly with user touch for a good amount of time? Thanks!
Touch events are fired very frequently. since quartz2d is slow your system will saturate.
several options
Switch to opengl ^^ (bu that is an overkill)
don't do a draw on every single event. put you touch to sleep (acutally thats an android soluiton so I'm not sure its good for Iphone), only draw 1 out of x lines.
store the coordinates of your touch somewhere and when your app is ready to refresh the ui, get the current values stored and do you draw.
another solution I had put in place is to test if the new position had actually moved of more that a certain amount from the las draw (lets say 1~3 px) this way I avoid refreshing and redrawing if the updated position was to small.
This are just pointers, there might be a better option for you case ^^

Resources