This week, my major work on the project was still the integration of Winform and XNA.
I found out that a smooth integration of these two can be implemented. Yes, they are all in all the children of DotNet framwork. By using the approach of Model View Controler, the GraphicsDevice that deals with graphic calculation and reprentation can be imported and loaded as a Control component in the MainForm.
After other members in our group finish all the user case and sequence diagrams, I think then I'll be able to write down all major interfaces and make a new demo that will run as we expect.
Thursday, October 21, 2010
Friday, October 15, 2010
Winform & XNA main framework and some utility classes design
This week, I've made our draft design for Winform & XNA framework.
These some uitility classes that need to be used in our project.
These some uitility classes that need to be used in our project.
This is for week10
During week10 (from 05/10 - 10/10), I was working at integration of Windows form and XNA project.
I seemed so much work to do in order to let Winform and XNA work together and get keyborad and mouse event handled properly.
The good luck is that the sample code found by Phili has shown the possiblilty. I then got another very cool program source code, where they elegantly use Winform and XNA together. Base on these findings I think next week I'll be able to design our own frame work for our project.
I seemed so much work to do in order to let Winform and XNA work together and get keyborad and mouse event handled properly.
The good luck is that the sample code found by Phili has shown the possiblilty. I then got another very cool program source code, where they elegantly use Winform and XNA together. Base on these findings I think next week I'll be able to design our own frame work for our project.
Sunday, September 19, 2010
I have made the first demo
This has been a great week, although I feel so tired now, as I've finished 3 big assignments and most importantly I've made our first string creating demo:
When A key is pressed, user can continually add control-points, by clicking left-mouse-botton, to form a string, or a knot.
Now, it's 3D version, and the Natural Cubic Spline seems very good to use in our probject.
On Wednesday, I started looking for some good curve-drawing algorithms for Knot_A_Problem. 4 hours at that day and I got nothing. Those curve-drawing algorithms in the internet seem just complex mathematical stuff and hard to understand. Some C source code are available online but they look just another mathematical formulation due to its lack of documentation. On Thursday, I got understanding of how the 2D DrawCurve method works in DotNet Framework for WinForm. Then I decided to write our own 3D version of CubicSpline class for further use in our project. Meeting with other group members on Friday, talking about the Technical Manual, I thought that it was actually in urgent need for us to get one demo works, otherwise, we are gonna have to face some big problems in doing Technical Manual. So I've been working from yesterday (Saturday) morning until this milestone, a working demo.
Here is the CubicSpline class, sorry for not providing documentation for it yet, I'll add them later on:
namespace Knot_A_Problem
{
class CubicSpline
{
int controlPointNo = 2;
double[,] controlPoints;
pspline.pspline3interpolant interpolantP;
pspline.pspline3interpolant interpolantClosedP;
{
class CubicSpline
{
int controlPointNo = 2;
double[,] controlPoints;
pspline.pspline3interpolant interpolantP;
pspline.pspline3interpolant interpolantClosedP;
public CubicSpline()
{
controlPoints = new double[controlPointNo, 3];
interpolantP = new pspline.pspline3interpolant();
interpolantClosedP = new pspline.pspline3interpolant();
}
{
controlPoints = new double[controlPointNo, 3];
interpolantP = new pspline.pspline3interpolant();
interpolantClosedP = new pspline.pspline3interpolant();
}
public CubicSpline(List<Vector3> pointList)
{
controlPointNo = pointList.Count;
controlPoints = new double[controlPointNo, 3];
interpolantP = new pspline.pspline3interpolant();
interpolantClosedP = new pspline.pspline3interpolant();
{
controlPointNo = pointList.Count;
controlPoints = new double[controlPointNo, 3];
interpolantP = new pspline.pspline3interpolant();
interpolantClosedP = new pspline.pspline3interpolant();
for (int i = 0; i < controlPointNo; i++)
{
controlPoints[i, 0] = (double)(pointList[i].X);
controlPoints[i, 1] = (double)(pointList[i].Y);
controlPoints[i, 2] = (double)(pointList[i].Z);
}
if (controlPointNo >= 3)
{
pspline.pspline3build(controlPoints, controlPointNo, 2, 2, ref interpolantP);
pspline.pspline3buildperiodic(controlPoints, controlPointNo, 2, 2, ref interpolantClosedP);
}
}
{
pspline.pspline3build(controlPoints, controlPointNo, 2, 2, ref interpolantP);
pspline.pspline3buildperiodic(controlPoints, controlPointNo, 2, 2, ref interpolantClosedP);
}
}
public List<Vector3> GetCubicSpline(int n)
{
double xGet = 0, yGet = 0, zGet = 0;
double internalT = 0;
if(n != 0)
internalT = 1 / ((double)n);
List<Vector3> calVectors = new List<Vector3>();
if (controlPointNo >= 3)
{
for (int i = 0; i <= n; i++)
{
pspline.pspline3calc(ref interpolantP, internalT * i, ref xGet, ref yGet, ref zGet);
calVectors.Add(new Vector3((float)xGet, (float)yGet, (float)zGet));
}
}
return calVectors;
}
{
double xGet = 0, yGet = 0, zGet = 0;
double internalT = 0;
if(n != 0)
internalT = 1 / ((double)n);
List<Vector3> calVectors = new List<Vector3>();
if (controlPointNo >= 3)
{
for (int i = 0; i <= n; i++)
{
pspline.pspline3calc(ref interpolantP, internalT * i, ref xGet, ref yGet, ref zGet);
calVectors.Add(new Vector3((float)xGet, (float)yGet, (float)zGet));
}
}
return calVectors;
}
public List<Vector3> GetClosedCubicSpline(int n)
{
double xGet = 0, yGet = 0, zGet = 0;
double internalT = 0;
if (n != 0)
internalT = 1 / ((double)n);
List<Vector3> calVectors = new List<Vector3>();
if (controlPointNo >= 3)
{
for (int i = 0; i <= n; i++)
{
pspline.pspline3calc(ref interpolantClosedP, internalT * i, ref xGet, ref yGet, ref zGet);
calVectors.Add(new Vector3((float)xGet, (float)yGet, (float)zGet));
}
}
return calVectors;
}
}
}
{
double xGet = 0, yGet = 0, zGet = 0;
double internalT = 0;
if (n != 0)
internalT = 1 / ((double)n);
List<Vector3> calVectors = new List<Vector3>();
if (controlPointNo >= 3)
{
for (int i = 0; i <= n; i++)
{
pspline.pspline3calc(ref interpolantClosedP, internalT * i, ref xGet, ref yGet, ref zGet);
calVectors.Add(new Vector3((float)xGet, (float)yGet, (float)zGet));
}
}
return calVectors;
}
}
}
Another StringGeometry class has been defined and implemented to draw geometries around the central curve to form the string. It's very long, I'm not going to post it here.
Thursday, September 2, 2010
First draft interface has been done
This week, after 4 hours work on drawing a draft interface for Knot_A_Problem software, our first draft interface has been done. Thanks very much for Allen's help on this work!
So far the desired operations provided are ---
Creat new knot
Save a knot file
Open a knot file
Undo
Redo
Select a point on the string and move it
Delete a point
Add a point
Lock\Unlock a point to be fixed
Rotate the view camera
Move the view camera
Enlarge a view window
Get back to 4 viewport mode
Zoom out
Zoom in
Select colors
Play the animaiton of drawing a knot
Stop palying
Print
Print preview
Submit a knot onto online database server.
The left side of the interface is a tree view that shows knots fetched from online database server.
I think the menu should be elaborated. It's now far away from sophisticated. It's good for all of our group member to have a brainstorm on it tomorrow.
Friday, August 27, 2010
More elegant operation should be provided
Again, users can add points or delete any of the points to form lines, and more elegantly, our software could allow user to drag any set of connected points to make strings they want. The idea is we could introduce the Fixed Point operation: when a user click a point with hitting F key, that point is now being marked fixed, then when the user drag the point P1 from A to C, only three points can be moved (see the green line). The behaviour of the lines to transform is no longer like the one being moved from A to B (see the blue line).
This week, I think I'm going to draw a draft interface using VS windows forms and Photoshop.
Saturday, August 21, 2010
Came out a algorithm to make curves more like a strings - core technical feasibility research continues
I think that we can use weighted points to make a curve behave more like a string:
When we drag P1 from position A to B, other points should move respectively according to the its weight.
How Lines can be represented using XNA and .Net Framework
This diary was actually written one week ago on 14 of August, now I post it here.
One core thing in our project is to be able to graphicly represent knots. Users can load a predefined knot to see the looking of the knot and how the knot is created step by step. Users are also allowed to draw curves and make them to be some knots. I tried today checking to see if XNA is a good framework for our project. After three hours work on creating 3D world space, drawing some points and lines, making camera view rotated using mouse movement events, I think XNA is a powerful tool. We could use it for our project.
I also looked into the possibility of creating curves, using some well defined algorithm: Bezir curve or B-spine curve.
One core thing in our project is to be able to graphicly represent knots. Users can load a predefined knot to see the looking of the knot and how the knot is created step by step. Users are also allowed to draw curves and make them to be some knots. I tried today checking to see if XNA is a good framework for our project. After three hours work on creating 3D world space, drawing some points and lines, making camera view rotated using mouse movement events, I think XNA is a powerful tool. We could use it for our project.
I also looked into the possibility of creating curves, using some well defined algorithm: Bezir curve or B-spine curve.
Drawing lines and 3D rotation have been tested. Now it is time to fine a good curve algorithm for our project.
Subscribe to:
Posts (Atom)