Author Topic: Question: TextPacket output  (Read 7957 times)

0 Members and 1 Guest are viewing this topic.

howardzzh

  • WM Pro Beta Tester
  • World Machine Veteran
  • ***
  • Posts: 22
    • View Profile
    • Terrain Synthesis
Question: TextPacket output
« on: July 07, 2007, 08:36:25 PM »
Hi everyone,
    I encounted an linking error while outputing a TextPacket from a device that I am creating. The error message said that void TextPacket::setText(const char *txt) is an undefined reference. I wonder if it's because the library file wasn't included in the PDK or if the function is not defined yet.

I've temporarily bypassed this problem by defining my own inline function in the TextPacket.h to overide the default setText.

inline void TextPacket::setText(const std::string& txt)
{
   int len = txt.length();
   body = new char[len+1];
   memcpy(body, txt.c_str(), len);
   body[len] = NULL;
}

However, I could not get the "Text Output" device (which is hooked to the text output of my device) to write a file to the disk. There is no error or warning, just that the "Write output to disk" didn't do anything. Also, after the device is built, it will result an exception whenever I want to switch to either the "Layout view" or the "Explorer view". The device behaves fine if I just swith between the other views.

I wonder if I missed anything here. I would really appreciate your help if you've had similar experience. Thank you!

Howard

Remnant

  • Author
  • World Machine Guru
  • *****
  • Posts: 2311
    • View Profile
    • http://www.world-machine.com/
Re: Question: TextPacket output
« Reply #1 on: July 08, 2007, 05:31:15 PM »
The text packet body text must be allocated from the WM Core's heap, otherwise there will be potential problems across DLL boundaries. Use WMAlloc() and WMFree() to allocate/delete text.

The Text Output device should output text to the file you specified if the above is correct.
-- Stephen Schmitt
- Creator of World Machine

howardzzh

  • WM Pro Beta Tester
  • World Machine Veteran
  • ***
  • Posts: 22
    • View Profile
    • Terrain Synthesis
Re: Question: TextPacket output
« Reply #2 on: July 08, 2007, 10:08:12 PM »
Thank you Remnant.
     After using WMAlloc() to allocate the memory for the TextPacket body, I no longer get any exception from switching between different views. However, I still have two questions.

1.  Was the function "void TextPacket::setText(const char *txt)" defined in the libraries included in the PDK? The reason I ask this question is because it showed up as an undefined reference for me when I built my device. That's why I have to write my own setText function which is probably incorrect. I would like to use the official version if somehow I just missed.


2. I probably used the text output device in an incorrect way since I still could not get it to write any text to a file.

Here is how I added a second output port in the constructor
    AddPort(0, 1, WMP_text, -1);

Here is how I tried to store the data to the output

bool PluginPPA::Activate(BuildContext &context)
{
    ...
    StoreData(txtBranchPoints, 1, context);
    ...
}


I also tried to simply link the "Text input" device to the "Text output" device and could not get it to output a text file.  What I did was to link it to a text output port, build the whole thing, specify the output filename, and then click the "Write ouput to disk!". I wonder if I did anything wrong with the "Text output" device. Thank you for the help.
« Last Edit: July 08, 2007, 10:16:51 PM by howardzzh »
Howard

Remnant

  • Author
  • World Machine Guru
  • *****
  • Posts: 2311
    • View Profile
    • http://www.world-machine.com/
Re: Question: TextPacket output
« Reply #3 on: July 10, 2007, 03:04:24 PM »
Yes.. I just looked into it, and TextOutput output was temporarily disabled. Text I/O is there on a "might be useful" basis rather than being actively used by WM devices right now, so its definitely off of the high traffic code path and I didn't notice. Fixed.


-- Stephen Schmitt
- Creator of World Machine

howardzzh

  • WM Pro Beta Tester
  • World Machine Veteran
  • ***
  • Posts: 22
    • View Profile
    • Terrain Synthesis
Re: Question: TextPacket output
« Reply #4 on: July 10, 2007, 06:22:49 PM »
Thank you for clarifying this.
Howard

Alexander

  • WM Pro Beta Tester
  • World Machine Veteran
  • ***
  • Posts: 25
    • View Profile
Re: Question: TextPacket output
« Reply #5 on: July 13, 2007, 10:20:35 AM »
Just wanted to add that a lot of people are looking forward to your plugins Howard.  :D

howardzzh

  • WM Pro Beta Tester
  • World Machine Veteran
  • ***
  • Posts: 22
    • View Profile
    • Terrain Synthesis
Re: Question: TextPacket output
« Reply #6 on: July 14, 2007, 10:34:54 PM »
Thank you, Alex. I just posted the first part of the plug-in series here, I will start working on the next part and hopefully, I can finish them before the WM Pro version comes out.
Howard