Projectiles Supported?
by David Wyand · in Torque Game Engine Advanced · 06/03/2004 (11:24 am) · 9 replies
Greetings!
I've just finished converting the TSE demo into a single player game of Orcs in Space. It's great to be able to run around and look at everything in the big building with a camera I can control.
I'd like to get my Orc firing his new space gun. He's loaded up with ammo, and when I fire I see the recoil animation going. And if I fire at my feet, I'll eventually kill myself. Unfortunately, I cannot see the projectile (the crossbow bolt) fire from my gun. If I load up the crossbow bolt as a static shape in the mission, it shows up fine.
Is the visual aspect of projectiles supported by the TSE at this time?
Thanks.
- LightWave Dave
I've just finished converting the TSE demo into a single player game of Orcs in Space. It's great to be able to run around and look at everything in the big building with a camera I can control.
I'd like to get my Orc firing his new space gun. He's loaded up with ammo, and when I fire I see the recoil animation going. And if I fire at my feet, I'll eventually kill myself. Unfortunately, I cannot see the projectile (the crossbow bolt) fire from my gun. If I load up the crossbow bolt as a static shape in the mission, it shows up fine.
Is the visual aspect of projectiles supported by the TSE at this time?
Thanks.
- LightWave Dave
About the author
A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!
#2
No problem, Brian. I'll take a look at the projectile renderObject() method myself.
Thanks.
- LightWave Dave
06/03/2004 (2:07 pm)
Greetings!No problem, Brian. I'll take a look at the projectile renderObject() method myself.
Thanks.
- LightWave Dave
#3
I've got projectiles rendering now in the TSE. I've not only made changes to the ::renderObject() method, but also ::prepRenderImage() to allow for glowing projectiles (which are cool BTW).
Here's my first patch for the TSE (first end user patch ever?? :o)
Now, I'm the first to admit that I'm not yet familiar with how the TSE rendering pipeline works. Heck, it feels like I'm still learning with the TGE! And, well, we've only had the code for a day. So, perhaps there are better ways of doing the above, but all appears well with my test TSE game.
- LightWave Dave
Edit: Line breaks missing in code...hmm can't seem to get any line breaks in the code block at all. Sorry about that.
06/03/2004 (6:41 pm)
Greetings!I've got projectiles rendering now in the TSE. I've not only made changes to the ::renderObject() method, but also ::prepRenderImage() to allow for glowing projectiles (which are cool BTW).
Here's my first patch for the TSE (first end user patch ever?? :o)
bool Projectile::prepRenderImage(SceneState* state, const U32 stateKey,
const U32 /*startZone*/, const bool /*modifyBaseState*/)
{
if (isLastState(state, stateKey))
return false;
setLastState(state, stateKey);
if (mHidden == true || mFadeValue <= (1.0/255.0))
return false;
// This should be sufficient for most objects that don't manage zones, and
// don't need to return a specialized RenderImage...
if (state->isObjectRendered(this)) {
SceneRenderImage* image = new SceneRenderImage;
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::Point;
state->setImageRefPoint(this, image);
// For projectiles, the datablock pointer is a good enough sort key, since they aren't
// skinned at all...
image->textureSortKey = (U32)(dsize_t)mDataBlock;
state->insertRenderImage(image);
// DAW: Added glow pass for projectiles. Could comment out if
// your projectiles will never glow to save on a scene graph pass.
// glow pass - after everything has rendered to zbuffer
image = new SceneRenderImage;
image->obj = this;
image->glow = true;
image->isTranslucent = true;
image->sortType = SceneRenderImage::Glow;
state->insertRenderImage(image);
// DAW: Uncomment if projectiles will have refraction. Kind of
// heavy weight for a projectile, but maybe you need it...
// refract pass - after everything has rendered
//image = new SceneRenderImage;
//image->obj = this;
//image->isTranslucent = true;
//image->sortType = SceneRenderImage::Refraction;
//state->insertRenderImage(image);
}
return false;
}void Projectile::renderObject(SceneState* state, SceneRenderImage * image)
{
// DAW: New code for TSE
MatrixF proj = GFX->getProjectionMatrix();
RectI viewport = GFX->getViewport();
state->setupObjectProjection(this);
// hack until new scenegraph in place
MatrixF world = GFX->getWorldMatrix();
TSMesh::setCamTrans( world );
TSMesh::setSceneState( state );
TSMesh::setGlow( image->glow );
// DAW: Uncomment below if projectiles support refraction
//TSMesh::setRefract( image->sortType == SceneRenderImage::Refraction );
GFX->pushWorldMatrix();
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
if(mProjectileShape)
{
AssertFatal(mProjectileShape != NULL,
"Projectile::renderObject: Error, projectile shape should always be present in renderObject");
mProjectileShape->selectCurrentDetail();
mProjectileShape->animate();
mProjectileShape->render();
}
GFX->popWorldMatrix();
GFX->setProjectionMatrix( proj );
GFX->setViewport( viewport );
}Now, I'm the first to admit that I'm not yet familiar with how the TSE rendering pipeline works. Heck, it feels like I'm still learning with the TGE! And, well, we've only had the code for a day. So, perhaps there are better ways of doing the above, but all appears well with my test TSE game.
- LightWave Dave
Edit: Line breaks missing in code...hmm can't seem to get any line breaks in the code block at all. Sorry about that.
#4
06/06/2004 (2:55 am)
Great David, I'll try that out.
#5
but has anyone gotten glowing projectiles working witht he lastest tgea 1.7.1? or tgea 1.7.1 with arcane fx?
this would be really cool but part of this looks nothing like the current code:s
12/30/2008 (2:29 pm)
Sorry to bump this old postbut has anyone gotten glowing projectiles working witht he lastest tgea 1.7.1? or tgea 1.7.1 with arcane fx?
this would be really cool but part of this looks nothing like the current code:s
#6
new Material(OrcEye)
{
baseTex[0] = "orc_ID6_eye";
emissive[0] = true;
glow[0] = true;
};
12/30/2008 (2:34 pm)
Would the projectiles glow if you changed their material to glow, like the Orc eye?new Material(OrcEye)
{
baseTex[0] = "orc_ID6_eye";
emissive[0] = true;
glow[0] = true;
};
#7
but whenever i try that
the engine seems to not be able to load the weapon and projectile at all
something about unlinked namespace failure
so im thinking it has somerthing to do with this, i could be wrong tough
12/30/2008 (3:01 pm)
Thats what i was thinkingbut whenever i try that
the engine seems to not be able to load the weapon and projectile at all
something about unlinked namespace failure
so im thinking it has somerthing to do with this, i could be wrong tough
#8
12/30/2008 (4:41 pm)
We got glowing projectiles, check your stuff.
#9
i got everythign working, but only the baseTex flag in the materials.cs file has any impact
glow, emissive and any other do not affect my projectiles
12/30/2008 (5:56 pm)
Ehm, i have tgea 1.7.1 with arcane Fx, and my projectiles do not glowi got everythign working, but only the baseTex flag in the materials.cs file has any impact
glow, emissive and any other do not affect my projectiles
Torque Owner Brian Ramage
Black Jacket Games