|
I am doing some project where I read values from accelerometer sensor. I also want to apply XNA framework where I rotate model according to sensor values (angles). I am using example from App Hub website. However the Draw() method is protected and I don't know how to redraw model according to sensors values not to timer ElapsedSeconds. There is Draw() method:
partial class ModelViewerControl : GraphicsDeviceControl
{
protected override void Draw()
{
Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);
GraphicsDevice.Clear(backColor);
if (model != null)
{
float rotation = (float)timer.Elapsed.TotalSeconds;
Vector3 eyePosition = modelCenter;
eyePosition.Z += modelRadius * 2;
eyePosition.Y += modelRadius;
float aspectRatio = GraphicsDevice.Viewport.AspectRatio;
float nearClip = modelRadius / 100;
float farClip = modelRadius * 100;
Matrix world = Matrix.CreateFromYawPitchRoll((float)0, (float)rotation, (float)rotation);
Matrix view = Matrix.CreateLookAt(eyePosition, modelCenter, Vector3.Up);
Matrix projection = Matrix.CreatePerspectiveFieldOfView(1, aspectRatio, nearClip, farClip);
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World = boneTransforms[mesh.ParentBone.Index] * world;
effect.View = view;
effect.Projection = projection;
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.SpecularPower = 16;
}
mesh.Draw();
}
}
}
}
And there is port_DataReceived():
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
switch (comport.ReadChar())
{
case 'B':
byte[] angle;
angle = new byte[2];
comport.Read(angle, 0, 2);
break;
}
}
If somebody knows how to do that or who have any idea, please let me know that.
|
|
|
|
|
I don't have my XNA code in front of me in order to give it to you. But I have used this website which has so many amazing tutorials on XNA. Take a look at this 2d tutorial[^] which all the principles taught here will apply to your scenario. Also, for a bonus check out the fun flight sim tutorial.
Have fun coding! One final thing. Let me know how it goes!
|
|
|
|
|
how to write part of application widow to vga or usb out as video stream what i want is part of application (square selection of app winfrom window) view on LCD (not in my lap top other LCD ) screen.
|
|
|
|
|
Don't post this in multiple places - it wastes effort and can annoy people.
Pick either QA or the forums - but not both, please!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hey all,
I've been making a project recently, and I wanted to run the program on linux, but I don't know at all how to use Mono, so can anyone tell me how to convert my codes to a linux application? or at least, give me the link to a tutorial about this stuff!
Thank you.
|
|
|
|
|
|
Well, I wouldn't have asked if I didn't try to search in the first place but thanks anyway for your help
|
|
|
|
|
There's a reason why I posted that result list.
There's tons and tons of tips and stuff. FAR more than you will EVER get in a couple of forum posts.
Start reading - especially all the stuff on the Mono site.
|
|
|
|
|
What kind of application? WinForms, ASP.NET? You can simply install the MonoDevelop IDE, and copy the sources. Open the solution in the IDE, build and run.
There's also a bunch of examples on the site where you download Mono.
Bastard Programmer from Hell
|
|
|
|
|
Thank you. I've downloaded MonoDevelop. And I'm using Windows Forms. Does it implement all the dlls that come with the .net framework?
|
|
|
|
|
AhmedOsama wrote: Does it implement all the dlls that come with the .net framework?
There's a visual on what's implemented here[^].
Bastard Programmer from Hell
|
|
|
|
|
No it doesn't. There's no support for WPF for instance.
|
|
|
|
|
But it supports SilverLight or was that Moon something
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
|
how to make C# coding with implement of Analytical Hierarchy Process(AHP).
and i use Microsoft visual studio 2008
|
|
|
|
|
|
You might want to change your user name, otherwise you'll get spam.
|
|
|
|
|
We are calling LoadLibary in C#. For this we have included the below code in the C# file.
[DllImport("Kernel32.dll")]
internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule);
We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path.
What could be the reason for dll failure.
|
|
|
|
|
The likeliest problem is that something the DLL you are trying to load relies on can't be found in the path.
|
|
|
|
|
The dll is physically existing in the desired path. But still LoadLibraryW( ) fails.
|
|
|
|
|
Did you read my answer? I said that something the DLL relies on is probably outside the path.
|
|
|
|
|
.DLL's sometimes are not standalone modules. It's entirely possible the .DLL you're trying to load uses another .DLL that you don't have somewhere where it can be found.
Use this[^] to find out what that dependancy might be. Just open the .DLL that's failing in it.
|
|
|
|
|
The error code means that the file cannot be found. As I requested in the C++ forum, please show the exact code (including the string parameter) of the call that fails. We cannot guess what is happening inside your program. At a (bad) guess, based on what you wrote in the C++ forum, your code looks like:
LoadLibaryW("C:\abc.dll");
which will most likely fail as the backslash needs to be escaped.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
The exact path is
LoadLibraryW("C:\\Program Files\\MyApp\\");
|
|
|
|