Tutorial 09 Player Export Problem
2 posters
Tutorial 09 Player Export Problem
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
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
Re: Tutorial 09 Player Export Problem
Does Tutorial 09's code have a problem with a high polygon environment?
My plane keeps disappearing and appearing back each time i rotate
My plane keeps disappearing and appearing back each time i rotate
vikthered- Posts : 25
Join date : 2009-06-25
Re: Tutorial 09 Player Export Problem
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...
i hope i was clear in explaining
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
Re: Tutorial 09 Player Export Problem
i also copy pasted the tutorial 09 code without changing it...still same problem
vikthered- Posts : 25
Join date : 2009-06-25
Re: Tutorial 09 Player Export Problem
sio2CameraGetProjectionMatrix( sio2->_SIO2camera );
sio2CameraGetModelviewMatrix( sio2->_SIO2camera );
sio2CameraUpdateFrustum( sio2->_SIO2camera );
sio2ResourceCull( sio2->_SIO2resource, sio2->_SIO2camera );
sio2CameraGetModelviewMatrix( sio2->_SIO2camera );
sio2CameraUpdateFrustum( sio2->_SIO2camera );
sio2ResourceCull( sio2->_SIO2resource, sio2->_SIO2camera );
Re: Tutorial 09 Player Export Problem
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
And amazingly the player model is being loaded correctly everytime. Although i shall do some testing tonight and post an update
cheers
vikthered- Posts : 25
Join date : 2009-06-25
Re: Tutorial 09 Player Export Problem
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...
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...
Re: Tutorial 09 Player Export Problem
hehe...actually i have started from scratch and learnt a lot so far....
Thank you
Thank you
vikthered- Posts : 25
Join date : 2009-06-25
Similar topics
» Problem with the physics, specifically through the tutorial 09
» Tutorial 2 and blender export
» Tutorial 2 problem
» Problem in tutorial 02 using my own model
» Light (lamp) problem with tutorial 8
» Tutorial 2 and blender export
» Tutorial 2 problem
» Problem in tutorial 02 using my own model
» Light (lamp) problem with tutorial 8
Permissions in this forum:
You cannot reply to topics in this forum