Attached objects?
4 posters
Attached objects?
I think perhaps this have been answered before but I donīt find it.
Can I attach an object to another (I guess using blender) so both are always together.
Imagine a light attached to a lantern object so as you move the lantern, the light also moves.
Cheers.
Can I attach an object to another (I guess using blender) so both are always together.
Imagine a light attached to a lantern object so as you move the lantern, the light also moves.
Cheers.
Re: Attached objects?
arg! And what about in 1.3.1? or another way, can I attach a light to an object in Blender?
Re: Attached objects?
Ok long story short when you update from 1.3.1 to 1.3.2 and +, independent pos, rot, scl have been replaced by one struct SIO2transform, for camera the struct also contain dir, and tar have been removed as it is not needed.
Dir = Normalize( Target - Position )
Camera does not have rotation, no need for it... just calculate the direction vector and the camera will render in that direction is that simple... you can always calculate it using something like that:
All BindMatrix operation are now passing by sio2TransformBindMatrix in order to have everything unified as 1 struct that can be used by everything and also give you access to parent child matrices with the _SIO2transform->parent handle.
SIO2transform can be used 2 ways sio2TransformRender, that will use the precalculated matrix by a previous sio2TransformBindMatrix or sio2TransformApply that will use a good old glTranslate, glRotate and glScale sequence, the push and pop of the matrix is directly used by the different struct such as camera or object so you don't have to worry about it.
A black screen is usually the result when:
1. You didn't re-export your scene using the latest exporter.
2. You didn't calculate the right dir of the camera or didn't normalize it.
3. If you point directly the camera down the Z axis negating the rotation matrix column. If you want to do that, like a top view game:
- Point the camera down the positive Y axis
- Push the matrix before rendering your resource and rotate it 90 on the X axis then update the camera frustum then render the scene.
4. That's basically it...
Dir = Normalize( Target - Position )
Camera does not have rotation, no need for it... just calculate the direction vector and the camera will render in that direction is that simple... you can always calculate it using something like that:
- Code:
hyp_a = hypotf( dir->x, dir->y );
hyp_b = hypotf( hyp_a, dir->z );
rot->x = asinf( dir->z / hyp_b ) * SIO2_RAD_TO_DEG;
rot->z = asinf( dir->x / hyp_a ) * SIO2_RAD_TO_DEG;
if( dir->y < 0.0f )
{ rot->z += 180.0f; }
else
{ rot->z = 360.0f - rot->z; }
rot->z += 90.0f;
rot->z = sio2RoundAngle( rot->z );
All BindMatrix operation are now passing by sio2TransformBindMatrix in order to have everything unified as 1 struct that can be used by everything and also give you access to parent child matrices with the _SIO2transform->parent handle.
SIO2transform can be used 2 ways sio2TransformRender, that will use the precalculated matrix by a previous sio2TransformBindMatrix or sio2TransformApply that will use a good old glTranslate, glRotate and glScale sequence, the push and pop of the matrix is directly used by the different struct such as camera or object so you don't have to worry about it.
A black screen is usually the result when:
1. You didn't re-export your scene using the latest exporter.
2. You didn't calculate the right dir of the camera or didn't normalize it.
3. If you point directly the camera down the Z axis negating the rotation matrix column. If you want to do that, like a top view game:
- Point the camera down the positive Y axis
- Push the matrix before rendering your resource and rotate it 90 on the X axis then update the camera frustum then render the scene.
4. That's basically it...
Re: Attached objects?
1. You didn't re-export your scene using the latest exporter.
I did. This is not the problem.
2. You didn't calculate the right dir of the camera or didn't normalize it.
Can you explain it a little more?
This is my code:
- Code:
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
sio2WindowEnterLandscape3D();
{
sio2CameraUpdateListener( sio2->_SIO2camera );
sio2CameraRender( sio2->_SIO2camera );
if( tap_select )
{
.
.
.
}
if (selection) {
.
.
.
}
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
sio2CameraUpdateFrustum( sio2->_SIO2camera );
sio2ResourceCull( sio2->_SIO2resource,
sio2->_SIO2camera );
sio2ResourceRender( sio2->_SIO2resource,
sio2->_SIO2window,
sio2->_SIO2camera ,
SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_CLIPPED_OBJECT | SIO2_RENDER_ALPHA_OBJECT );
}
sio2WindowLeaveLandscape3D();
I update the camera perspective just after getting it:
- Code:
sio2->_SIO2camera = ( SIO2camera * )sio2ResourceGet( sio2->_SIO2resource,
SIO2_CAMERA,
"camera/IntroCamera" );
sio2CameraSetPerspective( sio2->_SIO2camera, sio2->_SIO2window );
How do I calculate the right dir and normalize it?
3. If you point directly the camera down the Z axis negating the rotation matrix column.
Not the case.
Cheers.
Re: Attached objects?
This code point straight to my player object wherever this object is:
- Code:
// tmp is whatever distance or position offset I want...
sio2Vec3Add( _SIO2player->player->_SIO2transform->loc,
&tmp,
sio2->_SIO2camera->_SIO2transform->loc );
sio2Vec3Diff( _SIO2player->player->_SIO2transform->loc,
sio2->_SIO2camera->_SIO2transform->loc,
sio2->_SIO2camera->_SIO2transform->dir );
sio2Normalize( sio2->_SIO2camera->_SIO2transform->dir,
sio2->_SIO2camera->_SIO2transform->dir );
Re: Attached objects?
Not working
Iīve pasted just before updating camera frustrum:
Iīve tried without your code, traced execution and in sio2resourcecull the camera and all scene objects location and direction is the same as in my blender scene but the objectsīs dst value in sio2resourcerender is 0. sio2resourcecull is unreadable enough to stop me trying to trace it.
Lights are not enabled but as far I can see in tutorials thereīs no need of enabling it (just thinking about possible causes).
Iīm draining my brain but I donīt see why all objects have a dst value of 0.
Cheers.
Iīve pasted just before updating camera frustrum:
- Code:
vec3 tmp;
tmp.x = 10.0f;
tmp.y = 10.0f;
tmp.z = 10.0f;
SIO2object *_Object = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, "object/Skydome" );
// tmp is whatever distance or position offset I want...
sio2Vec3Add( _Object->_SIO2transform->loc,
&tmp,
sio2->_SIO2camera->_SIO2transform->loc );
sio2Vec3Diff( _Object->_SIO2transform->loc,
sio2->_SIO2camera->_SIO2transform->loc,
sio2->_SIO2camera->_SIO2transform->dir );
sio2Normalize( sio2->_SIO2camera->_SIO2transform->dir,
sio2->_SIO2camera->_SIO2transform->dir );
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
sio2CameraUpdateFrustum( sio2->_SIO2camera );
sio2ResourceCull( sio2->_SIO2resource,
sio2->_SIO2camera );
Iīve tried without your code, traced execution and in sio2resourcecull the camera and all scene objects location and direction is the same as in my blender scene but the objectsīs dst value in sio2resourcerender is 0. sio2resourcecull is unreadable enough to stop me trying to trace it.
Lights are not enabled but as far I can see in tutorials thereīs no need of enabling it (just thinking about possible causes).
Iīm draining my brain but I donīt see why all objects have a dst value of 0.
Cheers.
Re: Attached objects?
Can you guys please make sure to paste the solution?
;-)
-joshua
;-)
-joshua
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: Attached objects?
Ok, I'm confused. Where does SIO2player come from??
Is this only in the SVN version?
Thanks,
-j
Is this only in the SVN version?
Thanks,
-j
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: Attached objects?
I guess SIO2player itīs just a sample
Iīm afraid, sio2interactive, I canīt send you the code but all the relevant part is just copied before.
Iīm afraid, sio2interactive, I canīt send you the code but all the relevant part is just copied before.
Re: Attached objects?
sample of what?
>_<
>_<
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: Attached objects?
iphoniac just create a simple project and copy paste the necessary blocks as well as the one that causes problem, for the model just create something quick with blender... cuz what you post is not enough for me to draw any conclusion...
Re: Attached objects?
Is there any support to make this parent-child-relationship a bit springy and use some physics?
basco- Posts : 12
Join date : 2009-02-01
Similar topics
» duplicating objects at runtime and changing textures on the duplicated objects
» Duplicating an object with sound attached
» Particle system - vel/dir vector attached to particle
» Static Objects
» Parenting Objects
» Duplicating an object with sound attached
» Particle system - vel/dir vector attached to particle
» Static Objects
» Parenting Objects
Permissions in this forum:
You cannot reply to topics in this forum