FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Tutorial 09 Player Export Problem

2 posters

Go down

Tutorial 09 Player Export Problem Empty Tutorial 09 Player Export Problem

Post  vikthered Mon Aug 03, 2009 6:46 pm

Hi,

I'm trying to implement the Third Person Cam Mode similar to tutorial 09. I've put my level in one sio2 file and the "player" in another sio2 file. Although it works, sometimes the player does not show up on the screen. I did a "center new" before exporting but still the problem persists. It works once in a while.

Also once in a whie, when i try rotating or moving the player, the player object disappears! and then appears again after rotating it to a certain random angle. Ive searched the forum for this but everywhere it says to do a "center new".

I've been stuck with this for a couple of days now, I'd be glad if someone help me out.

Thank you

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  vikthered Mon Aug 03, 2009 10:56 pm

Does Tutorial 09's code have a problem with a high polygon environment?

My plane keeps disappearing and appearing back each time i rotate Sad

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  sio2interactive Mon Aug 03, 2009 10:58 pm

Are you updating the necessary matrix for the frustum culling?
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  vikthered Mon Aug 03, 2009 11:06 pm

Yes i have....


I'm not using the accelorometer or "click & drag" as shown in tutorial 09. I have direction keys displayed using a widget.

If the user hits "accelerate key", player/car moves forward

If the user hits "left key", player & world rotate left
If the user hits "right right", player & world rotate right

Inside render function...

Code:

SIO2camera *_SIO2camera = ( SIO2camera * )sio2ResourceGet( sio2->_SIO2resource,  SIO2_CAMERA, "camera/Camera" );
 
 
      if(!_SIO2camera)
      return;
 
      //Bind the camera pointer
      sio2->_SIO2camera = _SIO2camera;
     
     
      sio2Perspective( _SIO2camera->fov,
                  sio2->_SIO2window->scl->x / sio2->_SIO2window->scl->y,
                  _SIO2camera->cstart,
                  _SIO2camera->cend );
 
 
 
     
      sio2WindowEnterLandscape3D();
      {
     
        // Just to show that we can use the physic render
        // function at different location and adjust the
        // sequence according to the type of structure that
        // we want to achieve.
        sio2PhysicRender( sio2->_SIO2physic,
                      sio2->_SIO2window->d_time, 1 );     
       
        // Get the handle of our "player" entity.
        SIO2object *object = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource,
                                                SIO2_OBJECT,
                                                "object/Porsche" );
       
        if( object )
        {
            /*
            Implementation of the camera collision based
            on rigid bodies inside our physic world.
            */
            vec3 tmp_pos;
           
            // Calculate our desire camera position that orbit
            // around an arbitrary point in space (in occurrent our "player").
           
            if(ROTZ_DIR == 1)//That means user clicked left arrow
            {
            ROT_Z+=0.5f;
            CAR_ROTZ = 20.0f;
            }
           
            else if(ROTZ_DIR == -1)//User clicked right arrow button
            {
            ROT_Z-=0.5f; 
            CAR_ROTZ = -20.0f;
           
            }
           
              sio2Rotate3D( object->_SIO2transform->loc, 10.0f, ROT_Z, 15.0f, &tmp_pos );
           
             
            // Set the object angle based on the rotation
            // of our camera in degree.
           
            object->_SIO2transform->rot->z = ROT_Z + CAR_ROTZ;// rotate the car by an extra CAR_ROTZ
           
     
           
           
           
            // Reset the rotation, we want our object to be steady on the XY
            object->_SIO2transform->rot->x =
            object->_SIO2transform->rot->y = 0.0f;
           
           
            // Update the object matrix
            sio2TransformBindMatrix( object->_SIO2transform );
           
           
            // Affect this new matrix to the Bullet
            // rigid body matrix.
            btMatrix3x3 mat3;
           
           
            mat3.setFromOpenGLSubMatrix( (btScalar *)object->_SIO2transform->mat );
           
            object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setBasis( mat3 );
           
           
            // Create a collision ray starting from our player to the camera
            // position. Here we give a little offset to the Z value in order
            // to be right on top of the player head.
            btVector3 from( object->_SIO2transform->loc->x,
                      object->_SIO2transform->loc->y,
                      object->_SIO2transform->loc->z + object->dim->z + 0.1f );
           
            // Our "desired" camera position in world space.
            btVector3 to( tmp_pos.x, tmp_pos.y, tmp_pos.z );
           
            // Execute the collision ray.
            btCollisionWorld::ClosestRayResultCallback ray( from, to );
            sio2->_SIO2physic->_btSoftRigidDynamicsWorld->getCollisionWorld()->rayTest( from, to, ray );
           
           
            // We have a collide into something, our camera cannot be at our
            // desired position so we need to adjust its position to take
            // the same value in worldspace from where our ray intersect with
            // something.
            if( ray.hasHit() )
            {
              // Affect the collision ray XYZ position.
              sio2->_SIO2camera->_SIO2transform->loc->x = ray.m_hitPointWorld.x();
              sio2->_SIO2camera->_SIO2transform->loc->y = ray.m_hitPointWorld.y();
              sio2->_SIO2camera->_SIO2transform->loc->z = ray.m_hitPointWorld.z();             
            }
            else
            {
              // No collision was detected we can then use
              // the values from our "desired" camera position
              sio2->_SIO2camera->_SIO2transform->loc->x = tmp_pos.x;
              sio2->_SIO2camera->_SIO2transform->loc->y = tmp_pos.y;
              sio2->_SIO2camera->_SIO2transform->loc->z = tmp_pos.z;
            }
           
           
            // Update the camera target position, manually keeping
            // in mind our Z offset to point directly on the top of
            // our player head.
            tmp_pos.x = object->_SIO2transform->loc->x;
            tmp_pos.y = object->_SIO2transform->loc->y;
            tmp_pos.z = object->_SIO2transform->loc->z + object->dim->z + 0.1f;
           
           
            // Update the camera direction.
            sio2Vec3Diff( &tmp_pos,
                      sio2->_SIO2camera->_SIO2transform->loc,
                      sio2->_SIO2camera->_SIO2transform->dir );
           
           
            // Make sure that our camera direction is properly normalized.
            sio2Normalize( sio2->_SIO2camera->_SIO2transform->dir,
                      sio2->_SIO2camera->_SIO2transform->dir );
           
           
            // So far we have only be handling our camera, not its time
            // to make our character move into 3D space. If we have a direction
            // coming from the "touchscreen" we simply give a little push to
            // our character in the appropriate direction.
            if( MOV_DIR == 1 )//User click the accelerate button
            {
             
              camera_speed += accel;//increase camera_speed
              // Make sure that our rigid body is activated instead whatever
              // we do would be ignored.
              object->_SIO2objectphysic->_btRigidBody->setActivationState( ACTIVE_TAG );
             
              // Set the linear velocity of our physic object with a push in
              // the right direction.
              object->_SIO2objectphysic->_btRigidBody->setLinearVelocity( btVector3( ( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x ) * camera_speed,
                                                                    ( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->y ) * camera_speed,
                                                                    object->_SIO2objectphysic->_btRigidBody->getLinearVelocity()[ 2 ] ) );
            }
           
            else // User realeased accelerator button
            {
              camera_speed -= decel;
              // Make sure that our rigid body is activated instead whatever
              // we do would be ignored.
              object->_SIO2objectphysic->_btRigidBody->setActivationState( ACTIVE_TAG );
             
              if(camera_speed>0)
              // Set the linear velocity of our physic object with a push in
              // the right direction.
              object->_SIO2objectphysic->_btRigidBody->setLinearVelocity( btVector3( ( 1 * sio2->_SIO2camera->_SIO2transform->dir->x ) * camera_speed,
                                                                    ( 1 * sio2->_SIO2camera->_SIO2transform->dir->y ) * camera_speed,
                                                                    object->_SIO2objectphysic->_btRigidBody->getLinearVelocity()[ 2 ] ) );
              else camera_speed = 0.0f;
                             
           
            }
           
        } 
       
       
       
       
        // Update the position and direction of the
        // listener to OpenAL.
        sio2CameraUpdateListener( sio2->_SIO2camera );
       
        sio2CameraRender( sio2->_SIO2camera );
        {
            sio2CameraGetModelviewMatrix( sio2->_SIO2camera );
           
          [b] sio2CameraUpdateFrustum( sio2->_SIO2camera );[/b]
           
            sio2ResourceCull( sio2->_SIO2resource,
                        sio2->_SIO2camera );       
           
           
            // Render the clipped object just to make
            // that our sound source will be refreshed.
            sio2ResourceRender( sio2->_SIO2resource,
                          sio2->_SIO2window,
                          sio2->_SIO2camera,
                          SIO2_RENDER_SOLID_OBJECT );
           
       
        sio2ObjectReset();
       
        sio2MaterialReset();
       
       
       
       
        sio2WindowLeaveLandscape3D();
      }
 
 


i hope i was clear in explaining

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  vikthered Mon Aug 03, 2009 11:12 pm

i also copy pasted the tutorial 09 code without changing it...still same problem

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  sio2interactive Mon Aug 03, 2009 11:16 pm

sio2CameraGetProjectionMatrix( sio2->_SIO2camera );

sio2CameraGetModelviewMatrix( sio2->_SIO2camera );

sio2CameraUpdateFrustum( sio2->_SIO2camera );

sio2ResourceCull( sio2->_SIO2resource, sio2->_SIO2camera );
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  vikthered Tue Aug 04, 2009 12:04 am

It worked! Thank you.

And amazingly the player model is being loaded correctly everytime. Although i shall do some testing tonight and post an update


cheers Very Happy

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  sio2interactive Tue Aug 04, 2009 2:08 am

Before doing more "testing" as you call, I would suggest you to go through ALL the source code of the tutorials and try to reproduce from scratch all the video tutorials.

You will learn alot...

If you are in a hurry and want a quick crash course 101, for a modest fee, get the iZenGarden source code... Wink
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  vikthered Tue Aug 04, 2009 3:48 am

hehe...actually i have started from scratch and learnt a lot so far.... Very Happy

Thank you

vikthered

Posts : 25
Join date : 2009-06-25

Back to top Go down

Tutorial 09 Player Export Problem Empty Re: Tutorial 09 Player Export Problem

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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