Game Development Community

Shadow on the wall like a shadow on the wall

by Zilla · in · 10/27/2008 (3:18 am) · 11 replies

I added some objects in MyXnaFPS of chapter 13 in the Torque X Builder 3D:

www.gymprojects.ch/zilla/images/3D1.jpg
then I got the following error:

www.gymprojects.ch/zilla/images/3D2.jpg
When I removed the creation of the shadow in the code,

/*
//add a simple shadow component
T3DBlobShadowCasterComponent componentShadow = new
T3DBlobShadowCasterComponent();
componentShadow.SceneGroupName = "PlayerObject";
objPlayer.Components.AddComponent(componentShadow);
*/

then the program compiles but the camera is not attached to the player anymore and there is no more collision with the terrain.

-> check this video: www.youtube.com/watch?v=QHkimJ6sFjk

And when I delete the added objects Torque X Builder 3D, the described errors are still present and I have to delete the whole project and restart it from the original files that John provides.

#1
10/27/2008 (7:41 am)
Zilla -

As you probably know there are two distinct ways to expose your art content, one is the XML serializer, and the other is through code. Torque X Builder 3D modified the XML for your application.

I am betting that Torque X Builder 3D modified your cam or playerobject node and you are also doing it via code.

The addtion of your spheres should not impact the player at all...they should just be other objects in the scene.

Can you submit your entire XML level and your whole create player method....and we can get this worked out.

Sean
#2
10/27/2008 (8:35 am)
Here's the XML

<?xml version="1.0" encoding="UTF-8"?>
<TorqueSceneData>
  <Version>1.0</Version>
  <SceneData>
    <ObjectTypeDeclaration>
      <LockTypes>false</LockTypes>
      <ObjectTypes />
    </ObjectTypeDeclaration>
    <SceneGraph type="GarageGames.Torque.T3D.T3DSceneGraph" name="SceneGraph" />
  </SceneData>
  <Materials>
    <TerrainDetailMaterial type="GarageGames.Torque.Materials.DetailMaterial" name="TerrainDetailMaterial">
      <TextureFilename>data/terrains/SandDetail01</TextureFilename>
      <DetailTextureRepeat>256</DetailTextureRepeat>
      <DetailDistance>50</DetailDistance>
      <EffectFilename>DetailEffect</EffectFilename>
      <IsWireframe>false</IsWireframe>
      <IsReflective>false</IsReflective>
      <IsRefractive>false</IsRefractive>
      <IsTranslucent>false</IsTranslucent>
      <IsAdditive>false</IsAdditive>
    </TerrainDetailMaterial>
  </Materials>
  <Objects>
    <Terrain type="GarageGames.Torque.T3D.XTerrain" name="Terrain">
      <Components>
        <T3DSceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" name="">
          <UseOwnerObjectType>true</UseOwnerObjectType>
          <Visible>true</Visible>
          <VisibilityLevel>1</VisibilityLevel>
          <Position>
            <X>0</X>
            <Y>0</Y>
            <Z>0</Z>
          </Position>
          <Rotation>
            <X>0</X>
            <Y>0</Y>
            <Z>0</Z>
            <W>1</W>
          </Rotation>
          <Scale>
            <X>1</X>
            <Y>1</Y>
            <Z>1</Z>
          </Scale>
        </T3DSceneComponent>
        <T3DRigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent" name="">
          <GravityScale>0</GravityScale>
          <Mass>0</Mass>
          <Kinetic>true</Kinetic>
          <Immovable>true</Immovable>
          <Velocity>
            <X>0</X>
            <Y>0</Y>
            <Z>0</Z>
          </Velocity>
          <RotationScale>1</RotationScale>
          <ResolveCollisions>true</ResolveCollisions>
          <AnimateCollisionOffsets>false</AnimateCollisionOffsets>
          <RenderCollisionBounds>false</RenderCollisionBounds>
        </T3DRigidComponent>
      </Components>
      <Position>
        <X>1028</X>
        <Y>1028</Y>
        <Z>0</Z>
      </Position>
      <HorizontalScale>8</HorizontalScale>
      <VerticalScale>1</VerticalScale>
      <Scale>
        <X>8</X>
        <Y>8</Y>
        <Z>1</Z>
      </Scale>
      <Repeat>true</Repeat>
      <RepeatX>true</RepeatX>
      <RepeatY>true</RepeatY>
      <Visible>true</Visible>
      <Data type="GarageGames.Torque.T3D.TGETerrainData">
        <TerrainFilename>data/terrains/terrain.ter</TerrainFilename>
        <LightMapFilename>data/terrains\lightmap.png</LightMapFilename>
        <TexturePathSubstitution>data/terrains</TexturePathSubstitution>
        <DetailMaterial>TerrainDetailMaterial</DetailMaterial>
      </Data>
      <ViewError>2</ViewError>
      <LODError>0.5</LODError>
      <LevelZeroError>0</LevelZeroError>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </Terrain>
    <TorqueObject type="GarageGames.Torque.Core.TorqueObject" name="Camera">
      <Components>
        <CameraComponent type="GarageGames.Torque.T3D.FreeCameraComponent" name="CameraComponent" />
        <T3DSceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" name="">
          <UseOwnerObjectType>true</UseOwnerObjectType>
          <Visible>true</Visible>
          <VisibilityLevel>1</VisibilityLevel>
          <Position>
            <X>1024</X>
            <Y>1008</Y>
            <Z>300</Z>
          </Position>
          <Rotation>
            <X>0.01749911</X>
            <Y>0</Y>
            <Z>0</Z>
            <W>0.9998469</W>
          </Rotation>
          <Scale>
            <X>1</X>
            <Y>1</Y>
            <Z>1</Z>
          </Scale>
        </T3DSceneComponent>
      </Components>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </TorqueObject>
    <Sky type="GarageGames.Torque.T3D.Sky" name="Sky">
      <Visible>true</Visible>
      <SkyDistance>5</SkyDistance>
      <Sides>
        <string>data\skies\front</string>
        <string>data\skies\right</string>
        <string>data\skies\back</string>
        <string>data\skies\left</string>
        <string>data\skies\top</string>
        <string>data\skies\bottom</string>
      </Sides>
      <RenderBottom>true</RenderBottom>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </Sky>
    <RigidCollisionManager type="GarageGames.Torque.T3D.RigidCollision.RigidCollisionManager" name="RigidManager">
      <MaxUpdateSetp>0.01</MaxUpdateSetp>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </RigidCollisionManager>
    <TorqueObject type="GarageGames.Torque.Core.TorqueObject" name="TorqueObject_21800467">
      <Components>
        <T3DSceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" name="">
          <SceneGroup>PlayerObject</SceneGroup>
          <UseOwnerObjectType>true</UseOwnerObjectType>
          <Visible>true</Visible>
          <VisibilityLevel>1</VisibilityLevel>
          <Position>
            <X>1024</X>
            <Y>1024</Y>
            <Z>301.522</Z>
          </Position>
          <Rotation>
            <X>0</X>
            <Y>0</Y>
            <Z>0</Z>
            <W>1</W>
          </Rotation>
          <Scale>
            <X>1</X>
            <Y>1</Y>
            <Z>1</Z>
          </Scale>
        </T3DSceneComponent>
        <T3DTSRenderComponent type="GarageGames.Torque.T3D.T3DTSRenderComponent" name="">
          <ShapeName>data\shapes\simpleshape\simpleshape.dts</ShapeName>
          <SceneGroupName>PlayerObject</SceneGroupName>
        </T3DTSRenderComponent>
      </Components>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </TorqueObject>
    <TorqueObject type="GarageGames.Torque.Core.TorqueObject" name="TorqueObject_58204539">
      <Components>
        <T3DSceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" name="">
          <SceneGroup>PlayerObject</SceneGroup>
          <UseOwnerObjectType>true</UseOwnerObjectType>
          <Visible>true</Visible>
          <VisibilityLevel>1</VisibilityLevel>
          <Position>
            <X>1020.343</X>
            <Y>1016.307</Y>
            <Z>297.1924</Z>
          </Position>
          <Rotation>
            <X>0</X>
            <Y>0</Y>
            <Z>0</Z>
            <W>1</W>
          </Rotation>
          <Scale>
            <X>1</X>
            <Y>1</Y>
            <Z>1</Z>
          </Scale>
        </T3DSceneComponent>
        <T3DTSRenderComponent type="GarageGames.Torque.T3D.T3DTSRenderComponent" name="">
          <ShapeName>data\shapes\simpleshape\simpleshape.dts</ShapeName>
          <SceneGroupName>PlayerObject</SceneGroupName>
        </T3DTSRenderComponent>
      </Components>
      <Pool>false</Pool>
      <PoolWithComponents>false</PoolWithComponents>
      <IsTemplate>false</IsTemplate>
      <IsPersistent>false</IsPersistent>
      <Notched>false</Notched>
    </TorqueObject>
  </Objects>
</TorqueSceneData>
#3
10/27/2008 (8:36 am)
And this is John's CreatePlayer method:

