Scaling a Wheeled Vehicle
by Steve Lamperti · in Torque Game Engine · 07/15/2005 (11:31 am) · 16 replies
I'm trying to use the SceneObject::setScale method on a wheeled vehicle. The produces interesting results, as the wheels don't scale.
Does anyone know of a resource, or a have a suggestion as to how to do this? I tried overriding setScale in my wheeledVehicle object, but I'm not sure how to tell the wheels that they should scale, as they are not SceneObjects themselves.
Does anyone know of a resource, or a have a suggestion as to how to do this? I tried overriding setScale in my wheeledVehicle object, but I'm not sure how to tell the wheels that they should scale, as they are not SceneObjects themselves.
#2
07/19/2005 (4:55 pm)
Call glScale in the wheel render code?
#3
07/19/2005 (5:07 pm)
The wheels are not just being rendered the wrong size, but are also still being rendered in the wrong places, and the bounding box for the vehicle doesn't change. For example if I scale a car to half size, the body of the car scales fine, but there four wheels in their original positions, surrounding the car at a distance. The object still works fine, but looks quite odd.
#4
I've been trying to come up with some code in the setScale of my wheeled vehicle override, and I'm not having much luck, but it's clear from the fact that it's easy to reproduce this in the demo that it's a TGE question, not just one in my project, so I'm hoping someone else has encountered it before.
07/20/2005 (10:45 am)
If anyone is curious, this is not just a problem with my project. I just launched the demo, and went into the editor in the racing example. When I select the buggy, change the scale numbers in the transform to .5 .5 .5, and click on the apply button, I see exactly the same thing that I see in my project. The vehicle body scales, but the wheels dont. (Both position of the wheels, and size, fail to scale.)I've been trying to come up with some code in the setScale of my wheeled vehicle override, and I'm not having much luck, but it's clear from the fact that it's easy to reproduce this in the demo that it's a TGE question, not just one in my project, so I'm hoping someone else has encountered it before.
#5
07/20/2005 (11:12 am)
Wheels are DTS Shapes mounted to the vehicle if i'm not mistaken. So you'll need to make a way to scale the dts shape, or do what Ben sugested.
#6
If you're just scaling the mesh, your wheel placement will never be correct.
As was stated, the wheels are seperate objects that are added onto the vehicle at runtime.
You'll have to scale them seperately - but getting their placement correct will require manipulating the nodes to which they get mounted.
07/20/2005 (11:16 am)
Does your scaling method account for the placement of the mount nodes?If you're just scaling the mesh, your wheel placement will never be correct.
As was stated, the wheels are seperate objects that are added onto the vehicle at runtime.
You'll have to scale them seperately - but getting their placement correct will require manipulating the nodes to which they get mounted.
#7
I have this code in my override of WheeledVehicle, but I think (once there is code that makes sense,) this should be in wheeled vehicle itself.
07/20/2005 (11:31 am)
Here's the code I was trying to write. I think this is a reasonable approach, but I really don't know how to do the last step.I have this code in my override of WheeledVehicle, but I think (once there is code that makes sense,) this should be in wheeled vehicle itself.
void ExtendWheeledVehicle::setScale(const VectorF & scale)
{
// JSL - scale the wheels
if (mDataBlock && mWheel)
{
mObjScale = scale;
Wheel* wend = &mWheel[mDataBlock->wheelCount];
for (Wheel* wheel = mWheel; wheel < wend; wheel++)
{
if (wheel->shapeInstance)
{
// don't know what to do here to actually scale the wheels
}
}
}
SceneObject::setScale(scale);
}
#8
09/11/2006 (5:22 pm)
Can i scale the wheel by using script
#9
I never figured out this question, so I am not sure what the answer to your question is.
09/11/2006 (5:34 pm)
Abdullah, I never figured out this question, so I am not sure what the answer to your question is.
#10
add this line in our wheeledvehicle.cpp after dglMultMatrix(&getRenderTransform()); line no 1413
"glScalef(mObjScale.x,mObjScale.y,mObjScale.z);//size transform "
but this doesn't solve collision box resizing
do any one have solution for collision
01/22/2007 (11:41 pm)
Steve add this line in our wheeledvehicle.cpp after dglMultMatrix(&getRenderTransform()); line no 1413
"glScalef(mObjScale.x,mObjScale.y,mObjScale.z);//size transform "
but this doesn't solve collision box resizing
do any one have solution for collision
#11
Thanks for your reply to this post. What you suggest does scale the wheels correctly, in size, but it doesn't effect the position of the wheels. They are still located outside the body of the car in their original position, and as you mentioned, it would not effect the collision box either.
I had dropped this a while ago, and never got back to it, but I am still surprised that no one else has tried to scale the vehicles in stock torque.
01/23/2007 (9:15 am)
Roshan,Thanks for your reply to this post. What you suggest does scale the wheels correctly, in size, but it doesn't effect the position of the wheels. They are still located outside the body of the car in their original position, and as you mentioned, it would not effect the collision box either.
I had dropped this a while ago, and never got back to it, but I am still surprised that no one else has tried to scale the vehicles in stock torque.
#12
03/07/2007 (4:53 pm)
We are getting closer to release on our project, so I am considering this question again. Does anyone have any thoughts? As I mentioned above, this is reproducible in stock torque.
#13
Also (Doh!) this is exactly the suggestion that Ben made way back when in the beginning of this thread.
07/06/2007 (3:18 pm)
Revisiting this again. Turns out I had done something stupid with Roshan's suggestion, and had put it in the wrong place. In the right place, it does exactly the right thing visually with the wheels and the rest of the car body, but as he mentioned, it doesn't deal well with the collision box, which makes the car deal with the terrain and other objects as if it were not resized. I will try to come up with some code that corrects this, and if I do, I will post it here.Also (Doh!) this is exactly the suggestion that Ben made way back when in the beginning of this thread.
#14
Thanks!!!
04/13/2009 (8:16 pm)
Hello Steve, I need scale two wheels on the vehicle and the other two remain the same size. Do you have any idea how can I do that?Thanks!!!
#15
Sorry Edmar, I am not the right person to ask. I never really got this working brilliantly, and haven't looked at the code involved with it in quite a while.
04/14/2009 (9:53 am)
@Edmar,Sorry Edmar, I am not the right person to ask. I never really got this working brilliantly, and haven't looked at the code involved with it in quite a while.
#16
I discovered this when I developed the I.E.D gunTruck for the CombatStarterKit. I built my vehicle to exact mfg specs and animated it accordingly at that scale. When the vehicle was loaded into a mission; all animations were as I constructed them before export. The hub 'Z' displacement was exactly the same distance as I'd animated. Now, here's the rub with this....
Once inside the engine, the vehicle was not scaled 'large' enough for the avatars used...! So, rather than rescale all my Source geometry[since it IS the correct specs], I began to Export Scale the entire shape at say a factor of 1.4.
Now, when I looked at this newly scaled shape inside the engine...the animations for hub displacement were 'off'...not ending up where I animated them, as the datablock was setup for the 'mfg' specs. I found I had to go back and multiply my datablock values by my Export Scale Factor to match the new scale of vehicle. I would imagine that dynamically scaling with the engine would produce these proportional results, mis-aligning geometry and datablock.
My suggestion for this Threads issue is to build your wheel geometry to the correct Scale in your modeling program and export again, keeping all objects at same Export Scale Factor.
Change your art asset....don't try to 'fix' art with code!!!! My 3 cents.
This is why I always suggest to build your shapes to correct scale outside the engine and never begin to jizzle with 'coding' the correct size. It may take a little more R/D to get proper mesh scale FIRST, but I think that extra time will be picked up on the backEnd of the shape work; IE, not having to rescale after animating....everybody is so 'busy' to get animating....do yer math first!! I say....
04/16/2009 (5:28 am)
I found that scaling a vehicle will produce odd results if animated first, as the geometry resizes, while the datablock remains 'constant'.I discovered this when I developed the I.E.D gunTruck for the CombatStarterKit. I built my vehicle to exact mfg specs and animated it accordingly at that scale. When the vehicle was loaded into a mission; all animations were as I constructed them before export. The hub 'Z' displacement was exactly the same distance as I'd animated. Now, here's the rub with this....
Once inside the engine, the vehicle was not scaled 'large' enough for the avatars used...! So, rather than rescale all my Source geometry[since it IS the correct specs], I began to Export Scale the entire shape at say a factor of 1.4.
Now, when I looked at this newly scaled shape inside the engine...the animations for hub displacement were 'off'...not ending up where I animated them, as the datablock was setup for the 'mfg' specs. I found I had to go back and multiply my datablock values by my Export Scale Factor to match the new scale of vehicle. I would imagine that dynamically scaling with the engine would produce these proportional results, mis-aligning geometry and datablock.
My suggestion for this Threads issue is to build your wheel geometry to the correct Scale in your modeling program and export again, keeping all objects at same Export Scale Factor.
Change your art asset....don't try to 'fix' art with code!!!! My 3 cents.
This is why I always suggest to build your shapes to correct scale outside the engine and never begin to jizzle with 'coding' the correct size. It may take a little more R/D to get proper mesh scale FIRST, but I think that extra time will be picked up on the backEnd of the shape work; IE, not having to rescale after animating....everybody is so 'busy' to get animating....do yer math first!! I say....
Torque Owner Steve Lamperti
Imagine That!