Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esimerkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tie
ohj1
2021s
esimerkit
Commits
0de6714c
Commit
0de6714c
authored
3 years ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
liitos
parent
e42c8f19
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
luennot/luento17/Liitos/Liitos.cs
+53
-0
53 additions, 0 deletions
luennot/luento17/Liitos/Liitos.cs
with
53 additions
and
0 deletions
luennot/luento17/Liitos/Liitos.cs
+
53
−
0
View file @
0de6714c
...
...
@@ -4,19 +4,72 @@ using Jypeli.Controls;
using
Jypeli.Widgets
;
using
System
;
using
System.Collections.Generic
;
using
FSJoint
=
FarseerPhysics
.
Dynamics
.
Joints
.
DistanceJoint
;
using
FarseerPhysics.Factories
;
using
FarseerPhysics.Dynamics
;
using
Jypeli.Farseer
;
using
Jypeli.Physics
;
using
FarseerPhysics.Dynamics.Joints
;
public
class
Liitos
:
PhysicsGame
{
public
class
AxleJoint
:
Jypeli
.
AxleJoint
{
internal
FSJoint
InnerJoint
{
get
{
return
(
FSJoint
)
innerJoint
;
}
set
{
innerJoint
=
value
;
}
}
/// <summary>
/// Luo uuden akseliliitoksen kahden olion välille.
/// </summary>
/// <param name="firstObject">Ensimmäinen olio</param>
/// <param name="secondObject">Toinen olio</param>
/// <param name="axlePosition">Liitoksen akselin paikka</param>
public
AxleJoint
(
PhysicsObject
firstObject
,
PhysicsObject
secondObject
,
Vector
axlePosition
)
:
base
(
firstObject
,
secondObject
,
axlePosition
)
{
World
world
=
PhysicsGame
.
Instance
.
Engine
as
World
;
var
first
=
firstObject
.
Body
as
PhysicsBody
;
var
second
=
secondObject
.
Body
as
PhysicsBody
;
var
ap2
=
firstObject
.
Position
+
axlePosition
-
secondObject
.
Position
;
InnerJoint
=
JointFactory
.
CreateDistanceJoint
(
world
,
first
.
FSBody
,
second
.
FSBody
,
axlePosition
*
FSConvert
.
DisplayToSim
,
ap2
*
FSConvert
.
DisplayToSim
);
// axlePosition2 * FSConvert.DisplayToSim);
InnerJoint
.
DampingRatio
=
0.5f
;
InnerJoint
.
Frequency
=
50
;
//InnerJoint.Enabled = false;
}
}
public
override
void
Begin
()
{
Level
.
Background
.
Color
=
Color
.
Black
;
var
osa1
=
new
PhysicsObject
(
200
,
30
);
osa1
.
MakeStatic
();
osa1
.
AddCollisionIgnoreGroup
(
1
);
Add
(
osa1
);
var
osa2
=
new
PhysicsObject
(
200
,
30
);
osa2
.
Position
=
new
Vector
(
osa1
.
Width
,
0
);
osa2
.
AddCollisionIgnoreGroup
(
1
);
Add
(
osa2
);
var
liitos
=
new
AxleJoint
(
osa1
,
osa2
,
new
Vector
(
osa1
.
Width
/
2
,
0
));
liitos
.
Softness
=
0
;
Add
(
liitos
);
Gravity
=
new
Vector
(
0
,
-
400
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment