T3D 3dArrow Port
by Donnie Hutson Jr · 03/21/2014 (8:25 pm) · 2 comments
This is based off the original 3darrow resource found here;
www.garagegames.com/community/resources/authorID/90692
The fixes to this are posted else where and are by no means my own work,
other than this is what I did to get it to work in T3d 3.5.1 MIT!!
Ok first the engine changes I used.... open guiObjectView.cpp
around line 112, zero these out....
in
add this....
right after this....
just under
add...
at the very end of this file add....
save and close..... Now open guiObjectView.h
add this around line 234....
save and close..... Rebuild Engine!!
Now for the scripts.... in game/art/gui/playGui.gui add this to the bottom;
save and close.... Now in game/scripts/client/client.cs add this to the end of file;
save and close.... Now in game/scripts/gui/playGui.cs in
add....
save and close.... Now in game/scripts/server/game.cs add this to the end of file;
save and close.... In game/scripts/server/gameCore.cs in
add....
save and close...... Run game and enoy, dont forget you can set this in console or script like so;
www.garagegames.com/community/resources/authorID/90692
The fixes to this are posted else where and are by no means my own work,
other than this is what I did to get it to work in T3d 3.5.1 MIT!!
Ok first the engine changes I used.... open guiObjectView.cpp
around line 112, zero these out....
mCameraRot.set( 0.0f, 0.0f, 0.0f ); mCameraPos.set( 0.0f, 0.0f, 0.0f );
in
void GuiObjectView::renderWorld( const RectI& updateRect )
add this....
// Set up pass transforms. renderPass->assignSharedXform( RenderPassManager::View, MatrixF::Identity ); renderPass->assignSharedXform( RenderPassManager::Projection, GFX->getProjectionMatrix() );
right after this....
SceneRenderState state
(
gClientSceneGraph,
SPT_Diffuse,
SceneCameraState( GFX->getViewport(), frust, GFX->getWorldMatrix(), GFX->getProjectionMatrix() ),
renderPass,
false
);just under
void GuiObjectView::setOrbitDistance( F32 distance )
add...
// 3D Arrow Resource
void GuiObjectView::setRotation(F32 x, F32 y, F32 z)
{
mCameraRot.x = (x * 1.0f);
mCameraRot.y = (y * 1.0f);
mCameraRot.z = (z * 1.0f);
}
// 3D Arrow Resourceat the very end of this file add....
// 3D Arrow Resource
ConsoleMethod(GuiObjectView, setRotation, void, 5, 5,
"(float x, float y, float z)n"
"Sets the rotation for the loaded model..nn"
"param x x rotation value."
"param y y rotation value."
"param z z rotation value.")
{
argc;
object->setRotation(dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]));
}
// 3D Arrow Resource Endsave and close..... Now open guiObjectView.h
add this around line 234....
void setRotation( F32 x, F32 y, F32 z ); // <- add this 3darrow
save and close..... Rebuild Engine!!
Now for the scripts.... in game/art/gui/playGui.gui add this to the bottom;
new GuiObjectView(direction) {
shapeFile = "art/shapes/3darrow/arrow.dts";
mountedNode = "mount0";
lightColor = "0.6 0.58 0.5 1";
lightAmbient = "0.5 0.5 0.5 1";
lightDirection = "-0.57735 -0.57735 -0.57735";
orbitDiststance = "5";
minOrbitDiststance = "0.438834";
maxOrbitDiststance = "5";
cameraSpeed = "0.01";
cameraRotation = "0 0 0";
cameraZRot = "0";
forceFOV = "0";
reflectPriority = "0";
renderStyle = "standard";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "244 -102";
extent = "532 483";
minExtent = "8 2";
horizSizing = "center";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};save and close.... Now in game/scripts/client/client.cs add this to the end of file;
//3darrow
function clientCmdSetDirection(%x, %y, %z)
{
%x = -0.5; // Hack to get the arrow to point down some.
%y = 0; // This value is not really needed at all, so nullify the results.
direction.setRotation(%x, %y, %z);
//echo(("clientCmdSetDirection rotation: " SPC %x SPC %y SPC %z));
}save and close.... Now in game/scripts/gui/playGui.cs in
function PlayGui::onWake(%this)
add....
%shapeName = "art/shapes/3darrow/arrow.dts";
direction.setModel(%shapeName);save and close.... Now in game/scripts/server/game.cs add this to the end of file;
//------------------------------------------------------------------------
//3darrow HUD
//------------------------------------------------------------------------
$aimTarget = 1052871; //set this to any game ID you want arrow to point to...
function GameConnection::AimTarget( %this )
{
if($aimTarget)
{
%player = %this.player;
%target = $aimTarget;
%playerTrans = (%player.getTransform());
%xPlayer = getWord(%playerTrans, 0);
%yPlayer = getWord(%playerTrans, 1);
%zRot = getWord(%playerTrans, 5);
%playerRot = getWord(%playerTrans, 6);
%targetPosition = (%target.getPosition());
%xTarget = getWord(%targetPosition, 0);
%yTarget = getWord(%targetPosition, 1);
%xDiff = %xTarget - %xPlayer;
%yDiff = %yTarget - %yPlayer;
// dont have to change it to degrees
// settransform automatically change it to degrees
%rotToTarget = mAtan(%xDiff, %yDiff);
if(%zRot < 0)
%playerRot = (2 * 22/7) - %playerRot;
// multiply by -1 because the rotation in 3dspace is oppositing the guiobjectview rotation
%rotation = -1 * (%rotToTarget - %playerRot);
commandToClient(%this, 'SetDirection', 0, -15, %rotation);
}
%this.schedule(25, AimTarget);
}save and close.... In game/scripts/server/gameCore.cs in
function GameConnection::onClientEnterGame(%this)
add....
// here you go just call the aimTarget here
// and you can set the $aimtarget anywhere and anytime you want.
%this.aimTarget();save and close...... Run game and enoy, dont forget you can set this in console or script like so;
$aimTarget = 1052871; //set this to any game ID you want arrow to point to...
About the author
Electrical Engineer by trade, Computer geek by night. Still learning and loving every minute.

Richard Marrevee
R.G.S - Richards Game Studio