• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineLoading textures with rigid bodies (VehicleSample)Loading textures with rigid bodies (VehicleSample)
Previous
 
Next
New Post
5/28/2012 8:38 PM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 

HI

I made more investigations and it turns out that the above threading issue was indeed causing slowdown. It seems that the issue is now resolved. 

 
New Post
5/28/2012 10:00 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Loading textures with rigid bodies (VehicleSample) 

Thank your for this information. This was very helpful.

I made some tests and found a bug in our multithreading classes, which will be fixed in the next release. But since current Windows Phones have only one core, they do not benefit from multithreading and multithreading should be turned off anyway (which is also the default setting on the Windows Phone).

Some quick background info for the interested readers:
Internally we have a collection that stores tasks for the current thread (Thread.CurrentThread). But on Windows Phone it seems that the object returned by Thread.CurrentThread is not persistent - unlike on other platforms. Therefore the collection was constantly growing. This caused the slow down on the Windows Phone.

 
New Post
7/6/2012 7:37 AM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 

Hi again!
The game is advancing fine but I do have a question.

I added RigidBodies to the game as objects that the car can collide with. It seems that if I add RigidBodes with the following code (and all required rendering code)

SphereShape sphereShape = new SphereShape(0.5f);
             for (int i = 0; i < 40; i++)
             {
                 Vector3F position = RandomHelper.Random.NextVector3F(-60, 60);
                 position.Y = 26;
                 AddBody("Sphere" + i, new Pose(position), sphereShape, MotionType.Dynamic);
             }


Everything works just fine.  I have coded my own loading function based on car loading function (and uses different rendering code as well):


... (code omitted)
var ma = MassFrame.FromShapeAndMass(meshCollisionShapeX, Vector3F.One, obj.mass, 0.1f, 10)

RigidBody trackObject = AddBody(obj.name, (obj.getMeshLocation(rataPose.ToXna())), new BoxShape(10.0f, 5.0f, 5.0f), MotionType.Dynamic);
// Or Alternatively new RigidBody(new BoxShape(10.0f, 5.0f, 5.0f)
  {

                    Name = obj.name,
                    Pose = obj.getMeshLocation(rataPose.ToXna()),
                    MotionType = MotionType.Dynamic,
                };


                obj.initialPosition = new Pose(trackObject.Pose.Position);
                trackObject.CollisionResponseEnabled = true;
                trackObject.CcdEnabled = true;
               SmartLoader.Simulation.RigidBodies.Add(trackObject);


Above code somehow does not provide good results. I can see the objects but objects move quite differently that the objects that are loaded with the earlier code. Objects are quite unstable and move quite unexpectedly. They can drop through the world or shoot to the sky. If I add mass or friction I can actually make them to stay in one place but then it is difficult for a car to move these objects at all (by hitting them). Earlier objects work just fine when car hits them. So what could be the difference between these to pieces of code?

 
New Post
7/6/2012 10:45 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Loading textures with rigid bodies (VehicleSample) 

Good to hear that you are making progress.

I am a bit confused by the two code snippets. In the second snippet, you are creating a mass frame, but from your code snippet I cannot see if and where you are using this mass frame?

If a mass frame is computed for complex shapes (e.g. a triangle mesh), then it can happen that the resulting inertia tensor makes the object unstable. This happens especially for shapes with long, thin parts. To avoid such inertia tensor problems, you can try to compute the mass frame from the AABB of the shape or its bounding sphere, and use this mass frame instead of the exact mass frame.

The only other relevant difference of the code snippets which I see is that your are enabling CCD in the second snippet - but this shouldn't cause instabilities.

 
New Post
7/13/2012 7:28 AM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample)  Modified By juhanay  on 7/13/2012 7:30:14 AM

Hi

I have now more important issue issue.It takes a quite a while dynamically calculate collision model thus am now attempting to  build the triangle mesh and the AABB tree in the XNA content pipeline and avoid the building of the tree at runtime (see Sample 33). However i have run into problems

I have added contentpipeline extension  to my WP7 project (I have two content pipeline extensions one for this and one for skybox), then I have XNA project and silverlight project and Contents (5 projects in my solution).

No matter what I get the following error message

Error 2 The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.    ****Stuff taken away** CollisionModelProcessor.cs 69 25 ContentPipelineExtension2 , (The cause of this is Vector3F?)

This could be somekind of library clash between different projects but I have tried to add System.Xml (different versions) and System.xml.serializable. My Assembly references should be fine but they are not, and my using statements should be fine too. Could it be what I am mixing code/dlls from windows and Windows Phone?


 
New Post
7/13/2012 10:08 AM
 
MartinG
7th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 446
Re: Loading textures with rigid bodies (VehicleSample) 

The Content project needs to reference:

  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Mathematics.Content.Pipeline.dll
  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Geometry.Content.Pipeline.dll
  • ContentPipelineExtension2

The ContentPipelineExtension2 project needs to reference:

  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.dll
  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Mathematics.dll
  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Geometry.dll
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll

I think with these settings it should work fine.

 
New Post
7/13/2012 3:45 PM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 

Hi
The issue is not with the above references since they are already in.I just keep getting the error.

My problem is similar to the following

