Skip to content

Commit

Permalink
Arania Exumai now working for mouse, without loop video
Browse files Browse the repository at this point in the history
  • Loading branch information
bigokro committed Sep 11, 2015
1 parent da3c9b0 commit d65854d
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 54 deletions.
1 change: 1 addition & 0 deletions HarryParty/AraniaExumai.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 70 additions & 37 deletions HarryParty/AraniaExumai.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,56 +33,73 @@ public partial class AraniaExumai : Form
private WandTracker wandTracker;
private Spell trigger;

private double maxConfidence;
private double minConfidence;

int count = 0;
Boolean spellCast, shownEnd;
Dictionary<Guid, WiimoteInfo> mWiimoteMap = new Dictionary<Guid, WiimoteInfo>();
WiimoteCollection mWC;
GlobalMouseHandler gmh;

public AraniaExumai()
{
InitializeComponent();

strokesGraphics = Graphics.FromImage(strokesBitmap);
wandTracker = new WandTracker();
List<String> spellNames = new List<string>();
//spellNames.Add("Aguamenti");
spellNames.Add("Reparo");
spellNames.Add("Metelojinx");
spellNames.Add("Tarantallegra");
spellNames.Add("Locomotor");
spellNames.Add("Incendio");
spellNames.Add("WingardiumLeviosa");
wandTracker.setSpells(spellNames, null, null, null);

this.maxConfidence = 0.0;
this.minConfidence = 1.0;
this.spellCast = false;
this.shownEnd = false;

this.KeyPreview = true;
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(HandleKeys);


}

void gmh_TheMouseMoved()
{
System.Drawing.Point cur_pos = System.Windows.Forms.Cursor.Position;

// Check for spell action
trigger = wandTracker.addMousePosition(cur_pos, DateTime.Now);

if (trigger != null) // && trigger.casting())
{
castSpell();
}

drawWandMovement();
}


private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(wplayer_PlayStateChange);
//axWindowsMediaPlayer1.URL = @"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_pre.mp4";
//axWindowsMediaPlayer1.settings.autoStart = false;
//axWindowsMediaPlayer1.Ctlcontrols.play();
playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("AraniaExumaiVideos");

playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("ExpectoPatronumVideos");
preMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_pre.mp4");
playList.appendItem(preMovie);
loopMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_loop.mp4");
//playList.appendItem(loopMovie);
postMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_post.mp4");

axWindowsMediaPlayer1.currentPlaylist = playList;
//WMPLib.IWMPMedia3 preFile = (WMPLib.IWMPMedia3)axWindowsMediaPlayer1.mediaCollection.getAll().get_Item(0);
//axWindowsMediaPlayer1.currentMedia = preFile;

}

private void HandleKeys(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case ' ':
spellCast = true;
castSpell();
break;
}
e.Handled = true;
Expand All @@ -105,15 +122,20 @@ void wplayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChan
//playList.removeItem(preMovie);
if (!spellCast)
{
playList.appendItem(loopMovie);
//playList.appendItem(loopMovie);
pbStrokes.Visible = true;
if (mWC == null || mWC.Count == 0)
if ((mWC == null || mWC.Count == 0) && wandTracker.positions.Count == 0)
{
initWiiMotes();
}

axWindowsMediaPlayer1.Visible = false;

}
else if (spellCast && !shownEnd)
{
// TODO: moved this to the place where the spell is cast
axWindowsMediaPlayer1.Visible = true;
playList.appendItem(postMovie);
pbStrokes.Visible = false;
shownEnd = true;
Expand Down Expand Up @@ -167,6 +189,11 @@ private void initWiiMotes()

wm.SetLEDs(index++);
}

// Init Mouse tracker, too
gmh = new GlobalMouseHandler();
gmh.TheMouseMoved += new MouseMovedEvent(gmh_TheMouseMoved);
Application.AddMessageFilter(gmh);
}

void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
Expand Down Expand Up @@ -217,8 +244,6 @@ private void UpdateWiimoteChanged(WiimoteChangedEventArgs args)
{
WiimoteState ws = args.WiimoteState;

strokesGraphics.Clear(Color.Black);

for (int i = 0; i < 4; i++)
{
if (ws.IRState.IRSensors[i].Found)
Expand All @@ -231,28 +256,34 @@ private void UpdateWiimoteChanged(WiimoteChangedEventArgs args)

if (trigger != null) // && trigger.casting())
{
// TODO: HERE IS WHERE EVERYTHING SHOULD HAPPEN!!!!!!!!!!!!
spellCast = true;
castSpell();
}

IftttStartStopSpell spell = new IftttStartStopSpell(
"bslEohHzR8x_HsJ3vWzxub",
"hue_arania_exumai_on",
"hue_spell_off",
5);
spell.castSpell();
drawWandMovement();
}

Incendio cloudBit = new Incendio("00e04c034e9a", "c83578c843ac46220849a1bd919662b340e537dd14f0b234a5a99634becc5339", 50, 1000, null, null);
cloudBit.castSpell();
private void castSpell()
{
spellCast = true;
Application.RemoveMessageFilter(gmh);

IftttStartStopSpell spell = new IftttStartStopSpell(
"bslEohHzR8x_HsJ3vWzxub",
"hue_expecto_patronum_on",
"hue_spell_off",
30);
spell.castSpell();

axWindowsMediaPlayer1.Visible = true;
//playList.appendItem(postMovie);
pbStrokes.Visible = false;
shownEnd = true;
axWindowsMediaPlayer1.currentMedia = postMovie;
}

if (trigger.getConfidence() > maxConfidence)
{
maxConfidence = trigger.getConfidence();
}
if (trigger.getConfidence() < minConfidence)
{
minConfidence = trigger.getConfidence();
}
}
private void drawWandMovement()
{
strokesGraphics.Clear(Color.Black);

Position previous = null;
foreach (Position p in wandTracker.positions)
Expand All @@ -264,10 +295,13 @@ private void UpdateWiimoteChanged(WiimoteChangedEventArgs args)
}
System.Drawing.Point pointA = new System.Drawing.Point();
System.Drawing.Point pointB = new System.Drawing.Point();
// TODO: different measures for different inputs... do this in the position class

pointA.X = (PositionStatistics.MAX_X - previous.point.X) / 4;
pointA.Y = (PositionStatistics.MAX_Y - previous.point.Y) / 4;
pointB.X = (PositionStatistics.MAX_X - p.point.X) / 4;
pointB.Y = (PositionStatistics.MAX_Y - p.point.Y) / 4;

strokesGraphics.DrawLine(new Pen(Color.Yellow), pointA, pointB);

previous = p;
Expand Down Expand Up @@ -313,7 +347,6 @@ private void UpdateWiimoteChanged(WiimoteChangedEventArgs args)

pbStrokes.Image = strokesBitmap;
}

private void UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color)
{
//chkFound.Checked = irSensor.Found;
Expand Down
7 changes: 0 additions & 7 deletions HarryParty/ExpectoPatronum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@ private void drawWandMovement()
pointB.X = (PositionStatistics.MAX_X - p.point.X) / 4;
pointB.Y = (PositionStatistics.MAX_Y - p.point.Y) / 4;

/*
pointA.X = previous.point.X / 4;
pointA.Y = previous.point.Y / 4;
pointB.X = p.point.X / 4;
pointB.Y = p.point.Y / 4;
*/

strokesGraphics.DrawLine(new Pen(Color.Yellow), pointA, pointB);

previous = p;
Expand Down
7 changes: 4 additions & 3 deletions HarryParty/HarryParty.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
-->
<ItemGroup>
<Folder Include="Properties\New Folder\" />
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<None Include="media\images\hogwarts_logo_wood.jpg" />
Expand Down Expand Up @@ -276,9 +277,6 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\bg_gryffindor.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="media\images\sorting_hat_bg_gryffindor.jpg" />
</ItemGroup>
Expand All @@ -294,4 +292,7 @@
<ItemGroup>
<None Include="media\images\wand_expecto_patronum.png" />
</ItemGroup>
<ItemGroup>
<None Include="media\images\wand_arania_exumai.png" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions HarryParty/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions HarryParty/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@
<data name="sorting_hat_bg_hufflepuff" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\sorting_hat_bg_hufflepuff.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="sorting_hat_bg_ravenclaw" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\sorting_hat_bg_ravenclaw.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btn_lumos" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\btn_lumos.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand All @@ -139,16 +136,22 @@
<data name="btn_arania_exumai" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\btn_arania_exumai.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btn_expecto_patronum" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\btn_expecto_patronum.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btn_hedwig" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\btn_hedwig.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btn_expecto_patronum" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\btn_expecto_patronum.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="sorting_hat_bg_ravenclaw" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\sorting_hat_bg_ravenclaw.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="wand_expecto_patronum" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\wand_expecto_patronum.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="hogwarts_logo_wood" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\hogwarts_logo_wood.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="wand_expecto_patronum" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\wand_expecto_patronum.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="wand_arania_exumai" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\wand_arania_exumai.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file removed HarryParty/Resources/bg_gryffindor.bmp
Binary file not shown.
Binary file added HarryParty/media/images/wand_arania_exumai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d65854d

Please sign in to comment.