Fenric's Plugins

13»

Comments

  • DartanbeckDartanbeck Posts: 21,564
    mindsong said:

    FWIW, I believe Fenric was planning to Open-Source his toolkit. I think the logistics of 'proper' Open-Sourcing (appropriate to his intentions) was the hold-up. Like many, here I have grand plans, semi-grand skills, and completely non-grand free-time, but I'm excited by the idea of digging in and tweaking some of these utilities someday. Maybe he'll post the code just before I'm able to do something with it :)

    I'd be happy to help with a "beer-starter" donation campaign (for Philemo, Alberto, and Sparrow-Hawk3D too! - and Selina too - I wonder how she's doing) to help out. I sponsor the few patreons a bit and occasionally do a paypal send, but it only goes so far and I don't use any of these things as much as I'd like.

    All ideas welcomed, and hopefully some of these things will get a second-chance-at-life with the sharing of work done and available talent.

    Thanks in advance to all who share with this community!

    cheers,

    --ms

    Wow. Rock On, mindsong!

    Love and Art!

  • NexySaloonNexySaloon Posts: 71

    Very sweet of both of you Fenric & Omega Man, I was missing one, who knows why! Wishing you all the best Fenric, have website, will email you tomorrow. - Rebecca

  • cynthia1968cynthia1968 Posts: 34
    edited May 2020

    Thanks to Fenric, I decided to look at the source code of "FixPoseChannels". It's programmed in C#. 

    Although I haven't programmed in C# before, I decided to take a close look at the source code, and made some adjustments:

    ---// source code of Form1.cs //---
     

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;

     

    namespace FixPoseChannels
    {
        public partial class Form1 : Form
        {
            public string folder;
            public string countItems;


            public Form1()


            {
                InitializeComponent();
                

     

            }

            

     

            private void SelectFigure_Click(object sender, EventArgs e)
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Poser character|*.cr2";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Figure.Text = dlg.FileName;
                    Properties.Settings.Default.PoserChar = Figure.Text;
                    SaveAllSettings();

                }
            }

            private void SelectPose_Click(object sender, EventArgs e)
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Select pose|*.pz2";


                if (dlg.ShowDialog() == DialogResult.OK)
                {

                    Pose.Text = dlg.FileName;
                
                }
            }

            private void Go_Click(object sender, EventArgs e)
            {
                PoserFigure figure = new PoserFigure();

                string testIfAlreadyUsed;

                testIfAlreadyUsed = Pose.Text + ".old";

                if (File.Exists(testIfAlreadyUsed))
                {
                    MessageBox.Show(Pose.Text + " is already fixed.");

                    //--> Get next pz2 file from PoseList

                    try
                    {
                        if (PoseBox.Items.Count > 0)
                        {
                            PoseBox.Items.RemoveAt(0);
                            PoseBox.SelectedIndex = 0;
                            return;
                        }
                    }
                    catch (Exception)
                    {
                        return;
                    }
                }
                else
                {


                    // First, read in the figure and build a list of channels
                    using (StreamReader reader = File.OpenText(Figure.Text))
                    {
                        FigureParseMachine.Start();

                        string CurrentLine = reader.ReadLine();
                        while (CurrentLine != null)
                        {
                            Status.Text = "Reading CR2 File.";
                            Application.DoEvents();

                            if (CurrentLine.Contains("readScript"))
                            {
                                string scriptFileName = CurrentLine.Replace("readScript ", "").Replace("\"", "").Trim();
                                Status.Text = "ReadScript '" + scriptFileName + "'";
                                Application.DoEvents();
                                ReadScriptResolver resolver = new ReadScriptResolver(runtimeFolder.Text, scriptFileName);
                                string subLine = resolver.readLine();
                                while (subLine != null)
                                {
                                    PoserActor actor = FigureParseMachine.ProcessLine(subLine);
                                    if (actor != null) figure.Actors.Add(actor);
                                    subLine = resolver.readLine();
                                }
                            }
                            else
                            {
                                PoserActor actor = FigureParseMachine.ProcessLine(CurrentLine);
                                if (actor != null) figure.Actors.Add(actor);
                            }
                            CurrentLine = reader.ReadLine();
                        }
                    }

                    PoserActor lastActor = FigureParseMachine.getLastActor();
                    if (lastActor != null) figure.Actors.Add(lastActor);

                    // Step one: Inject the names into the channels - otherwise you have to start with
                    // a CR2 that was already injected, which rather defeats the purpose.
                    try
                    {
                        using (StreamReader reader = File.OpenText(Pose.Text))
                        {
                            PoseParseMachine.StartForName();
                            Status.Text = "Reading PZ2 file and modifying channel names.";
                            Application.DoEvents();

                            string CurrentLine = reader.ReadLine();
                            while (CurrentLine != null)
                            {
                                PoseFix fix = PoseParseMachine.ProcessLineForName(CurrentLine);
                                if (fix != null)
                                {
                                    if (!String.IsNullOrEmpty(fix.Name)) figure.UpdateDisplayName(fix);
                                }
                                CurrentLine = reader.ReadLine();
                            }
                        }
                    }

                    catch (Exception Err)
                    {
                        MessageBox.Show(Err.Message);
                        return;
                    }

     

                    // Step two: build the new PZ2.
                    try
                    {
                        using (StreamReader reader = File.OpenText(Pose.Text))
                        {
                            using (StreamWriter writer = File.CreateText(Pose.Text + ".fix"))
                            {
                                Status.Text = "Resolving ERC link names and creating new PZ2 file.";
                                Application.DoEvents();
                                PoseParseMachine.Start();

                                string CurrentLine = reader.ReadLine();
                                while (CurrentLine != null)
                                {
                                    PoseFix fix = PoseParseMachine.ProcessLine(CurrentLine);
                                    if (fix != null)
                                    {
                                        string newChannel = figure.LookForAlternate(fix);
                                        if (newChannel != null)
                                        {
                                            CurrentLine = CurrentLine.Replace(fix.Channel, newChannel);
                                        }
                                    }
                                    writer.WriteLine(CurrentLine);
                                    CurrentLine = reader.ReadLine();
                                }
                            }
                        }

                    }

                    catch (Exception Err)
                    {
                        MessageBox.Show(Err.Message);

                        return;
                    }


                    Status.Text = "Backing up old pose file";
                    Application.DoEvents();
                    try
                    {
                        File.Move(Pose.Text, Pose.Text + ".old");

                        File.Move(Pose.Text + ".fix", Pose.Text);
                        
                        countItems=PoseBox.Items.Count.ToString();

     

                        // MessageBox.Show("All done!", "Channel Name Repair");
                        if (string.IsNullOrEmpty(countItems))
                        {

                        }
                        else
                        {
                            PoseBox.Items.RemoveAt(0);
                            PoseBox.SelectedIndex = 0;
                        }

                        Status.Text = "Ready...";
                        Application.DoEvents();
                    }
                    catch (Exception Err)
                    {
                        MessageBox.Show(Err.Message);

                        return;

                    }

                    try
                    {
                        //--> Get next pz2 file from PoseList
                        if (PoseBox.Items.Count > 0)
                        {
                            if (PoseBox.Items.Count == 0)
                            {
                                MessageBox.Show("Nothing to see here, move along 1");
                                return;
                            }
                            else
                            {

                                PoseBox.Items.RemoveAt(0);
                                PoseBox.SelectedIndex = 0;
                            
                                                        }
                        }
                    }
                    catch (Exception)
                    {

                        MessageBox.Show("Nothing to see here, move along 3");
                        return;
                    }
                    

                }
            }

            private void Form1_Load(object sender, EventArgs e)
            {

                runtimeFolder.Text = Properties.Settings.Default.PoserDir;
                Figure.Text = Properties.Settings.Default.PoserChar;
                folder = Properties.Settings.Default.PoserRuntime;
                

            }
            

            private void runtimeFolder_TextChanged(object sender, EventArgs e)
            {
             
            }

            private void Status_Click(object sender, EventArgs e)
            {

            }

            private void SelectDirectory_Click(object sender, EventArgs e)
            {

                // if a directory is already selected, retrieve selected directory
                
                    FolderBrowserDialog dlg = new FolderBrowserDialog();
                    // if a directory is already selected, retrieve selected directory
                    if (string.IsNullOrEmpty(folder))
                    {
                        // do nothing 

                    }
                    else
                    {
                        dlg.SelectedPath = folder;
                        PoseBox.Items.Clear();
                    }


                    if (dlg.ShowDialog() == DialogResult.OK)
                    {

                        folder = dlg.SelectedPath;
                        

                        
                        string[] posefiles = Directory.GetFiles(folder, "*.pz2");

                        // Test if selected directory contains pose files.

                        try
                        {
                            if (posefiles[0] != null)
                            {
                                PoseBox.Items.AddRange(posefiles);
                                PoseBox.SelectedIndex = 0;
                            }

                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Selected directory " + folder + " doesn't contain Pose files.");
                            return;
                        }

                    }

            }

            
        

            private void PoseBox_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (PoseBox.Items.Count >= 0)
                {
                    if (PoseBox.SelectedIndex ==-1)
                    {
                        // there's nothing to do.
                        return;
                    }
                    PoseBox.SelectedIndex = 0;
                    Pose.Text = PoseBox.SelectedItem.ToString();
                }
                
            }

            private void Figure_Click(object sender, EventArgs e)
            {

            }

            

            public void SaveAllSettings()
            {
                // Save all settings
                
                Properties.Settings.Default.PoserRuntime = folder;
                Properties.Settings.Default.PoserChar = Figure.Text;
                Properties.Settings.Default.PoserDir = runtimeFolder.Text;
                Properties.Settings.Default.Save();

            }

        }
    }

    ----// end of source code //--

    I used Fenric's code, and added some sub routines to make the fix pose easier to working on, also using settings, so that the program now keeps the 'selected figure' and remembers the poser directory. Default is C:\Poser 7, but on my PC it's D:\Poser 7\

    Also added a list box with poses. It's still buggy but this is how the programs looks:

     ​

    If I'm done, debugging, I'll put it online as open source :-)
     

    Post edited by cynthia1968 on
  • FenricFenric Posts: 351

    Sorry about the delay, life got busy the last few months - can't imagine why :D

     

    Anyway, I've decided to just give up on the open source notion, as these are plugins the license just gets too weird and verbose. So, I'm going to go to the other end of the spectrum: free for all. Here you go, public domain, go nuts.

    Nearly 12 megabytes, so be warned!

    http://www.fenric.com/download/CarraraSources.zip

  • WendyLuvsCatzWendyLuvsCatz Posts: 38,206

    heart hopefully someone can do something with that

    we would rather you back in our fold though to be honest 

  • Bunyip02Bunyip02 Posts: 8,602

    Thanks to Fenric, I decided to look at the source code of "FixPoseChannels". It's programmed in C#. 

    Although I haven't programmed in C# before, I decided to take a close look at the source code, and made some adjustments:

    If I'm done, debugging, I'll put it online as open source :-)
     

    Thanks, last programing I did was Fortran at Uni, glad someone is doing an update of Fenric's excellent work !

  • Bunyip02Bunyip02 Posts: 8,602

    heart hopefully someone can do something with that

    we would rather you back in our fold though to be honest 

    +1 yes

  • mindsongmindsong Posts: 1,701

    heart hopefully someone can do something with that

    we would rather you back in our fold though to be honest 

    ++

    (lol on the "the heck with it - here!" for the source code - I soo get that sometimes! :)

    As I like to tell my good friends: "You're alright, I don't care *what* they say about you!" ...

    Thanks a bunch for doing the plugins to start with - I bought them all and they were worth every penny, and thanks a zillions for giving them a chance to live on in the Carrara world!

    Even if you leave us, your legacy is treasured and appreciated.

    Best to you - and stop in when you can and vote for your favorite challenge entries - and let us know when you add updates to your Fox Den novel.

    cheers and beers!

    --ms

  • mindsongmindsong Posts: 1,701

    Thanks to Fenric, I decided to look at the source code of "FixPoseChannels". It's programmed in C#. 

    Although I haven't programmed in C# before, I decided to take a close look at the source code, and made some adjustments:

    ---// source code of Form1.cs //---

     

    ...

     

    If I'm done, debugging, I'll put it online as open source :-)
     

    This is exciting - and having a capable helping-hand available that might be able to advise those of us who feel ambitious with this code is inspiring too. I hope it wouldn't be presumptuous to ask for help if we get stuck along the way.

    cheers,

    --ms

  • MistaraMistara Posts: 38,675

    the shader tweaker tool is so sublimely awesome

    50

    shader tweaker.JPG
    814 x 604 - 100K
  • HeadwaxHeadwax Posts: 9,987

    Mistara said:

    the shader tweaker tool is so sublimely awesome

    50

    Yes a land in itself

  • StezzaStezza Posts: 8,054

    I use it all the time yes

  • mschackmschack Posts: 337

    It allows you to change shasder setting outside the shader room?

  • StezzaStezza Posts: 8,054

    yep.. I always use it to adjust the highlight, shine, texture bump and sampling settings yes

Sign In or Register to comment.