Game Development Community

Clothitem addition

by Sylvain · in Technical Issues · 07/09/2007 (6:43 am) · 4 replies

Hello !
I'm a student and relatively new to Torque (well, about 3 weeks of experimentations ...). I have just read about the cloth physics addition to the TGE.

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8942

After reading through the comments, I managed to create an instance of a cloth item via the World Editor Creator. However for the moment, my cloth item is a textured square rotating 50 feet above the ground ...

I was wondering : how can I create a cloth item from a .cs file ? and how do I have that item falling on the ground and deforming according to the shape of the ground ?

I copied & pasted that from the comments. Is it a good start ?

datablock ClothItemData(Cloth)
{
category = "Cloth";
shapeFile = "~/data/shapes/crossbow/weapon.dts";
};

function ClothItemData::Create(%data)
{
%obj = new ClothItem()
{
datablock = %data;
};
}

Thank you !
Sylvain

#1
07/12/2007 (8:53 am)
Well I've got an error :

"Unable to instantiate non-conobject class ClothItem"

whenever I try to call my function InsertCloth :

datablock ClothItemData(Cloth)
{
category = "Cloth";
shapeFile = "~/data/shapes/test.dts";
mass=1;
friction=1;
};

function InsertCloth()
{
%obj = new ClothItem(){
datablock = Cloth;
rotation="0 0 1 0";
};

MissionCleanup.add(%obj);

%obj.setTransform("50 -440 240 0 0 1 0");
echo("Inserting Shape " @ %obj);
return %obj;
}

Any suggestion ?
#2
07/12/2007 (9:56 am)
Quote:
"Unable to instantiate non-conobject class ClothItem"

That error means that the c++ class "ClothItem" either does not exist in your executable, or is not exposed as a class that can be instantiated from script.

Normal cases are:

--you did not include the c++ files for this class in your Project, and/or you did not recompile.
--the class does not use the DECLARE_XXXOBJECT() and IMPLEMENT_XXX_OBJECT() macros that are appropriate for that "type" of class.
--you are misspelling the class in your script.
#3
07/15/2007 (10:24 am)
Thanks for the reply.
I checked the different points, and indeed I didn't recompile ... After recompiling though I was thrown an error "addLight isn't a component of lightmanager"
I have a c++ file for the lightmanager class, but most of it is commented out ...
So I removed the line referring to addLight, it then compiled just fine but when I tried to call call my InsertCloth function I was thrown exactly the same error message as before ("Unable to instantiate non-conobject class ClothItem").
I have also seen instances of the macros you are talking about.
And I have checked for mispelled class names several times ......

Has anyone been able to use that clothitem class ? Do you think (if I ever manage to have it working) that I might use it to create dynamically deformable objects ?

Thank you !
Sylvain
#4
07/23/2007 (2:42 am)
Hasn't really noone had to deal with the same issues ?