3D Model Viewer - G-Sensor [NEW 2.0]

Search This thread

andrec

Member
Aug 16, 2008
32
0
Screenshot5.jpg


1.0 - Tiger
Modified a DirectX sample to use the g-sensor to view a 3D model :)
Mostly to show what can be done!
Rotation and zoom.

2.0 - T-Rex
- New model, advanced
- Filtered g-sensor input
- Other improvements

Enjoy! If you like, please donate for further development.

(.Net 3.5 required)
 

Attachments

  • 3DModelViewer.zip
    48.3 KB · Views: 7,063
  • 3DModelViewer2.0.zip
    1,014.4 KB · Views: 14,580
Last edited:

veil

Member
Jun 18, 2007
30
0
Good Job man ...The background could have been better ...like leaves.
 

giangishanghai

Senior Member
Sep 18, 2007
805
124
Shanghai
this is a very good start point.
what about to link this great app. for example.................if someone is calling you, can be great if a picture of the caller will come up on the screen in 3D like your tiger!!!! (i know is not easy, but is a nice dream!)
many thanks
ciao
 

Ximoon

Senior Member
Jul 9, 2008
130
0
40
Paris
www.yaronet.com
Really nice ! It seems you can do pretty nice stuff with that 3D chip after all ;)
Is the v-sync a driver issue or can it be solved in a way ? And just add some little filtering on gsensor inputs, that'll be so impressive.
 

Jorlin

Senior Member
Jun 5, 2008
584
10
I like it... to make it better: allow the tilt action to rotate even more so that you do not have to hold your diamond 90° in each direction to change the same amount if the model... that would be better to actually watch the model... :)
 

andrec

Member
Aug 16, 2008
32
0
Really nice ! It seems you can do pretty nice stuff with that 3D chip after all ;)
Is the v-sync a driver issue or can it be solved in a way ? And just add some little filtering on gsensor inputs, that'll be so impressive.

V-sync problem seem to be a driver issue, hopefully fixed with new official update.

About filtering the g-sensor input, I did try some simple methods, but didn't improve much. Can anyone suggest an effective algorithm?
 

Ximoon

Senior Member
Jul 9, 2008
130
0
40
Paris
www.yaronet.com
V-sync problem seem to be a driver issue, hopefully fixed with new official update.

About filtering the g-sensor input, I did try some simple methods, but didn't improve much. Can anyone suggest an effective algorithm?

Too bad for the vsynch, let's hope I'll be improved.

For filtering, you can try something like:
Filtered_Sample[t] = A*Raw_Sample[t] + B*Filtered_Sample[t-1]
With A+B = 1. Can't give you values, since it depends on the sampling period, but great A will lead to fast but noisy sampling, and great B will end laggy but smooth. Just try values such as 0.9+0.1, 0.99+0.01, etc... Hope that'll help !
 

TDO

Senior Member
Feb 15, 2006
339
37
Try it with the omnia drivers.

For me it looks like they have vsync enabled (but they are a lot slower)

TDO
 

Koush

Retired Recognized Developer
Sep 21, 2007
917
871
IL_000c: ldarg.0
IL_000d: ldfld class [Microsoft.WindowsMobile.DirectX]Microsoft.WindowsMobile.DirectX.Direct3D.PresentParameters Microsoft.Samples.MD3DM.Meshes::presentParams
IL_0012: ldc.i4.1
IL_0013: callvirt instance void [Microsoft.WindowsMobile.DirectX]Microsoft.WindowsMobile.DirectX.Direct3D.PresentParameters::set_SwapEffect(valuetype [Microsoft.WindowsMobile.DirectX]Microsoft.WindowsMobile.DirectX.Direct3D.SwapEffect)


namespace Microsoft.WindowsMobile.DirectX.Direct3D
{
public enum SwapEffect
{
Discard = 1,
Flip = 2,
Copy = 3,
CopyVSync = 4,
}
}

I disassembled your code. It looks like you are using SwapEffect.Discard. Can you try using SwapEffect.CopyVSync?
 
Last edited:

htcplussony

Senior Member
Aug 26, 2008
413
32
Hi all. I got a dumb question. Does the Diamond/Touch pro have an hardware 3d accelerator thats actually enabled?
 

gerDiamond

Member
Jul 26, 2008
20
0
This is great, and I think a lot of us would like to look at your code (and we do not all have Koushik's skills at disassembling :D)
Now I'm wondering whether I should learn D3D or openGL...

I might add the possibility to change model/textures, if desired.
Please, please :)
I'd love to have a 3D T-Rex like this one
(even one with less polygons will do ^^)
 

andrec

Member
Aug 16, 2008
32
0
namespace Microsoft.WindowsMobile.DirectX.Direct3D
{
public enum SwapEffect
{
Discard = 1,
Flip = 2,
Copy = 3,
CopyVSync = 4,
}
}

I disassembled your code. It looks like you are using SwapEffect.Discard. Can you try using SwapEffect.CopyVSync?

Thanks, but it doesn't seem to make any difference :(

The sample can be found here if you want to experiment and for those who requested the code:
http://msdn.microsoft.com/en-us/library/ms181024.aspx
 

Koush

Retired Recognized Developer
Sep 21, 2007
917
871
Thanks, but it doesn't seem to make any difference :(

The sample can be found here if you want to experiment and for those who requested the code:
http://msdn.microsoft.com/en-us/library/ms181024.aspx

Couple things I'd also try:

Override OnPaintBackground and remove the base.OnPaintBackground call. There's no point using OnPaintBackground in GDI if D3D is painting. It can cause flickering.

Also, instead of using Device.Clear to clear the background, perhaps try using a polygonal colored/textured background? Device.Clear used to cause flickering behavior on some computer video cards. I think it has something to do with a device Clear not being a true render call, and handled as an asynchronous memset, which causes issues with making render calls immediately after the Clear (ie, part of your rendered image would get cleared). Another common workaround was to Clear the device AFTER the buffers were swapped, and not immediately before painting. The reason that works "better" is because the memset is given more time to complete before the next set of render calls are made. At least that's how it worked ~7 years ago when I was working on the Direct3D team...

I have been trying to reproduce this bug in OpenGL, and can't get it to happen anymore: my code doesn't do either of the things I mentioned.
 
Last edited: