Can't scale 3D model

Sep 1, 2009 at 5:31 AM

Hi Ohan,

I've tried to add a robot model exported from 3D studio as a .fbx file, but when I change its scale, only the bounding box for collision detection changes, the model still appears with its original size. Is there anything wrong with my code?


        public static Robot AddRobot(Scene scene, MarkerNode groundMarkerNode, ContentManager Content)
        {

            ModelLoader loader = new ModelLoader();
            Model robotModel = (Model)loader.Load("", "robot");           

            GeometryNode robotNode = new GeometryNode("Robot");
            robotNode.Model = robotModel;
            robotNode.Model.UseInternalMaterials = true;           
            robotNode.Model.CastShadows = true;
            robotNode.Model.ReceiveShadows = true;

            NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine;

            Robot robot = new Robot(robotNode, physicsEngine);
            for (int i = 0; i < 4; i++)
                robot.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i), robot.TireTransformNode[i], robotNode, scene.PhysicsEngine.Gravity);

            robot.Collidable = true;
            robot.Interactable = true;

            robotNode.Physics = robot;
            robotNode.Physics.NeverDeactivate = true;
            robotNode.AddToPhysicsEngine = true;           
           
            TransformNode transNode = new TransformNode();
            transNode.Translation = new Vector3(15, 50, 35);       
            transNode.Scale = new Vector3(100);
            transNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)) * Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90));

            groundMarkerNode.AddChild(transNode);            
            transNode.AddChild(robotNode);

            Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld, robot.LeaveWorldCallback);

            return robot;
        }

Coordinator
Sep 3, 2009 at 2:46 AM

Hi,

Please send me the entire project so I can take look at it. The model scaling works fine for me, so I don't know what's wrong with yours.

 

Thanks

Ohan

Sep 3, 2009 at 9:07 PM

Hi Ohan,

Since my project works with different classes and different files, it would be easier if i send you my project attached to an email. Do you have an email address where I can send you my entire project?

I tried to scale different models also, some of then works just fine, but others I found the same problem. I was wondering if this issue with model scaling has any connection with the 3D Studio Max fbx exporter.

Thanks

Emerson

Coordinator
Sep 4, 2009 at 2:14 PM

Hi Emerson,

Hmm... Interesting. I'm wondering if you can scale those models in pure XNA code (without using Goblin). If you Goblin's Model class's Render method, it simply iterates throught each of the loaded ModelMeshPart, and pass the vertices & indices information to the shader, so it should be able to scale for any .fbx models.

Please send your zipped project to ohan@cs.columbia.edu and please make sure to zip it with a password like "123" (my cs email is forwarded to my gmail and gmail doesn't like any .dll or .exe files, with the password, gmail can't check the contents of the zip file).

I'm quite busy with the preparation for next Goblin release (v3.3) which includes a new marker tracking support, so I don't know when exactly I will be able to check the problem though... 

Thanks