How to import a 3D object into TGB
by Joseph Serra · in General Discussion · 05/03/2008 (8:06 am) · 1 replies
3D Shapes in TGB!
(this tutorial will bring "Blocky/player.dts" into TGB and spin)
Let's get started!
- Create a new project
- Name it "Blocky_Spin" (or whatever)
- Use an Empty Game Template
- This creates a new folder called "Blocky_Spin"
Let's get Blocky!
- Goto (ha!)
C:Program Files\Garage Games\TorqueGameBuilder-1.7.2\games\TutorialBase\game\data\shapes
- You should see a bunch of different files in the folder
- Copy the player.dts & player_blue.jpeg.
- Paste these files into...
C:Documents & Settings\"user"\My Documents\MyGames\"Blocy_Spin"\game\data\shapes
- Go back into TGB, re-open your project, goto File->Open Project->project
- When TGB refreshes, you will see Blocky in the 3D Shapes rollout
- Drag him out onto the stage
- He can be manipulated like other objects, using the handles
- Drag his bounding box to the inner "camera-box"
Let's do some Editing!
- Click on the edit tab
- You will notice the 3D Shape rollout, it contains a few options
- Angular Velocity, Rotation, Offset, and Scale
- Angular Velocity (X,Y,Z): applies constant rotation
- Rotation (X,Y,Z): sets the position based on rotation
- Offset (X,Y,Z): will move along axis, BUT! not towards or away...2D
- Scale (X,Y,Z): size in space
- Let's get Blocky to face us, set the Rotation Y to 180.000
Let's do some Coding!
- Goto the Scripting rollout
- In the Class Name type, player
- Check the Use Mouse Events box
- In the "Blocky_Spin\gamescripts" folder create a Player.cs
- Right click, New -> Text Document -> name it Player.cs
- Remember! you must type "exec("./Player.cs");" in the game.cs and save
- Type it into the game.cs function startGame(%level)
- The game.cs is located in...
C:\Documents and Settings\Joseph Serra\My Documents\MyGames\Blocky_Spin\game\gameScripts
- In the Player.cs type enter the following code:
sceneWindow2D.setUseObjectEvents(true);
function Player::onAdd(%this)
{
%this.setUseMouseEvents(true);
}
function Player::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.setShapeAngularVelocity(0,30,0);
}
- Save your file, now it's time to save everything and then test!
- Make sure all of your files are in the proper location
- Check over your code and make sure everything is spelled right
- Remember!!! Blocky is awesome!!!!
(this tutorial will bring "Blocky/player.dts" into TGB and spin)
Let's get started!
- Create a new project
- Name it "Blocky_Spin" (or whatever)
- Use an Empty Game Template
- This creates a new folder called "Blocky_Spin"
Let's get Blocky!
- Goto (ha!)
C:Program Files\Garage Games\TorqueGameBuilder-1.7.2\games\TutorialBase\game\data\shapes
- You should see a bunch of different files in the folder
- Copy the player.dts & player_blue.jpeg.
- Paste these files into...
C:Documents & Settings\"user"\My Documents\MyGames\"Blocy_Spin"\game\data\shapes
- Go back into TGB, re-open your project, goto File->Open Project->project
- When TGB refreshes, you will see Blocky in the 3D Shapes rollout
- Drag him out onto the stage
- He can be manipulated like other objects, using the handles
- Drag his bounding box to the inner "camera-box"
Let's do some Editing!
- Click on the edit tab
- You will notice the 3D Shape rollout, it contains a few options
- Angular Velocity, Rotation, Offset, and Scale
- Angular Velocity (X,Y,Z): applies constant rotation
- Rotation (X,Y,Z): sets the position based on rotation
- Offset (X,Y,Z): will move along axis, BUT! not towards or away...2D
- Scale (X,Y,Z): size in space
- Let's get Blocky to face us, set the Rotation Y to 180.000
Let's do some Coding!
- Goto the Scripting rollout
- In the Class Name type, player
- Check the Use Mouse Events box
- In the "Blocky_Spin\gamescripts" folder create a Player.cs
- Right click, New -> Text Document -> name it Player.cs
- Remember! you must type "exec("./Player.cs");" in the game.cs and save
- Type it into the game.cs function startGame(%level)
- The game.cs is located in...
C:\Documents and Settings\Joseph Serra\My Documents\MyGames\Blocky_Spin\game\gameScripts
- In the Player.cs type enter the following code:
sceneWindow2D.setUseObjectEvents(true);
function Player::onAdd(%this)
{
%this.setUseMouseEvents(true);
}
function Player::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.setShapeAngularVelocity(0,30,0);
}
- Save your file, now it's time to save everything and then test!
- Make sure all of your files are in the proper location
- Check over your code and make sure everything is spelled right
- Remember!!! Blocky is awesome!!!!
Associate David Montgomery-Blake
David MontgomeryBlake