public void CreatePlayer()
        {
            //find the physics resolver
            RigidCollisionManager rigidManager =
            TorqueObjectDatabase.Instance.FindObject<RigidCollisionManager>("RigidManager");
        
            TorqueObject objPlayer = new TorqueObject();
            objPlayer.Name = "PlayerObject";
            
            T3DSceneComponent componentScene = new T3DSceneComponent();
            componentScene.Position = new Vector3(1024, 1036, 300);
            componentScene.SceneGroup = "PlayerObject";
            objPlayer.Components.AddComponent(componentScene);
            
            T3DTSRenderComponent componentRender = new T3DTSRenderComponent();
            componentRender.ShapeName = @"data\shapes\boombot\orange_player.dts";
            componentRender.SceneGroupName = "PlayerObject";
            objPlayer.Components.AddComponent(componentRender);
            
            //give the player some physics attributes, like gravity and collision
            T3DRigidComponent componentPhysics = new T3DRigidComponent();
            componentPhysics.SceneGroupName = "PlayerObject";
            componentPhysics.GravityScale = 1.5f;
            componentPhysics.Mass = 100.0f;
            componentPhysics.RigidManager = rigidManager;
            componentPhysics.CollisionBody.AddCollisionShape(new CollisionBoxShape());
            objPlayer.Components.AddComponent(componentPhysics);
            
            //add the animation component
            T3DAnimationComponent componentAnimation = new T3DAnimationComponent();
            componentAnimation.SceneGroupName = "PlayerObject";
            objPlayer.Components.AddComponent(componentAnimation);
            
            //add the player movement conmponent
            MovementComponent3D componentMovement = new MovementComponent3D();
            componentMovement.SceneGroupName = "PlayerObject";
            objPlayer.Components.AddComponent(componentMovement);

            /*
            //add a simple shadow component
            T3DBlobShadowCasterComponent componentShadow = new
            T3DBlobShadowCasterComponent();
            componentShadow.SceneGroupName = "PlayerObject";
            objPlayer.Components.AddComponent(componentShadow);
            */
            TorqueObjectDatabase.Instance.Register(objPlayer);
        }
#4
10/27/2008 (1:08 pm)
Zilla -
Ah.
So in your Level XML you will notice that you newly added models have been added to the SceneGroup PlayerObject, this is causing the issue - you can uncomment out the shadows code from CreatePlayer - and rename the SceneGroup simpleshape.dts to something other than PlayerObject and you will be golden!

example:
<TorqueObject type="GarageGames.Torque.Core.TorqueObject" name="TorqueObject_58204539">
  <Components>
    <T3DSceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" name="">            
        <SceneGroup>PlayerObject</SceneGroup>

One thing to note - you were getting the shadow errors because the SimpleShapes did not have the Shadow Component added to them.

Sean
#5
10/28/2008 (1:50 pm)
@Sean

Mmmh... I renamed PlayerObject of the spheres to SphereObject but this did not change anything. The camera is still not attached to the player and the player is falling through the terrain. Whenever I open the project in the TX3D builder, it changes the camera settings in the XML file to the values in the code of my previous post and the camera will not be attached to the player anymore.

I tried to add shadows to the spheres but the error that I mentioned in my first post still exists when I uncomment the shadows code:

/*
            //add a simple shadow component
            T3DBlobShadowCasterComponent componentShadow = new
            T3DBlobShadowCasterComponent();
            componentShadow.SceneGroupName = "PlayerObject";
            objPlayer.Components.AddComponent(componentShadow);
            */

            TorqueObjectDatabase.Instance.Register(objPlayer);

            TorqueObject objSphere = new TorqueObject();
            objSphere.Name = "SphereObject";
            T3DBlobShadowCasterComponent componentShadowSphere = new
            T3DBlobShadowCasterComponent();
            componentShadowSphere.SceneGroupName = "SphereObject";
            objSphere.Components.AddComponent(componentShadowSphere);

            TorqueObjectDatabase.Instance.Register(objSphere);
#6
10/28/2008 (4:43 pm)
Can you remove the spheres from the xml all together and get the player working properly - then we may add them via code - using tx3d builder to generate the data for us.
#7
10/29/2008 (12:01 am)
Yes. I could do that. But as soon as I open the scene in tx3d builder it will overwrite the camera data in the xml file. Is this a bug or don't I understand the workflow with tx3d builder?
#8
10/29/2008 (12:08 am)
Zilla,
Ah....I, myself dont use tx3d builder - because of some of the workflow, and have found it easier to do everything via c# -it is slightly probablamatic when trying to place objects....but that is my work around.

I would say that it is probably a bug that should be submitted to the GG team.


Sean
#9
10/29/2008 (3:40 am)
Quote:and have found it easier to do everything via c#

you're right but this video from john convinced me to try this editor:
vimeo.com/778087
#10
10/29/2008 (6:24 am)
I was playing around with the editor and it worked fine when I created a new scene with a terrain, a skybox and several objects. But when I was trying to implement a player in the code (according to the example above) it will fall through the terrain and won't have a camera attached. Without placing objects in tx3d builder, the code and the player work fine.
#11
10/29/2008 (11:44 am)
It is still in beta- maybe the current workflow will be changed once released..

Sean