Game Development Community

fxTreeReplicator

by CdnGater · 08/23/2007 (4:40 pm) · 26 comments

Download Code File

A while ago I posted the following blog www.garagegames.com/blogs/27572/11526.

Today I was asked if someone could use the resource. So I thought I would post it here for all to have and play with. One thing to remember, I have not touched this code since October 2006, my current project didn't require it. But with enough interest I may be swayed to work on it again and do more stuff with it.

Please use at your own risk.. :)

I have included the 2 source files, and an example tree done in MS3d (Note: it's programmer art!) Sorry, I did not include the textures as they bloat the file too much, but you can find samples on the net easy enough.

No instructions expect whats in the source, and its simple to add in. Just read the comments.

If you do use it, the only thing I ask is recognition.
Page «Previous 1 2
#1
08/24/2007 (1:02 am)
Thanks, great work, just ported to TGEA
Ported
#2
08/24/2007 (2:49 pm)
that looks great!
#3
08/24/2007 (4:51 pm)
this one is really interesting. gonna try that as soon as I find time for that :)
Thanks for sharing!
#4
08/27/2007 (10:08 pm)
Very nice! Thanks.
#5
09/12/2007 (2:29 pm)
Sounds cool man
#6
10/23/2007 (9:45 pm)
Neat resource. Darn dso's not recompiling made it a bit frustrating :mutter: I figured it out however. Now to investigate how to adjust the wind via script :P
#7
10/27/2007 (11:55 pm)
Ok so this is a bit confusing. I was able to place the whole fxtreereplicator object and have it replicate my trees. However I can't seem to get wind to affect them. I tracked it through the source, and it looks as though the tree isn't constructed properly.

