This project is read-only.

Jitter

Nov 29, 2012 at 8:05 AM
Edited Nov 29, 2012 at 3:27 PM

Hi Guys,

I am an absolute beginner at this so perhaps my question may seem dumb but please bear with me,

Also I apologize for posting this twice but I realized later on that this is the correct discussion area for this topic

I am using Windows 8, VS2012 Express for Windows 8, Blend 5

I have created a physics canvas

<ph:PhysicsCanvas x:Name="RootAnimationCanvas" MousePickEnabled="True" DebugMode="False" >

 

</ph:PhysicsCanvas>

 

Sprites

<ph:PhysicsSprite x:Name="PlanetObj" Canvas.Top="400" Canvas.Left="700" ShapeType="Polygon" Width="240" Height="80" RestitutionCoefficient="0"><Path Data="M0.5,1.252 L398,0.5 L202,300.5 z" Fill="Red" Canvas.Left="0" Stroke="#FF000000" Canvas.Top="0" UseLayoutRounding="False"/></ph:PhysicsSprite>
<ph:PhysicsSprite x:Name="PivotPoint" Canvas.Top="388" Width="10" Height="10" Canvas.Left="656" ShapeType="Ellipse" IsStatic="True"><Ellipse x:Name="Circle" Height="10" Width="10" Canvas.Top="0" Canvas.Left="0" Fill="Aqua"/></ph:PhysicsSprite>

And also a Joint

<ph:PhysicsJoint x:Name="Point" Canvas.Top="388" Canvas.Left="656" BodyOne="PivotPoint" BodyTwo="PlanetObj" CollisionGroup="1"/>

All these elements are inside the canvas

But now the issue I have is that when the object comes to near slowing down it starts to jitter and and vibrate.

I have also set the root canvas gravity to zero

RootAnimationCanvas.Simulator.Gravity.Y = 0;
RootAnimationCanvas.Simulator.Gravity.X = 0;

Just in case I also set the forces to clear.

RootAnimationCanvas.Simulator.ClearForces();

Also does physicshelper compile on ARM platform, as in would it work on an ARM device,
I know my question are basic and stupid but,

Please help guys =)

Nov 30, 2012 at 12:59 PM

Can you set DebugMode="True", just to verify that the boundaries are what you expect?

<ph:PhysicsCanvas x:Name="RootAnimationCanvas" MousePickEnabled="True" DebugMode="True" >

Dec 1, 2012 at 6:13 AM
Edited Dec 1, 2012 at 6:15 AM

Hi Andy,

Yes the boundaries are correct for the triangle and for the ellipse.

I even added another triangle and they collide and bounce just fine while rotating around the ellipse (with the restituion co-efficient set to .5) but its just that when they slow down they start to change position not so smoothly anymore, also like I wonder if its because my elements are too large, 

I had read something about the KMS system that is being applied in this engine, so when I made my elements really small the animation looked almost fine there was no jitter, but I wonder how can I have then big and perform just as well.

Thanks

Ronak

Dec 2, 2012 at 7:22 AM

Hi guys,

So in my investigation I discovered something else,

Im not sure this will apply to all objects of all sizes, but for me everytime the triangle rotating around the cirlce reaches and angular velocity of

0.016, is starts to jitter.

please guys is there any solution to this.

 

Ronak

Dec 2, 2012 at 7:22 AM

Hi guys,

So in my investigation I discovered something else,

Im not sure this will apply to all objects of all sizes, but for me everytime the triangle rotating around the cirlce reaches and angular velocity of

0.016, is starts to jitter.

please guys is there any solution to this.

 

Ronak

Dec 12, 2012 at 5:54 AM

Hi,

I there no solution for this, or has anyone even encountered this ?

Ronak

Dec 16, 2012 at 11:08 AM

Sorry to be really naggy,

But really does nobody have a solution to this.

cmon Im sure this has been done before Im just missing something please help me out guys.

Dec 16, 2012 at 1:17 PM

I recreated your sample above, and I'm not sure I see the Jitter you're talking about - do you mean that the Triangle just never comes to rest?

You can adjust the LinearDamping and AngularDamping properties on the object if you want to limit it's activity (the values of "5" below are just a random example, you'll need to tweak these as appropriate)

 

<ph:PhysicsSprite x:Name="PlanetObj" LinearDamping="5" AngularDamping="5" Canvas.Top="400" Canvas.Left="700" ShapeType="Polygon" Width="240" Height="80" RestitutionCoefficient="0"><Path Data="M0.5,1.252 L398,0.5 L202,300.5 z" Fill="Red" Canvas.Left="0" Stroke="#FF000000" Canvas.Top="0" UseLayoutRounding="False"/></ph:PhysicsSprite

> 

 

Dec 16, 2012 at 1:40 PM

Thanks for the reply Andy,

Then I am most certainly doing something wrong. I have the debug mode on the triangle draws fine.

i want to rotate a triangle around a center point, With the triangles vertex pointed at the joint.

I am creating a 

Circle

Triangle

Joint, where position = center of circle.

are there any special setting I need to observe,

Thanks

Ronak

I have posted all the code I use in the xaml file, just in case perhaps you could point out my mistake.

 

<Grid x:Name="LayoutRoot" Background="Black" >
        <Canvas x:Name="cnvGameOuter"  >
            <ph:PhysicsCanvas x:Name="cnvGame" Background="CornflowerBlue" DebugMode="False"  Width="1366" Height="768" MousePickEnabled="true">
                
                <ph:PhysicsSprite Height="8" x:Name="Star" Width="8" Canvas.Left="0" Canvas.Top="0" ShapeType="Ellipse" IsStatic="True" >
                    <Ellipse Height="8" Width="8" Stroke="Black" Canvas.Left="0" Canvas.Top="0">
                        <Ellipse.Fill>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF000000"/>
                                <GradientStop Color="#FF4F4949" Offset="1"/>
                            </LinearGradientBrush>
                        </Ellipse.Fill>
                    </Ellipse>
                </ph:PhysicsSprite>

                <ph:PhysicsSprite x:Name="PlanetObj" LinearDamping="1" AngularDamping="1" Canvas.Top="400" Canvas.Left="700" ShapeType="Polygon" Width="240" Height="80" RestitutionCoefficient="0">
                    <Path Data="M0.5,1.252 L398,0.5 L202,300.5 z" Fill="Red" Canvas.Left="0" Stroke="#FF000000" Canvas.Top="0" UseLayoutRounding="False"/>
                </ph:PhysicsSprite>

                <!--<ph:PhysicsSprite Height="20" x:Name="Planet2" Width="20" ShapeType="Polygon" Canvas.Left="0" Canvas.Top="0"  RestitutionCoefficient=".7" LinearDamping=".54">
                    <Image Source="Assets/blue.png" Height="10" Width="10"/>
                </ph:PhysicsSprite>-->


                <ph:PhysicsJoint x:Name="Pivot" Canvas.Left="0" Canvas.Top="0" BodyOne="Star" BodyTwo="PlanetObj" CollisionGroup="1" />
                <!--<ph:PhysicsJoint x:Name="Pivot2" Canvas.Left="0" Canvas.Top="0" BodyOne="Star" BodyTwo="Planet2" CollisionGroup="2" />-->

            </ph:PhysicsCanvas>

        </Canvas>
    </Grid>

Dec 16, 2012 at 4:31 PM

If I understand what you're talking about with the Jitter, I don't think much more can be done besides increasing the LinearDamping and AngularDamping properties. Part of what you're probably seeing is that the triangle is a pretty large object, so small changes in angle might cause the Jitter you're mentioning. If you try with a smaller object, is the Jitter still noticeable?

Note that you could also increase the TimeStep if you need a fast-forward (is the triangle falling too slow for your needs?)

<ph:PhysicsCanvas x:Name="cnvGame" Background="CornflowerBlue" DebugMode="False" TimeStep="0.08" Width="1366" Height="768" MousePickEnabled

="true">

 

Dec 17, 2012 at 8:46 AM

Hi Andy,

No I still find the problem even with small objects, 

sadly I am facing the thought of having to code this is DirectX, 

perhaps if you know some other way I can do this please do let me know.

Thanks

Ronak