StaticShapes & RegisterObject
by Stefan Lundmark · in Torque Game Engine · 10/24/2004 (3:44 am) · 22 replies
I have tried to get StaticObjects work with my 1.1.2 release but to no avail. I have not modified anything regarding this area.
What could be wrong when the console says this?
I noticed there was no create() function for staticshapes in the editorgui.cs, so I added it.
Still the same error message though. Nothing changed.
The following is the block from the .mis file that I'm trying to use.
IF I chose to create a Static Shape from within the World Editor, it creates a TSStatic instead. I'm very confused.
What could be wrong when the console says this?
Quote:
data/enviorment/desert.mis (0): Register object failed for object Door of class StaticShape.
I noticed there was no create() function for staticshapes in the editorgui.cs, so I added it.
function StaticShapeData::create(%data)
{
%obj = new StaticShape() {
dataBlock = %data;
};
return %obj;
}Still the same error message though. Nothing changed.
The following is the block from the .mis file that I'm trying to use.
new StaticShape(Door) {
position = "-221.9 492.47 234.441";
rotation = "0 0 -1 90";
scale = "3.2 2.5 3.4";
dataBlock = "Door";
isOpen = false;
};IF I chose to create a Static Shape from within the World Editor, it creates a TSStatic instead. I'm very confused.
About the author
#2
Do you have Door datablock defined anywhere? See the flag example from TGE demo:
10/24/2004 (3:57 am)
Stefan,Do you have Door datablock defined anywhere? See the flag example from TGE demo:
datablock StaticShapeData(Flag)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
// Path is relative to where the script is executed from.
category = "Misc";
shapeFile = "~/data/shapes/flagpole/flagpole.dts";
isPlaying = 1;
};
function Flag::onAdd(%this,%obj)
{
// %obj is the object being added to the world
// with %this datablock. Start up a thread on the
// new object. Since the ambient sequence is cyclic
// this animation will run continously.
%obj.playThread(0,"ambient");
%obj.isPlaying = 1;
}
#3
10/24/2004 (3:59 am)
I see you've posted door datablock as I was entering my comment. Here is rest of the flag code:function StaticShapeData::create(%block)
{
// The mission editor invokes this method when it
// wants to create an object of the given datablock
// type. You only need one of these methods for any
// class/datablock type (in this case StaticShape).
%obj = new StaticShape()
{
dataBlock = %block;
};
return(%obj);
}
function Flag::create(%block)
{
// The mission editor invokes this method when it
// wants to create an object of the given datablock
// type. You only need one of these methods for any
// class/datablock type (in this case StaticShape).
%obj = new StaticShape()
{
dataBlock = %block;
};
return(%obj);
}
#4
Unfortunatly, both of these are already mentioned in my post above :/
The Flag::onAdd is not nessecary.. and the Create functions were mentioned in the first post.
One question, does this work for you? Have you tried adding these shapes, and do you get a StaticShape when you do?
If so, then it has to be the release I have.
Edit: Spelling, gah.
10/24/2004 (4:13 am)
Thanks alot for answering, Akio.Unfortunatly, both of these are already mentioned in my post above :/
The Flag::onAdd is not nessecary.. and the Create functions were mentioned in the first post.
One question, does this work for you? Have you tried adding these shapes, and do you get a StaticShape when you do?
If so, then it has to be the release I have.
Edit: Spelling, gah.
#5
You show to be using...
function StaticShape::create(%data)
10/24/2004 (4:45 am)
Stefan, Akio is right, this should fix it...function StaticShapeData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type.
%obj = new StaticShape() {
dataBlock = %data;
};
return %obj;
}You show to be using...
function StaticShape::create(%data)
#7
It slipped by me at first, but you said you were using this in your mission file...
try this instead...
10/24/2004 (5:15 am)
Ahhh crap, I see the problem. Did you add this via text editor by chance? heheheIt slipped by me at first, but you said you were using this in your mission file...
new StaticShape(Door) {
position = "-221.9 492.47 234.441";
rotation = "0 0 -1 90";
scale = "3.2 2.5 3.4";
dataBlock = "Door";
isOpen = false;
}; try this instead...
new TSStatic(Door) {
position = "-221.9 492.47 234.441";
rotation = "0 0 -1 90";
scale = "3.2 2.5 3.4";
dataBlock = "Door";
isOpen = false;
};
#8
Which means I must have done something wrong. Sorry, I'll go download 1.3 and try to merge.
Edit:
Didn't see your post at first Gonzo.
Do you say that TSStatic is the same as StaticShape? :O I can create both in the Torque Demo.. wouldn't it be pointless to have two type of objects with the same functions??
I thought they were different. (Animations, shadows.. etc) If not, then why do they both exist?
10/24/2004 (5:28 am)
=/ I tried the same procedure and it works with the Torque Demo..Which means I must have done something wrong. Sorry, I'll go download 1.3 and try to merge.
Edit:
Didn't see your post at first Gonzo.
Do you say that TSStatic is the same as StaticShape? :O I can create both in the Torque Demo.. wouldn't it be pointless to have two type of objects with the same functions??
I thought they were different. (Animations, shadows.. etc) If not, then why do they both exist?
#9
11/17/2004 (5:29 am)
@Stefan: Did you ever find a solution for this? I'm running into the same exact situation as your 'is not member of GameBaseData clas..."
#10
Make sure you load the datablock when the server is created (preferebly in game.cs). If that's what you're doing already, and you still get the message; then you're in the same boat as me :) Good luck, and sorry I couldn't be to more help.
11/17/2004 (5:34 am)
I didn't find any solution. I changed the project to TGE 1.3 and tried the same procedure there. It worked. But I was able to reproduce the error there too by moving the datablock around though.Make sure you load the datablock when the server is created (preferebly in game.cs). If that's what you're doing already, and you still get the message; then you're in the same boat as me :) Good luck, and sorry I couldn't be to more help.
#11
11/17/2004 (4:50 pm)
Try this !function CreateADoor()
{
%obj = new StaticShape(door)
{
position = "-221.9 492.47 234.441";
rotation = "0 0 -1 90";
scale = "3.2 2.5 3.4";
dataBlock = "Door";
isOpen = false;
};
MissionGroup.add(%obj);
}
#12
11/19/2004 (5:04 am)
Already tried that Billy. It's not the scripts.. it's the code, something was changed.. might have been an error when I integrated the lightingpack with the staticshapes.
#13
Even V12 can handle it :)
hehe i don't have that pack so i cant answer for that.
11/19/2004 (6:36 am)
Stefan i tried this in versions from 1.1.1 to 1.3 .Even V12 can handle it :)
hehe i don't have that pack so i cant answer for that.
#14
I've been trying to work on this for you whenever I get some spare time and I just wanted to make sure that this had been considered while I'm in the process of trying to find a potential solution to your problem.
11/19/2004 (7:54 am)
Stefan, not sure if you had seen this or not, but just above the line that is spitting out your error is this comment from GG....Quote:This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields().
I've been trying to work on this for you whenever I get some spare time and I just wanted to make sure that this had been considered while I'm in the process of trying to find a potential solution to your problem.
#15
Gonzo, it's no problem for me anymore. I'm not working with that part of TGE anymore and I'm waiting for TSE. It might had been the initPersistFields though.. did you replicate the problem?
11/19/2004 (8:01 am)
Billy, again my point was that there was a CHANGE in the code somewhere that made it break, and thus you can't replicate it because you haven't done the same change. :)Gonzo, it's no problem for me anymore. I'm not working with that part of TGE anymore and I'm waiting for TSE. It might had been the initPersistFields though.. did you replicate the problem?
#16
Just kidding dude, I'm always glad to help you when I can.
11/19/2004 (9:03 am)
No. Just on a whim I searched the engine for your error so I could see the exact code I was going to be dealing with and trace it to all it's sources of execution to see if I could determine the problem for you. I didn't expect to see that comment and when I saw that it hadn't been mentioned in the thread I just wanted to make sure that it had been considered before I got way to deep into things. But if you are no longer concerned with this then I'll move on with other things. Thanks for being so quick to respond, god knows I would have knocked myself out trying to fix this for you, and then I would have had to hate you for not wanting it fixed anymore, lol.Just kidding dude, I'm always glad to help you when I can.
#17
11/19/2004 (10:05 am)
You could have tried debugging the onAdd Stefan and see where it's returning false.
#18
11/19/2004 (10:24 am)
I had no know-how of the VC debugger, at that point. Sorry Xavier.
#19
11/19/2004 (6:35 pm)
Yo stefan sorry :)
#20
@Xavier: I looked the only place where the onAdd fails is when the datablock is wrong.
@Stefan: you do realise that you are giving your datablock and the object you're creating the same name. you might want to try changing the name to somthing else. Just a guess.
edit: Grammar
11/19/2004 (8:29 pm)
@Gonzo & Stefan. TSStatic and StaticShapes are two diffrerent things. StaticShape inherits from ShapeBase and requires a datablock while TSStatic inherits from SceneObject and are just used for decoration. You will want to use StaticShape. TSStatic doesn't have any support for animation or sound.@Xavier: I looked the only place where the onAdd fails is when the datablock is wrong.
@Stefan: you do realise that you are giving your datablock and the object you're creating the same name. you might want to try changing the name to somthing else. Just a guess.
edit: Grammar
Torque Owner Stefan Lundmark
function createShape() { %shape= new StaticShape(Door){ dataBlock = Door; }; MissionCleanup.add(%shape); %shape.setTransform("-221.9 492.47 234.441"); return %shape; }Which gave:
My datablock looks like this:
datablock StaticShapeData(Door) { category = "Door"; shapeFile = "data/models/doors/door.dts"; };