problem with surface

View previous topic View next topic Go down

problem with surface

Post  hazeleye on Wed Sep 24, 2008 1:38 am

Hi,
I have one bad moment ,
In Blender I create surface (for example simple plane) and make it as static (Ctrl+A)
and create object (for example, sphere) - it's dinamic object

Mass of plane = 3000 (for static objects mass not impotant , aren't it ?)
Mass of sphere = 100

Set gravity.z = -10.0f;

Put sphere on the plane (on some distance from it)

Further, when program is running sphere often falls throw surface

If sphere put down to plane, then not often, if put up - very often
If encreaze gravity.z value (for example, -2.0f) - then not often

Would you please explain how i can solve this problem

And other question:

Is impotant the mass of dinamic objects only for collision with dinamic objects or with static objects too?

P.S: Sorry for my english - it's not my native language

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Sep 24, 2008 7:03 pm

I create a quick tutorial for you to understand how what you want to do can be done using Blender / SIO2. I took the tutorial 6 and create a new .sio2 and plug it in instead of the tutorial06.

Heres the link:

http://www.youtube.com/watch?v=7Dk0JQrlbxA&fmt=18


Please read the comments in tutorial06 about how to sync. the physic pass with the rendering pass. What most likely happen in your case is that you are loading so you are basically rendering something like 1fps and then when everything is done you are rendering +20fps so the physic pass cannot sync with the current framerate (which is normal). You can tweak that by reseting the current fps of the SIO2window it'll take like 1 sec to recalculate the avg. fps and then SIO2 will sync the value with the physic pass.


Concerning the mass of static object it really doesn't matter, actually Im ignoring whatever values that have been set and set it 0 (Bullet required that).

As a suggestion, please keep the mass of object relatively low, Bullet suggest 1 unit = 1 kg, and I think it make sense, and SIO2 work with 1 unit is 1m so I makes the perfect combination with real world relative measurements.

Lemme know if you have any other troubles Wink

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Thu Sep 25, 2008 2:52 am

Thank you for the answer
I change fps and sphere not falls throw surface

Now I want rotate one of my objects
For this I do:

plane = (SIO2object *) sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, "object/PlaneMain" );
plane->rot->x = accelerometer.x;
plane->rot->y = accelerometer.y;
sio2ObjectRender(plane, sio2->_SIO2camera, 1);

But plane is not rotate (plane is static)
What's wrong ?

Besides, scale plane is running

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Thu Sep 25, 2008 3:35 am

After applying any type of transformation you need to update the matrix of the object with:

sio2ObjectGetMatrix

If physic is ON you need to use the Bullet function of your choice in order to rotate your plane probably with setAngularVelocity, you can get access to the rigid body handle linked to the sio2Object and apply the rotation like this:

// Make sure that the physic object is not sleeping
_SIO2object->_btRigidBody->setActivationState( ACTIVE_TAG );

// Apply the rotation on the rigid body object
_SIO2object->_btRigidBody->setAngularVelocity( btVector3( rx, ry, rz ) );

But you cannot do that on static objects...

Just out of curiosity what are you trying to do something like supermonkey ball or?
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Thu Sep 25, 2008 4:39 am

sio2interactive wrote:
But you cannot do that on static objects...
But I want rotate static object. For example plane in your last tutorial (under ball)
Is it possible ?

sio2interactive wrote:
Just out of curiosity what are you trying to do something like supermonkey ball or?
I'm not playing in this game. Now I want jast roll a ball over plane with help accelerometer Smile

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Thu Sep 25, 2008 5:14 am

Allright your issue is actually not a SIO2 issue but a Bullet issue, but lemme help ya on that one this is what you should do:


// Affect the desired rotation on your SIO2object
yourplane_SIO2object->rot->x += 0.01f; // 0.01 Degree (here change for whatever you are using, as long that its in degree.)

// Recalculate the SIO2object matrix in worldspace
sio2ObjectGetMatrix( yourplane_SIO2object );


// Assign the transformation matrix using the Bullet API
btTransform trans;
trans.setFromOpenGLMatrix( ( btScalar * )yourplane_SIO2object->mat );
btDefaultMotionState *_btDefaultMotionState = new btDefaultMotionState( trans );

// Get the current motion state and free it.
delete yourplane_SIO2object->_btRigidBody->getMotionState();

// Affect the transformation to the _btRigidBody of your SIO2object
yourplane_SIO2object->_btRigidBody->setMotionState( _btDefaultMotionState );


// Now, here since your are modifying your plane transformation (which is basically the ground)
// you need to force the Bullet rigid body to be activated, you can do this only when the
// rotation of your plane is updated (ie: when the accelerometer change or something)

unsigned int i = 0;

// Loop through all the current SIO2object of the resource manager, basically we should skip
// the plane but since its a static object it doesn't matter Bullet will ignore the activation flag
// anyway.

while( i != sio2->_SIO2resource->n_object )
{
SIO2object *_SIO2object = ( SIO2object * )sio2->_SIO2resource->_SIO2object[ i ];

// Do we have a rigid body handle?
if( _SIO2object->_btRigidBody )
{
// Simply reactivate the flag to make this object part of the
// incoming physic frame.
_SIO2object->_btRigidBody->setActivationState( ACTIVE_TAG );
}

++i;
}
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Thu Sep 25, 2008 10:20 pm

It's working,
thank you

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Fri Sep 26, 2008 5:11 pm

Wink
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Mon Sep 29, 2008 1:22 am

Hi
I have last problem again
I create plane (now it's cube without top poligone or plane with barrier)
And create ball

All run fine untill ball gather speed. When ball move very quickly it's pass through barrier (but ball roll over surface fine)
I set FPS on 300 but it's not help

Now, I think maybe forbid to ball walk over some value and note hope that barrier stop it
But I not know how it's do correctrly. Can you help me ?

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Mon Sep 29, 2008 2:44 am

Please take a look at this thread:

http://forum.sio2interactive.com/sio2-engine-f3/step-simulation-syncing-t9.htm

If it doesn't help can you like post a video on youtube or something to show me the exact symptoms, and send me a sample blend file that is causing problem, it'll help me to fully understand the problem.

Cheers!
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Tue Sep 30, 2008 7:17 am

hi again
there's my project. Please look it and help me Smile

http://dump.ru/file_download/1091542

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Tue Sep 30, 2008 7:35 am

I can't find the .blend...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Tue Sep 30, 2008 11:11 pm

Sorry, here's
http://dump.ru/file_download/1093068

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Oct 01, 2008 1:26 am

Hey man please find your file at the following link:

http://www.sio2interactive.com/balls_MOD.blend.zip

What I did was:

1. Run polygon reducer a few times on the balls cuz they we're really heavy 2000 triangles for a ball that is some really round ball you are going to kill the FPS on the device man Wink The DEMO scene on the homepage does not top more than like 5~6k of triangles when rendering. Take it easy... Wink

2. I link the Scene.sio2 with tutorial06 and comment the camera physic, build and run and all the balls sticks in the box. It's working fine over here...

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Wed Oct 01, 2008 5:47 am

I can't load your link Sad

I run polygon reducer and now in all scene I have 1494 faces
But problem is not disappear

When you tested tutorial6 with Scene.sio2 what gravity value you have ? 10 ? Are you speed up ball? And they not pass through sides edge of cube? My balls sometimes pass through sides Crying or Very sad

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Oct 01, 2008 6:03 am

humm:

http://www.sio2interactive.com/dump/Balls_MOD.blend.zip

I didn't speed up the balls in anyway, just let the gravity do its job... maybe extrude the wall to make them ticker? I really don't know man... its working fine here... I don't know what to say...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Oct 01, 2008 6:05 am

Hey listen up I'll try to write for you a quick project that is doing the same as you intend to do...

Keep your heads up dude, that's what programming is all about, try & error Wink

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Wed Oct 01, 2008 6:19 am

Fine !
by the way for simulate rotate the plane I do that :
Code:

vec3 gravity;
gravity.x =  -accelerometer.y*10.0f;
gravity.y =  accelerometer.x*10.0f;
gravity.z = -10.0f;   

May be sometimes ball pass through sides because gravity is high (gravity.x or gravity.y) But I put sio2->_SIO2window->fps = 100;
....

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Oct 01, 2008 6:26 am

I would not suggest you to manipulate it like that, the gravity is something you assign at initialization and that you are using along the way, try to use bullet API to manipulate the orientation of the ground like I show you in the sample code in a previous post.
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Wed Oct 01, 2008 6:39 am

Why ? It's way is simple and ball behave yourself... Excepting my situation, of cause
But I try to do it your metod ....

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  sio2interactive on Wed Oct 01, 2008 6:00 pm

Well actually I tried just for fun, and my method is not better either, Im stuck with the same problem as you, yesterday when I try I didn't implement the floor rotation. But this morning I did it and well... I have the exact same problem, when the floor rotate sometimes the balls pass right through it...

Im not sure how to fix this problem...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: problem with surface

Post  hazeleye on Mon Oct 20, 2008 5:21 am

If replace btSoftRigidDynamicsWorld with btContinuousDynamicsWorld this bug disappear Wink

hazeleye

Posts : 34
Join date : 2008-09-24

View user profile

Back to top Go down

Re: problem with surface

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum