Newbie here.. Need some help..

13 views
Skip to first unread message

Cheng Teck

unread,
Oct 7, 2009, 1:46:23 AM10/7/09
to Physics2D.Net
Hi all..
I am quite new to Physics2D.Net.
Pardon me for doing any stupid things..
I am coding a WPF application using C#

I want to create a ball object on the form

This is my code..
However when I execute my application, I get nothing?
It is due to me not using any renderer?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AdvanceMath;
using AdvanceMath.Geometry2D;
using Physics2DDotNet;
using Physics2DDotNet.Shapes;
using Physics2DDotNet.PhysicsLogics;


namespace PhysicsTesting
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
PhysicsEngine engine = new PhysicsEngine();
engine.BroadPhase = new
Physics2DDotNet.Detectors.SelectiveSweepDetector();
engine.Solver = new
Physics2DDotNet.Solvers.SequentialImpulsesSolver();
PhysicsTimer timer = new PhysicsTimer(engine.Update, .
01f);
timer.IsRunning = true;
Coefficients coffecients = new Coefficients(/*restitution*/
1, /*friction*/.5f);
//Shape shape1 = new Ellipse();
Physics2DDotNet.Shapes.IShape shape1 = new CircleShape(8,
7);

float mass = 5;
//Body CircleBody = new Body(new PhysicsState(), shape1,
mass, coffecients, new Lifespan());
Body body1 = new Body(new PhysicsState(), shape1, mass,
coffecients, new Lifespan());
engine.AddBody(body1);


}

}
}

Daniel Story

unread,
Oct 7, 2009, 1:59:00 AM10/7/09
to Physics2D.Net
Yes, the physics engine itself does not render anything on screen. You
will need to render your object on screen with it's belonging body's
state. Though I've never worked with WPF, so not sure the best method
for it. I'm only used to GDI+ and DirectX; I can post a simple GDI+
example if need be.
Message has been deleted

Cheng Teck

unread,
Oct 7, 2009, 2:29:32 AM10/7/09
to Physics2D.Net
Hi.. Thanks for your fast reply..
Let's say if I were to add a rectangle control and a ellipse control
to my form.
If it is possible to make the rectangle control a floor and the
ellipse rolling onto the floor?
Something like this in the screenshot below...
http://i37.tinypic.com/2yww9lj.png

Daniel Story

unread,
Oct 7, 2009, 8:17:46 PM10/7/09
to Physics2D.Net
do the shape controls support rotation? Because you will need to
update the control's linear (location) and angle (rotation) by the
body's state each time step. (Body.State.Position.Linear.X,
Body.State.Position.Linear.Y, and Body.State.Position.Angular).


On Oct 7, 12:29 am, Cheng Teck <chengtec...@gmail.com> wrote:
> Hi.. Thanks for your fast reply..
> Let's say if I were to add a rectangle control and a ellipse control
> to my form.
> If it is possible to make the rectangle control a floor and the
> ellipse rolling onto the floor?
> Something like this in the screenshot below...http://i37.tinypic.com/2yww9lj.png
Reply all
Reply to author
Forward
0 new messages