PDA

View Full Version : C.O.F.F.E.E | Tags and rendering problem


tcastudios
10-26-2005, 06:09 PM
Hi.
In my coffee adventures I learn alot but still stumble on things I don't get.
Most often fundamental stuff (thanks to my lack of programming skills).

Due to a bug that means that no more than 28 UserData entries can be present at each object, I have split them to two objects, the op and the (Coffee)Tag.
Such as:

var myfader1 = op->#ID_USERDATA:1; // for the op.
and
var myfader2 = op->GetFirstTag()#ID_USERDATA:1; // for the (coffee)Tag.

This works fine -until- I render/render preview.
Then I get a COFFEE error. First I thought it was a bug but a (very) fast answer from
MaxonSupport explained that when rendering, the scene is duplicated. This way we can still work on the scene while rendering, very cool and what we are used to.

However, what happens then is that in the rendered scene, things as Tags get reordered and thus the above example do not work. Most likely a invisible tag(s) is placed infront of the CoffeTag I use.

From support I got the following code to get around the problem:

GetFirstTag(obj, type)
{
var tag = obj->GetFirstTag();
while (tag) {
if (tag->GetType() ==type) return tag;
tag = tag->GetNext();
}
return NULL;
}

To get the first COFFEE tag, you should use then:

var coffeeTag = GetFirstTag(myObj, Tcoffeeexpression);

Now I have spent a couple of hours with every possible variation of that code I can think of and I fail.
What I get in most tries is: "Variable or Function expected"
And that is within the brackets of the very first and very last line of the code above.
In the cases of no coffee errors the code doesn't work at all.

If anybody see anything strange in this and/or know how to aproach this I'd be very happy.

Cheers
Lennart

Per-Anders
10-26-2005, 07:00 PM
make sure that that function is outside of your main function (you can't make nested functions, just classes and structs if you need that sort of thing), i.e.

GetFirstTag(type) {
...
}

main(doc,op) {
...
var tag=GetFirstTag(Tcoffee);
...
}

tcastudios
10-26-2005, 08:45 PM
Thank you!
I'm getting two steps closer.
First, I wouldn't know that it should be before main()....
Second, it works in editor this way (also) but still doesn't in render...

May I ask also, when later transfering this to pluginexpression (.cof)
should it be placed within the Execute or in what part before, or can it just be
placed before Execute "as is" as its own entity?


Cheers
Lennart

tcastudios
10-26-2005, 09:20 PM
And it was of coarse my fault!
I had misspelt GetNext (typed getNext)
It was still gray in the expression editor (should it be that?) so I missed it.
-and- it worked in editor with the wrong spelling..
Let me apologize for confusion and a big thanks for the ongoing help!

Cheers
Lennart

tcastudios
10-27-2005, 02:24 PM
May I ask also, when later transfering this to pluginexpression (.cof)
should it be placed within the Execute or in what part before, or can it just be
placed before Execute "as is" as its own entity?


Yes I may ask. :)
What I did was to make a new entry beforein the "private" part.

GetFirstTag()

Then further down added:
PluginName::GetFirstTag(obj,type)
And the code.

Very much "paint by numbers" and guessing from my part, but it works!
I now have to find out why....
Hope it can help.

Cheers
Lennart

JDP
10-27-2005, 03:15 PM
Hi tcastudios, I strongly recommend you read a beginners C++ book, it will really make life a lot easier for you. You only really need to learn the basic concepts and it will make a big difference. Here is a link to a free book (http://www.uow.edu.au/~nabg/ABC/ABC.html) on the web, you can download the chapters in PDF format. It's not entirely up-to-date but covers all the things you need to know and this shouldn't really affect you unless you want to do c++ programming, and then the differences are only slight. There are also a few chapters on the history of computers and languages that makes interesting reading.

cheers,
JDP

tcastudios
10-27-2005, 04:05 PM
Thanks.
I will/have to look into it.

Cheers
Lennart

tcastudios
10-28-2005, 10:50 PM
I'm sure some are sick of me babbling along about COFFEE forever and ever...
My aim is of coarse to learn as much as possible and hopefully get more people into it by leaving as much info as possible here..

(The following is probably in the "get into programming, please" area but are related to the SDK. The question is made at PluginCafe as well)

The current issue is to place UserData faders on the PluginTag created by the plugin instead of the old (now not needed) COFFEE Tag.
The code above works with the COFFEE Tag and use the line:

var coffeetag = GetFirstTag(op, Tcoffeeexpression);


In the SDK there are the options:
-Tplugin
-Tcoffeeplugin
-Texpressionplugin

I don't get any of these to work by replacing "Tcoffeeexpression".

Any input or hint what to look for?

Cheers
Lennart

JDP
10-29-2005, 10:25 AM
Not sure what type id you need but Tcoffeeplugin doesn't seem valid anymore, in 9.5 at least. Maybe you should ask on plugin cafe.

tcastudios
10-29-2005, 10:59 AM
Thanks. Yeas I got a suggestion at PluginCafe that I will try.

Cheers
Lennart

JDP
10-29-2005, 11:27 AM
Don't know if it was suggested but it seems you need to put in your Plugin Id for the Type Id, at least that is what gets returned when i print out tag->GetType() to the console.
HTH

tcastudios
10-29-2005, 01:32 PM
I tried that in one of my attempts earlier but I'll see if there is another way to do it.
( I only replaced Tcoffeeexpression with the PLugin ID but I assume there is something more to it.)


Cheers
Lennart

JDP
10-29-2005, 02:16 PM
That should be all you need, works fine for me. This is exactly what I used var mytag = GetFirstTag(op, 1001368);, so must be something else wrong. :shrug:

tcastudios
10-29-2005, 02:23 PM
Oh, it does?! Even when you render/render preview?

I'll give that another go.

Thanks!

Cheers
Lennart

JDP
10-29-2005, 02:54 PM
Well I don't know your exact situation but I have accessed a user data field on the tag and used it's data in a calculation then took the output and assigned it to a text field of a text spline attached a sketch&toon style tag and rendered in editor and to picture viewer and all worked as expected.

Cheers,
JDP

tcastudios
10-29-2005, 03:10 PM
Thanks JDP for your help. It actually works very well today when I used the Plugin ID instead of Tcoffeeexpression. I must have done something really wrong yesterday. Most likely spelt/typed some errors myself. And/or the old COFFEE tag might have interfered in the process.

Again, thank you very much taking your time looking into this.

Cheers
Lennart

JDP
10-29-2005, 03:20 PM
You're welcome Tcastudios. It was probably a syntax error, they are often the cause of much confusion. :)

CGTalk Moderation
10-29-2005, 03:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.