http://forums.silverlight.net/t/22116... 

 
New Post
7/13/2012 6:27 PM
 
MartinG
7th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 446
Re: Loading textures with rigid bodies (VehicleSample) 

According to your previous post the error is caused by the project ContentPipelineExtension2, correct?

Content pipeline extensions are Windows projects - even if the content is built for Xbox 360 or WP7. So it should be a Windows problem, not a Silverlight problem.

If you select a reference in the Solution Explorer the Properties window shows the path and runtime version of the assembly. 
You can compare the references in your projects with our sample projects: 
<DIGITALRUNE_FOLDER>\Samples\DigitalRune.Geometry\XNA Content Pipeline Samples

 
New Post
7/13/2012 8:47 PM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 

Hi and thanks!

I managed to track down the reason what caused the issue. The problem was that I have Windows Phone 7 project and apparently ContentPipeline likes to work with  DigitalRune libraries that are build for \.NET Framework\v3.5 and not for \Windows Phone\v7.0 libraries. I added .Net libraries to Contentpipeline extension and it did build (Made some minor modifications).

Now unfortunately this did not resolve all my problems. Now I can select CollisionModel as content processor and it seems everything is fine. Now when I set collisionModel as a contentprocessor for .x file and build the project I get the following error message (for each  .x file).

Error    2    Building content threw ArgumentException: Cannot serialize type System.Func`2[System.Int32,DigitalRune.Geometry.Shapes.Aabb]. Delegates are not supported.
   at Microsoft.Xna.Framework.Content.Pipeline.TypeHandlerFactory`1.CreateHandler(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentTypeWriterFactory.CreateWriter(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.GetTypeWriterInternal(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.GetTypeWriter(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ReflectiveWriterMemberHelper.Initialize(ContentCompiler compiler, PropertyInfo propertyInfo)
   at Microsoft.Xna.Framework.Content.Pipeline.MemberHelperBase`1.TryInitialize(TSerializer serializer, Type declaringType, PropertyInfo propertyInfo)
   at Microsoft.Xna.Framework.Content.Pipeline.MemberHelperBase`1.CreateMemberHelpers[TDerived](TSerializer serializer, Type declaringType, List`1 memberHelpers)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ReflectiveWriter.Initialize(ContentCompiler compiler)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentTypeWriter.DoInitialize(ContentCompiler compiler)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.InitializeTypeWriter(ContentTypeWriter writer)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.GetTypeWriterInternal(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.GetTypeWriter(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ReflectiveWriterMemberHelper.Initialize(ContentCompiler compiler, PropertyInfo propertyInfo)
   at Microsoft.Xna.Framework.Content.Pipeline.MemberHelperBase`1.TryInitialize(TSerializer serializer, Type declaringType, PropertyInfo propertyInfo)
   at Microsoft.Xna.Framework.Content.Pipeline.MemberHelperBase`1.CreateMemberHelpers[TDerived](TSerializer serializer, Type declaringType, List`1 memberHelpers)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ReflectiveWriter.Initialize(ContentCompiler compiler)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentTypeWriter.DoInitialize(ContentCompiler compiler)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.InitializeTypeWriter(ContentTypeWriter writer)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.GetTypeWriterInternal(Type type)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentWriter.GetTypeWriter(Type type, Int32& typeIndex)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentWriter.WriteObject[T](T value)
   at Microsoft.Xna.Framework.Content.Pipeline.Processors.ModelContent.Write(ContentWriter output)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ModelWriter.Write(ContentWriter output, ModelContent value)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentTypeWriter`1.Write(ContentWriter output, Object value)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentWriter.InvokeWriter[T](T value, ContentTypeWriter writer)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentWriter.WriteObject[T](T value)
   at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCompiler.Compile(Stream output, Object value, TargetPlatform targetPlatform, GraphicsProfile targetProfile, Boolean compressContent, String rootDirectory, String referenceRelocationPath)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.SerializeOutputAsset(BuildItem item, Object assetData, String outputFilename)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.SerializeAsset(BuildItem item, Object assetData)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
   at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings)    C:\Users\koti\Desktop\JuJu_Race_working\JuJu_Race\JuJu_RaceLibContent\Track1_Parts\track1_extras.x    JuJu_RaceLib

 

So any ideas how to get past this? Or is there another way of generating collision model at buildtime? Perhaps with a Windows application?

 
New Post
7/13/2012 9:53 PM
 
MartinG
7th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 446
Re: Loading textures with rigid bodies (VehicleSample) 

Actually the content pipeline should use the assemblies which are specifically built for XNA: <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86

The new error ("Cannot serialize ...") usually appears when the XNA content pipeline tries to automatically serialize a Shape. But this does not work. Instead the XNA content pipeline needs to use the ContentWriters defined in the DigitalRune content pipeline assemblies.

Please check whether your Content project references the DigitalRune content pipeline assemblies:

  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Mathematics.Content.Pipeline.dll
  • <DIGITALRUNE_FOLDER>\References\XNA\v4.0\Windows\x86\DigitalRune.Geometry.Content.Pipeline.dll
 
 Page 2 of 3
Previous123Next 
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineLoading textures with rigid bodies (VehicleSample)Loading textures with rigid bodies (VehicleSample)


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement