|
|
 Prize winner in Competition
"C# May 2006"
Comments and Discussions
|
|
 |
|

|
Nothing but great straightforward examples, showing how to do no so simple things in C#/.Net. Thank you for sharing!
|
|
|
|
|
|
|

|
My name is Elad, I'm from Israel.
I am a student (CS) in the college of management.
I am using the project you build for my class presentation over 3rd party software.
I would like to show my classmates some kind of an API of your code.
and i saw that you wrote your notes inside the program in a special way.
is there any program i can run on your project that can create an API for me?
or do I need to do the hard work by hand?
Or maybe you do have an API somewhere out there?
thank you for your time!
regards,
Elad Yanai.
|
|
|
|

|
Hi, Elad,
I've never personally used it, but if you're trying to generate API documentation from XML comments, people seem to love NDoc.
http://ndoc.sourceforge.net/[^]
|
|
|
|

|
Hi,
thx for this great thing... i have no idea how to work with 3D objects, this is a great point to start from... thank you again!
|
|
|
|

|
it looks very nice, and simple, I wonder how can we use the same logic to translate for example, a perfect square into a trapezoid depending on perspective, plus, calculate the size of a shape depending on the "distance" relative to perspective over the square, and finally change the velocity as the same as the size, depending on the perspective...
could you please provide an advice to achieve this?.
regards.
|
|
|
|

