• 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
8/2/2012 8:58 AM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 
Hi
Now I am computing collisionmodels and everything in the contentpipeline and everything works just great! However there is 90MB memory limit requirement for Windows Phone 7 applications and I was wondering could I shave a little bit memory off from CompressedAabbTree. Requirement is not that much but every bit helps. It seems that CompressedAabbTree uses memory extensively. I am betting that I could reduce it like 20% and there would not be any noticeable difference. I tried this in content pipeline by setting BottomUpBuildThreshold (CompressedAabbTree) for to something smaller (e.g. 100) but it did not have any effect.

It there a way to do this and do you have any other tips to save memory (not sacrificing performance too much). E.g. I have lot of tall buildings we no not need collision detection in the upper parts of the buildings. Now since collision model is calculated directly from 3D model there is a lot of reducancy. Does Simulation create temp datastructures that I could clear out now and then?
 
New Post
8/2/2012 1:40 PM
 
HelmutG
6th Level Poster

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

The BottomUpBuildThreshold is used to choose which method is used to build the tree. A high value produces more balanced trees (faster at runtime), but it takes more time to build the tree. A low threshold can produce less balanced trees (slower at runtime), but building the tree is faster. I think this property has no influence on the used memory.

Usually games use a detailed mesh for the 3D graphics and a separate mesh for the collision objects. This saves memory and improves performance  if the collision mesh is simpler than the original 3D model. In the collision mesh you can leave out the triangles which you do not need (e.g. upper parts of the buildings). Often you can replace several triangles with a few larger triangles.

To save memory you can also try to use simpler shapes, e.g. a BoxShape or SphereShape instead of convex hulls, or height maps instead of triange mesh shapes.

Between levels of your game you can call ResourcePool.ClearAll()  to clear all used resource pools. Additionally, you can release all references to the existing Simulation and the existing rigid bodies, call the garbage collector (GC.Collect()) and then create a new Simulation. This way each level starts in a clean state.

 
New Post
8/17/2012 9:25 AM
 
juhanay
No Ranking

Joined: 8/14/2011
Posts: 21
Re: Loading textures with rigid bodies (VehicleSample) 
Hi
The idea is to calculate collisionmodel directly from the .X file as (shown in the example), but then with particular meshes use more simple mesh structure using digitalrune shapes. Calculate the collision model with the simplified meshes.

In the collisionmodel processor in the contentpipeline, I want to replace some of the meshes (from .x file) with digirune object (e.g. Shapes, cylindershape namely). Now In order to do this, i need to get triangle mesh for the shape and also transport the new triangle mesh to a particular world location (coordinates).


How to do both of those things ( I think that I can do the first part´, with getMesh), but how to transform that mesh to correct world coordinates?
 
New Post
8/18/2012 12:19 PM
 
HelmutG
6th Level Poster

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

Hi, as I understand, you want to get the mesh for a cylinder and move the vertices of the mesh to a different position? Is this correct?

You can use CylinderShape.GetMesh() to get a triangle mesh that represents the cylinder. Then you can call TriangleMesh.Transform() to translate the vertices.
Alternatively, you can use the TransformedShape to add a translation to a cylinder, and get then get the translated mesh using TransformedShape.GetMesh().

However, I don't understand why you need to perform this operations. Seems to me like you want to use the mesh of the cylinder for collision detection. But you could use the CylinderShape for collision detection directly?

 
New Post
8/19/2012 12:29 PM
 
juhanay
No Ranking

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

Hi

I am building collisiondetection model in contentpipeline and storing it in the tag-field of Model -class (just like in your example). This is due to the fact that calculating the collision model is expensive timewise and it is best done at build time. In the game the collision model works great. Now I just want to modify the combined collision model (which is stored in tag) a bit for gameplay reasons (e.g. you can drive through tree branches and plants)
I thought that this is best to do in the contentPipeline, where I read one single world 3D model (.x) and I just modify meshes a bit to make them more simple for collision detection purposes (I know which meshes need to be replaced with certain type of objects, here just cylinders.) So i plan to replace certain meshes with more simper object e.g. with a cylinder. I just need to position the cylinder in the same world position as the original object. Somehow the below code do not work, that well.  (I have simplified the below code a bit)

01.foreach (var mesh in meshes)
02.{
03.   Matrix transform = mesh.AbsoluteTransform;
04.     for (int i = 0; i < mesh.Positions.Count; i++)
05.        mesh.Positions[i] = Vector3.Transform(mesh.Positions[i], transform);
06. 
07.   // Here is the tricky stuff!
08.   CylinderShape tempShape = new CylinderShape(1f,100);
09.   TriangleMesh d = tempShape .GetMesh(0.1f, 100);
10.   d.Transform(Matrix44F.FromXna(transform));
11.   triangleMesh.Add(d, false);
12.}
13........
14. 
15.triangleMesh.WeldVertices();
16.CompressedAabbTree s = new CompressedAabbTree();
17.TriangleMeshShape triangleMeshShape = new TriangleMeshShape(triangleMesh, true, s);



 
New Post
8/19/2012 2:44 PM
 
juhanay
No Ranking

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

One additional question. I need to disable collisions between one particular type of Rigidbodies. Could I just say somewhere that all collisions are disabled for all objects belonging to a particular collsiongroup N, so that  rigidbodies which are assigned to this N group will not collide with each other, but all other collisions are enabled (e.g. other objects (from other collision groups  will collide with N)) .

How to do it in the most efficient way? By using Simulation.CollisionDomain.CollisionDetection.CollisionFilter.Filter() ?


 
New Post
8/20/2012 10:40 AM
 
HelmutG
6th Level Poster

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

Regarding the code snippet: Have you verified that transform (mesh.AbsoluteTransform) contains the correct translation? The meshes could be stored relative to the model origin. Then transform would be the identity matrix.

The code converts the CylinderShape to a triangle mesh. Triangle meshes are very inefficient for collision detection. I recommend to use the CylinderShape for collision detection without converting it to a mesh. You can use a CompositeShape to create collision shape which consists of different other collision shapes (TriangleMeshShape and CylinderShapes).

juhanay wrote:

One additional question. I need to disable collisions between one particular type of Rigidbodies. Could I just say somewhere that all collisions are disabled for all objects belonging to a particular collsiongroup N, so that  rigidbodies which are assigned to this N group will not collide with each other, but all other collisions are enabled (e.g. other objects (from other collision groups  will collide with N)) .

How to do it in the most efficient way? By using Simulation.CollisionDomain.CollisionDetection.CollisionFilter.Filter() ?

Yes, the collision filter was designed for this case. Use RigidBody.CollisionObject.CollisionGroup to assign a rigid body to group n. You can use the collision filter to disable collisions between groups or within a group, for example:

var filter = (ICollisionFilter)Simulation.CollisionDomain.CollisionDetection.CollisionFilter;
filter.Set(n, n, false);

 
 Page 3 of 3
Previous123 
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