void fxTreeReplicator::adjustForTurbulence( fxTreeReplicatedStatic *tree, VectorF *turbulenceTrunk, VectorF *turbulenceBranch )
{
	QuatF tmpQ, rotQ;
	S32 node;

	TSShape *shape = tree->getShape();
	TSShapeInstance *shapeInstance = tree->getShapeInstance();

	S32 nodeSize = shape->nodes.size();
	if (nodeSize == 0)
		return;

	for (S32 n = 0; n < nodeSize; n++)
	{
		TSTransform::setMatrix(	shapeInstance->mNodeReferenceRotations[n].getQuatF(&tmpQ),
								shapeInstance->mNodeReferenceTranslations[n],
								&shapeInstance->mNodeTransforms[n]);
	}

	// now adjust specific nodes for turbulence
	for (S32 t = 0; t < fxTreeReplicatedStatic::MaxTrunks; t++)
	{
		for (S32 tn = 0; tn < fxTreeReplicatedStatic::MaxTrunkNodes; tn++)
		{
			node = trunkNode[t][tn];
			if (node > -1)
			{
				shapeInstance->mNodeReferenceRotations[node].getQuatF(&tmpQ);
				rotQ.mul( tmpQ, QuatF(turbulenceTrunk[t]) );
				TSTransform::setMatrix(	rotQ,
								shapeInstance->mNodeReferenceTranslations[node],
								&shapeInstance->mNodeTransforms[node]);

For example, in the above snippet of code the

node = trunkNode[t][tn];
if (node > -1)

check always fails. This leads me to believe the tree has to be constructed in a special way, and its possible the default oak trees do not have the required information to be transformed. Any help would be appreciated.
#8
10/28/2007 (5:57 am)
The tree does need to be constructed a certain way, it needs a skeleton. The default trees that come with TGE do not have this. That is why I included tree.ms3d as an example.
#9
11/04/2007 (6:49 am)
Ahh I see. It wasn't called out in the documentation anywhere, but after opening the sample I was able to identify the nomenclature of the nodes. Thanks again!
#10
11/06/2007 (2:03 pm)
Not showing up at all.

I'm getting the menu item in the world editor, creator, fxTreeReplicator, brings up the little name box, but
then you click OK and you get nothing. I'm not getting any compile errors or script errors.

I don't think I'm compiling correctly. I added the fxTreeReplicator.cc to the mk file and did a build all on the torque demo. I don't see it on the list after the complie is done...

SDK 1.5.2
Any help is greatly appreciated.

J
#11
11/06/2007 (2:14 pm)
Did you make the script changes as indicated in the fxTreeReplicator.cc?
#12
11/06/2007 (2:27 pm)
Yep, I sure did. I went back through them and made sure I had everything in there
#13
11/06/2007 (3:08 pm)
If you dont see the file being compiled then I would expect you added it wrong somehow. What are you compiling with? I use VS2005 and adding the files to the project is easy.

Is there an obj file created for this class by the compiler?

I am surprised you dont get any errors if its not compiled when you add it to the mission. But you dont see it in the mission tree after adding right?
#14
11/06/2007 (7:37 pm)
Right, and that is what I thought, I added it wrong. I'm using VS2005, it compiled gui.cc's before with no problem, I'm lost on why I'm not getting it, I went back through and made sure I had everything correct from the resource. I added a secondary visiable distance on the sky.cc and tried to get a decent ground fog going, but it didn't effect anything that this changed. I checked them both. In my mk file, it shows fxTreeReplicator underneath the fxShapeReplicator in the fx. Do I need to add it any place else? I guess I'm still a noob,...
"obj file created for this class". In the mk it shows it under the fx. So I assume it does. I'll re-read the compile and also see exactly what the mk shows to give you exact info... . I'm not at my computer right now. But I will check it first thing in the morning and post again.

it does show it in the mission tree. fxtreerep... is there and you get the "name" box and place a name, click OK, and then nothing. I'll also place this in a clean SDK and see if it works, I should have it. maybe I'm missing something I changed before.... AAAAAHHHH, that would be so cool to get this working....

All I need to do to add it to the project is under Engine, add it in the mk?.... I added it right in front of the the fxShapeReplicator. Maybe that is wrong. I did everything else like the resource said. I'll also take a clean version of the SDK and put it in there and see if it compiles in the morning before I post again.
#15
11/06/2007 (7:56 pm)
Humm, the mission tree, not the creation tree.

Did you export the sample tree? Did you put that DTS into the data directory?

Can you inspect the object from within the mission editor?

Did you sell fxTreeReplicator what tree and how many to use?
#16
11/07/2007 (6:36 am)
in the mk it is under source.game.fx
7 succeeded 0 failed 0 skipped; 0 warnings on the TorqueDemo, rebuild all

Sorry, it IS in the creator tree, I can place the static object in the mission and inspect it

I exported the tree and put it in the starter.fps/data/shapes/trees/tree.dts

I did not set the fxTreeReplicator to what tree and how many. It only askes for a name, click OK and then it does nothing.

I've went through everything again...the only thing I can come up with is that I'm not adding it to the compile right. Same thing on a clean SDK
#17
11/07/2007 (6:53 am)
ok, if your not setting the parameters for fxTreeReplicator then it will not work. Eg: If you don't put gas in that new car you just bought, it will not work.

Add the fxTreeReplicator object to the mission. Then change to inspect view and select the object so you can change the parameters.

Change the shape parameter from nothing to point to the tree.dts.

All the other defaults should give you 10 trees in a 100 unit area.

Make sure that the object is actualy above the terrain and not below it.

You may need to save and reopen the mission once this is done.


If you are still having problems, then send me your log. My email address is in my profile.
#18
11/07/2007 (8:03 am)
It doesn't show up in the inspect view. You can go creator, Environment, fxTreeReplicator...then it brings up the little name box and then click OK and it does nothing. It doesn't show up in the inspector, it doesn't show up anywhere else. can't call it in the console, can't find it anywhere

Alright, finally got something out of the console....

warning in the consoleobject.cc @ 62; Couldn't find class rep for dynamic class: fxTreeReplicator
Unable to instantiate non-conobject class fxTreeReplicator

its not loading the .cc file on compile. What steps do you take to add the .cc to the project? Evidently I'm not doing it right. I even went in and manually added .cc to the registry so it will recognize it with no such luck.
#19
11/07/2007 (8:26 am)
Yay, now we are getting somewhere.

If your using VS2005, then its a simple matter of just adding the two files to the project. This can be done within VS2005. I am not sure why you are changing the MK file. When you build in VS2005 it creates a new MK file so any changes you attemped will be lost.

You need to add it properly into the project for it to work. If you are not sure how to add a source file to the project in VS2005, then I would suggest looking up beginner tutorials on VS2005.
#20
11/07/2007 (11:42 am)
got it building properly. I can insert the trees and inspect them... no movement of the leaves. I'll have to mess around with it. I am using the tree you provided exported with some leaves.
Page «Previous 1 2