Expanding the Cel shading and outling resources
by Tom Perry · in Torque Game Engine · 06/14/2006 (11:35 pm) · 12 replies
I would like to exapnd the cel shading and the Shape Outlining resource to include terrain, interiors, statics etc. I have had a look through the code, but i am a complete C++ noob :( I know they both have somthing to do with geting the object transform to its render calls, but after that I am at a lost. Any one lead me in the right direction? Thanks in advance.
About the author
#2
06/15/2006 (3:09 pm)
Thankyou David :) I tried to find the render function in the source but didn't really know what to look for, like I said, I'm completly new to C++. I have implemented the lines resource for terrain and interiors, looks alright, not quite as good as yours :P And I don't think the lines change thinkness with distance like yours. O well, life isn't perfect! It's late so I will try and implement the statics and render lines code tomorow. Thanks for the help.
#3
with:
and changed the trees in the stronghold mission to have computeCRC=true but nothing. I am getting mixed up between resource as well I think, as they cross over in some places! Any advice?
06/16/2006 (5:10 am)
Ok having a little trouble updating the TSStatic::renderObject function. I have replced:mShapeInstance->render();
with:
// shape outline resource MatrixF mat=getRenderTransform(); mShapeInstance->render(&mat); // shape outline resource
and changed the trees in the stronghold mission to have computeCRC=true but nothing. I am getting mixed up between resource as well I think, as they cross over in some places! Any advice?
#4
Are you not seeing outlining even on the trunks?
-David
06/16/2006 (10:50 am)
The trees in the Stronghold mission are sorted meshes. The trunks should be outlined, but not the leaves (they're translucent "billboards").Are you not seeing outlining even on the trunks?
-David
#5
06/16/2006 (11:02 am)
Nope. The player (and kork), crossbow, healthkit and ammo are all outlined but the trees, campfire and laterns are not. All have computeCRC in their scripts. Heres and example tree from the mission file:new TSStatic() {
position = "349.353 -149.425 229.698";
rotation = "1 0 0 0";
scale = "1 1 1";
shapeName = "~/data/shapes/trees/tree2.dts";
computeCRC=true;
receiveSunLight = "1";
receiveLMLighting = "0";
useAdaptiveSelfIllumination = "1";
useCustomAmbientLighting = "1";
customAmbientSelfIllumination = "1";
customAmbientLighting = "0.550000 0.550000 0.540000 1.000000";
};
#6
06/16/2006 (12:03 pm)
Stupid refresh. Sorry about repost.
#7
It's because "computeCRC" is not a persistant field of TSStatic. If you add that data member to TSStatic, include it in "initPersistFields", and then add it to the "new TSShapeInstance()" call in TSStatic::onAdd().
I had to dig a bit to find that. But TSStatic doesn't derive from ShapeBase/ShapeBaseData. That was the key piece I was missing at first.
Hope that helps.
-David
06/18/2006 (11:24 am)
Tom,It's because "computeCRC" is not a persistant field of TSStatic. If you add that data member to TSStatic, include it in "initPersistFields", and then add it to the "new TSShapeInstance()" call in TSStatic::onAdd().
I had to dig a bit to find that. But TSStatic doesn't derive from ShapeBase/ShapeBaseData. That was the key piece I was missing at first.
Hope that helps.
-David
#8
I added:
to TSStatic::initPersistFields (in tsStatic.cc). I then added to tsShapeInstance.h:
I added te bool bit at the bottom. Not sure if this is the right place though! To tsStatic.h I added:
underneth
And computeCRC = true; in TSShapeInstance::TSShapeInstance(const Resource & shape, bool loadMaterials, U32 shapeCrc).
I think that was all the changes. I don't know C++ so I am learning by trial and error so I may of added somthing else! No errors in the console now, and the trees have computeCRC come up under misc in the editor (and it is set to true) but no shading or outlines. I am sure some or maybe all of that code is wrong though!
06/18/2006 (2:57 pm)
Thanks, getting there but I think I missed somthing.I added:
addGroup("Misc");
addField("computeCRC", TypeBool, Offset(computeCRC, ShapeBaseData));
endGroup("Misc");to TSStatic::initPersistFields (in tsStatic.cc). I then added to tsShapeInstance.h:
static Vector<TSThread*> smRotationThreads;
static Vector<TSThread*> smTranslationThreads;
static Vector<TSThread*> smScaleThreads;
/// @}
bool computeCRC; ///< Should the shape's CRC be checked?I added te bool bit at the bottom. Not sure if this is the right place though! To tsStatic.h I added:
bool computeCRC; ///< Should the shape's CRC be checked?
underneth
static U32 smUniqueIdentifier;
And computeCRC = true; in TSShapeInstance::TSShapeInstance(const Resource
I think that was all the changes. I don't know C++ so I am learning by trial and error so I may of added somthing else! No errors in the console now, and the trees have computeCRC come up under misc in the editor (and it is set to true) but no shading or outlines. I am sure some or maybe all of that code is wrong though!
#9
To:
I think that should do it.
-David
06/18/2006 (5:47 pm)
In bool TSStatic::onAdd(), change:mShapeInstance = new TSShapeInstance(mShape, isClientObject());
To:
mShapeInstance = new TSShapeInstance(mShape, isClientObject(),computeCRC);
I think that should do it.
-David
#10
Error: no plane possible!
It references mplane.h line 239. It did run a few times, and the closet tree was outlined. I spawned in the same place each time it ran so it must happen when I look at a certain place. Do I need to remove the code I placed in? I have a feeling it is going to take me a long time to get a handle of the Torque source!
06/19/2006 (3:37 am)
Thanks again, making progress but now when I run the mission I get an error message:Error: no plane possible!
It references mplane.h line 239. It did run a few times, and the closet tree was outlined. I spawned in the same place each time it ran so it must happen when I look at a certain place. Do I need to remove the code I placed in? I have a feeling it is going to take me a long time to get a handle of the Torque source!
#11
I might be able to look into that before next weekend, but I don't want to promise anything. Sorry.
-David
06/19/2006 (8:41 am)
It sounds like I didn't get the outline working properly for sorted meshes with billboard items. I didn't notice because I only focused on the player model and weapons. Planes are used for finding the edges to outline, BTW.I might be able to look into that before next weekend, but I don't want to promise anything. Sorry.
-David
#12
06/19/2006 (9:12 am)
That's ok, your making your own game not mine! Thanks for the help so far, if nothing else I'm getting a better grip of C++.
Torque Owner DavidRM
Statics can be supported already, since they are based on TSMesh. You just need to update the TSStatic::renderObject() function as described in the resource.
Terrain and interiors, though, use totally separate rendering functions. A good place to start on those would be the "render lines with back face culling" method discussed in this thread and in TDN here. Skip the part about shapes (since my resource covers those) and look at interior and terrain changes.
Hope that helps.
-David
Joe Indie