|
Damn, I deleted the wrong post, now I have to write it again img src="/script/Forums/Images/smiley_smile.gif" align="top" alt="Smile | :)" />
Ill give some half pseudo code here:
Matrix world = Matrix view = Matrix.CreateLookAt(Vector3 cameraPosition, Vector3 targetPosition);
Matrix proj = Matrix.CreatePerspectiveFOV(Pi / 4, aspect ratio(width/height), near, far);
Matrix vp = new Matrix(
width, 0, 0, 0,
0, -height, 0, 0,
0, 0, 1, 0,
width/2,height/2,0, 1);
Matrix worldView = world * view;
Matrix projVp = proj * vp;
Vector4 point = new vector4(x,y,z,1);
point = Vector4.Transform(point, worldView);
point = Vector4.Transform(point, projVp);
point /= point.W;
If want code where you just enter x,y,z and retrieve the screenspace coord as output just tell me and ill write it for you.
Or else you could try to write your own math library for it(It took me a while though, im 15 and I didin't know any linear algebra at all before I started creating my own 3D engine), Or if you wanna take it easy you could search the internet or use Xna/DirectX's math
Good luck
|
|
|
|

|
Hello,
Its a great one!.
Can I rotate the dominoes to rotate in the similar manner as the cube does. Basically I need a cube to be placed within a dominoes and both rotate simultaneously on button click. The dominoes will rotate along with its axis along with the cube.
Any kind of help is appreciable.
Thanks,
Rajesh
|
|
|
|

|
I use C#2005, I even delete unit Test but It does not work.??? Can you help me? Point out exactly what I have to delete or Can you post a verified program?
|
|
|
|

|
I don't know what to tell you, dude. I just downloaded, unzipped, opened, and built it, then ran the example program, and it all worked just fine.
What's the specific error that you're getting?
|
|
|
|

|
How come drawing a simple object like the sphere is so incredibly slow? Do you have any idea what my GPU can do in a millisecond? This library does the same thing about a billion times slower. Therefor, I see much more potential in using XNA or MDX.
--
Thany
|
|
|
|

|
Well, yeah...
Dude, I hope you weren't planning on porting DOOM or anything. This project is a mathematical novelty, not a gaming framework.
All this thing can do is plot points in a 3D space, and draw lines to connect them. That's it, front-to-back. And when your library can only draw straight lines, a sphere is not a "simple object". It's an absurdly complex one.
In addition, it's built on top of the System.Drawing namespace. That's a fundamentally 2D environment. And all the 3D math that I'm doing is straight high school trigonometry using the System.Math class (no assembly optimizations, just straight managed code). It's simple, and it's illustrative, and it's turtle slow. And those were exactly the design goals of the project.
Anyway, I hope you're not too disappointed. Luckily, if you want to do some high-performance 3D stuff in an optimized framework, you've got about a thousand of them to choose from. Good luck.
|
|
|
|

|
Dear Pete Everett,
I'm a student at the university college of Antwerp in Belgium.
Currently I'm doing research on balance measurement of CVA patients (people who had a stroke).
I'm using accelerometer sensors to monitor the position of their body. May I use part of your CPI3d code to make my life and the life of the CVA patients a little easier ? The software will be used for research only and will not be commercialized.
Best regards,
Paul
e_paul321@hotmail.com
--P.E.--
|
|
|
|

|
Hi Paul,
I just officially assigned a Code Project Open License to the library, which roughly means that you're welcome to use it pretty much however you like. (Feel free to commercialize your software if you get the chance.)
Keep in mind, though, that I built the library as a proof-of-concept, and there are no guarantees that it actually works like it's supposed to in all the corner cases. So if you're planning to do anything serious with it, make sure you test it.
I hope it helps you out. Good luck with your research.
-Pete
|
|
|
|

|
Hi,
Excuse for my english very bad.
I download Plot3D_src, but I can't open and use it.
How can I do ?
Thanks
|
|
|
|

|
Two possibilities come to mind. This is a Visual Studio 2005 solution, so if you're using an earlier version of visual studio, you won't be able to open it. Also, it uses the NUnit unit testing framework, so you won't be able to build the code without that.
If lack of NUnit is your problem, you can just remove the test project from the solution (you don't really need it) and everything else should build just fine. If you have an old version of Visual Studio, that's a little trickier. Here's a link[^] to a previous thread where someone converted the code to VS 2003.
Or if you're having still yet some other problem, you'll need to describe the environment you're working in a little better.
|
|
|
|

|
Hi,
I want to say first that your article is really nice ! Easy to use and understand !
But ... I have a question about the location.
I changed the location because i wanted to have a good perspective.
But I don't know how draw the plot3D where I want.
For example, if I want to draw the same cube with : p.Location = new CPI.Plot3D.Point3D(50, 50, 500); at (0,0) of the Graphic.
I just want to do a kind of translation.
|
|
|
|

|
If I'm reading your question correctly, you're trying to force the upper-left-hand corner of a cube at the virtual coords of (for example) [50,50,500] to be drawn at [0,0] of the Graphics object that we're projecting onto. If that's what you're trying to do, the library doesn't actually have any support for that. You can change the projected position of 3D objects by changing the camera location of the Plot3D, but that will also change the perspective, and therefore the look, of the projected objects.
Your best bet might be to draw your object onto a Bitmap, and when you're done drawing, pay attention to the BoundingBox property of the Plotter3D object. That'll tell you (approximately) what the 2D bounds are, and from there you can use regular ol' GDI+ calls to reposition the drawn image however you'd like.
Or if I've misunderstood your question, feel free to clarify.
(Sorry I took so long to respond. I didn't notice that anybody had posted a question. I probably accidentally deleted the e-mail notification.)
|
|
|
|

|
Well done Pete,
Please can you tell me if i can use this work to fill the 3D shapes
with colors just like the cube?
|
|
|
|

|
Sorry. This is strictly a wireframe sort of thing. (That's actually one of the FAQs in the article.) Drawing filled areas in 3D is pretty hard, and I'm pretty lazy. If you want to do filled areas, you're better off with an actual 3D engine of some sort.
|
|
|
|

|
Very well thought out and programmed. Well done!
|
|
|
|

|
Why I can't find NUnit namespace. Please tell me how can download that NUnit and put it in my project.
|
|
|
|

|
NUnit is a unit testing framework which I used to develop the unit tests for the project. You can grab the framework from their web site at http://www.nunit.org/[^], or you can just remove the unit test project from the solution, and it'll build just fine for you.
|
|
|
|

|
By the way, can you tell me how download System.Window, System.Window.Media namespace. I don't know how to download it from microsoft site to import it to my project. Thanks a lot.
|
|
|
|

|
That's pretty far off-topic, and you'll probably want to direct similar questions someplace (any place) else. System.Windows.Media seems to be a .NET 3.0 namespace. If you want to work with 3.0 with VS2005, you'll need to download the WPF extensions, which you can get here[^]. If you need any more help on the subject, try an appropriately themed forum.
|
|
|
|

|
You've done an incredible job putting together this library and making it easy to use. I have a lot of programming experience (and my fair share of 2D/3D experience) but I've never seen such a targeted, light weight, flexible and easy to use library even from commercial offerings. Please keep up the good work. Just a thought, I haven't dug into your code but will this work one a windows mobile 2006 device?
|
|
|
|

|
Hi. Thanks for the comment. That's kind.
As far as windows mobile 2006, I've certainly never tried it, and I don't have a mobile device or emulator handy to test it out, but I can't think of any reason why it wouldn't work. The underlying code isn't really doing anything too fancy. Just some line-drawing methods from the Graphics class, and some basic trig functions from the Math class. so it should work just fine.
If you end up trying it out, leave a comment here if you think of it, letting everybody know whether or not it works.
|
|
|
|

|
This is EXACTLY what I've been looking for. Thank you SO much! I love the way you wrote your article, as well as the code! You are truly a professional programmer!
|
|
|
|
|
|
|

|
... an optical illusion but I think the rotating cube changes its edge length... May be it is a problem with my sight...
Great article. Thanks!!
*************************
Do, ut des.
|
|
|
|

|
you're amazing, im sorry i cant give you 6
|
|
|
|

|
You've got my 5!
Do you happen to have a VS2003 version for this work?
Victor.
|
|
|
|

|
Thanks for your vote, Victor.
I don't actually have a VS2003 version of the code, primarily because I don't have VS2003 installed anywhere anymore, but I just breezed through the source code of the library, and it seems that it should be a pretty simple change to retrofit it for 1.1 support. I think that the only 2.0 feature I'm actually using is that I'm implementing the IEquatable<> interface in the Point3D and Vector3D structs. I'll bet that if you remove the reference to IEquatable in both of those source files, the code will compile just fine in .NET 1.1. Just create a new class library project in VS2003, then add the 5 .cs files from my project to it, and you should be up-and-running. I'm too lazy to look through the example code, but I'll bet it would be just as simple to tweak that for 1.1 support as well.
|
|
|
|
|

|
Is it possible to draw a single point in XYZ coordinate?
Please reply to me at the following email:
ederobbio@motoman.es
Thank you
Regards
Eduardo
|
|
|
|

|
No. You can't really draw a point in this library. That's not too unusual, though, as you can't really draw a point in GDI+, either. You can kind of fake a point by drawing a stubby little line, but that doesn't work well, because a stubby line will be bigger if it's closer to you on the Z axis, and smaller if it's further away. The best bet, I think, would be to use the library to figure out the 2D coordinates of the 3D point you want to plot, then use a regular ol' GDI+ call to do the actual drawing. Here's how I see it working (very roughly, at least...this isn't what this library was designed to do). Keep in mind that this is off the top of my head, and completely untested, but it should approximate drawing a point in 3D:
using (Plotter3D p = new Plotter3D(someGraphicsObject, new Point3D(cameraX, cameraY, cameraZ)))
{
PointF point = new Point3D(x, y, z).GetScreenPosition(p.CameraLocation);
someGraphicsObject.DrawLine(Pens.Black, point.X, point.Y, point.X, point.Y + 1);
}
|
|
|
|

|
What is the best way to handle drawing the axes and then plotting the points reference to the axes?
With love,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|

|
Your question touches upon three things that this project isn't very good at doing.
First, drawing axes and plotting points relative to those axes smells a lot like absolute positioning (X, Y, Z) to me. This library is really designed to do relative positioning (Up, down, left, right). You can manage absolute positioning with the Plotter3D.MoveTo(Point3D) method, and that'll do what it sounds like you're looking for, but it's not really the focus of the library.
Second, it's not good at drawing infinite lines (like axis lines). If you draw a really long line along the z axis, it'll end up at a vanishing point, and it'll just look like a short stubby line. (You'll see what I'm talking about in the example).
And third, it's not good at drawing lines that extend past the camera position. So if you set up the Plotter3D at (for example) {0, 0, -100}, and you draw a line that extends to {0, 0, -200}, things get weird. It's important to keep the plotter positioned in front of the camera.
Anyway, here's some sample code to draw the X, Y, and Z axes.
float xOrigin = 500;
float yOrigin = 300;
float zOrigin = 0;
using (Plotter3D p = new Plotter3D(someGraphicsObject,
new Point3D(xOrigin - 100, yOrigin - 100, zOrigin - 1001)))
{
p.PenColor = Color.Red;
p.PenUp();
p.MoveTo(new Point3D(xOrigin - 1000, yOrigin, zOrigin));
p.PenDown();
p.MoveTo(new Point3D(xOrigin + 1000, yOrigin, zOrigin));
p.PenColor = Color.Blue;
p.PenUp();
p.MoveTo(new Point3D(xOrigin, yOrigin - 1000, zOrigin));
p.PenDown();
p.MoveTo(new Point3D(xOrigin, yOrigin + 1000, zOrigin));
p.PenColor = Color.Green;
p.PenUp();
p.MoveTo(new Point3D(xOrigin, yOrigin, zOrigin - 1000));
p.PenDown();
p.MoveTo(new Point3D(xOrigin, yOrigin, zOrigin + 1000));
}
Tom Hanks isn't a very good actor.
|
|
|
|

|
Thanks for the reply and the information. I was thinking if this library could be used as the basis to draw 3D charts, like Bar/Column charts, in which case the axes are not infinite.
I have even bought the book you recommended and will study the given code to see how far I could get with this project.
Again, thanks for the support.
Pete Everett wrote: Tom Hanks isn't a very good actor.
He needs our prayer and love
With love,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|

|
This is an excellent article. Well written text and code. I am looking forward to your future articles!
Woody
|
|
|
|
|

|
Great information! I'll surely be using this!
Thanks,
Ziggy
www.ziggyware.com
Advanced C# Tutorials
Game Development Resources
|
|
|
|

|
That is the first article about creating 3D graphics that really made sense to me. Thank you very much for writing it, and writing it so well. I can't wait to play around with your classes.
|
|
|
|

|
I come from china, I have been add you blog http://blog.cynicalpirate.com to my favorite. This is my blog http://zklxj.cnblogs.com.
|
|
|
|

|
Hello
Thank you for this nice article, keep the good work
Elias
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A library which draws 3D images on any GDI+ Graphics object.
| Type | Article |
| Licence | CPOL |
| First Posted | 9 Jun 2006 |
| Views | 259,218 |
| Bookmarked | 398 times |
|
|