Friday, June 2, 2023

Tool : Debug

 As the features in C are so complex I will write a Debug tool for each theme. The software will have a "Folder" or additional folder called "Debug tools", where they will be there. It makes various tests for example the images: it loads the image tests and outputs the image and all the image functions information; Maybe check for errors, see if the image is at 100%. This will help develop the software, and perform various tests. With this tool you can develop only the part of the images and connect later later, without all the code working.

Also found this software which have a interface working is very nice to study code. Since have information we can't find in the toturials.

https://sites.google.com/a/liesenberg.biz/cjogos/home/software/interfaces-graficas-em-c
http://www.enchantia.com/software/graphapp/

 

[b]The Box Version 0.0.2[/b]

Still it does not have that much work that i wanted but is the possible work. The file have like 30 pages. It should have every thing you need to understand and develop. It explain: interfaces, code, objects, objectives, tools, tutorials, planning, etc…

2 PDF, and the box folder :

You should have access to the public folder

https://drive.google.com/drive/u/1/folders/1LqXNvuu5p5t7cQ4yH-7YEqugL7glslMk

 

[b]Update[/b]

Missed a small thing, how to convert code to procedural to use with the global objects.

Think the theory of structural programming could also be called stack programming, or have a stack part in it, because we do things by stacks.

In this example we are going to see a stack.

In this function from Lips of Luna, nodes for 3D models. How to covert it to procedural code:

[code]
LIMdlModel* limdl_model_new_copy (

const LIMdlModel* model,int shape_keys)
{
 
int i;
LIMdlModel* self;


self = lisys_calloc (1, sizeof (LIMdlModel));
if (self == NULL)
 return NULL;
self->flags = model->flags;
self->bounds = model->bounds;

if (model->hairs.count)
{
 self->hairs.array = lisys_calloc (model->hairs.count, sizeof (LIMdlHairs));
 self->hairs.count = model->hairs.count;
 for (i = 0 ; i < model->hairs.count ; i++)
  limdl_hairs_init_copy (self->hairs.array + i, model->hairs.array + i);
}

if (model->lod.count)
{
    self->lod.array = lisys_calloc (model->lod.count, sizeof (LIMdlLod));
    self->lod.count = model->lod.count;
    for (i = 0 ; i < model->lod.count ; i++)
        limdl_lod_init_copy (self->lod.array + i, model->lod.array + i);
}
if (model->materials.count)
{
    self->materials.array = lisys_calloc (model->materials.count, sizeof (LIMdlMaterial));
    self->materials.count = model->materials.count;
    for (i = 0 ; i < model->materials.count ; i++)
        limdl_material_init_copy (self->materials.array + i, model->materials.array + i);
}
if (model->nodes.count)
{
    self->nodes.array = lisys_calloc (model->nodes.count, sizeof (LIMdlNode*));
    self->nodes.count = model->nodes.count;
    for (i = 0 ; i < model->nodes.count ; i++)
        self->nodes.array[i] = limdl_node_copy (model->nodes.array[i], 1);
}[/code]

The node.c file which will be kind of a stack if it works in C, didn't test it. This how i do it in PHP.

[code]#include model.h / global variables on models
#include draw.h

models = “model1, model2, model3” // models to load

#include node.c

----------Start  node.c----------------

while (models != not empty)
{
    for (i = 0 ; i < model->materials.count ; i++)
{
            limdl_material_init_copy (self->materials.array + i, model->materials.array + i);
    }

    for (i = 0 ; i < model->nodes.count ; i++)
            self->nodes.array[i] = limdl_node_copy (model->nodes.array[i], 1);
    }

}
---------end file----------

models_array // loaded models

#include draw.c // draw the models
[/code]

the global variable should have the models loaded after the include of the file. The file is only procedural code. and is very fast. and very easy to read. 


[b]Tutorial on code design and how the code is looking like :[/b]

[u]Code refactor on Lips of Luna[/u]

The refactor of code does not seem that hard once we have the planning, was able to refactor high amount of code. Doing like this: first remove all dependency and leave only procedural code, “leave notes in case we want to know what is going on lather” do not remove libraries because on 2º stage we are going to need to get that extra code from the dependency's.

[u]Object planning[/u]

Object planning this is already on the internet i din't invent it, the theory : “if a object is doing to much is bad and is if bad doing to little. So a object should deal with a set of functions in a proper way". For example Lips 3D model load first file is ok in therms of planning but the 2º part i called in this example : ”open model" and “load of model”, in this case is load of model, there are several files scattered with 50 lines  which, in this case is doing to little.

I will convert them in to the “load model”, to deal with materials, particles, etc…

[u]Code [/u]

Is more advanced then my PHP engine, it was only one layer, or two layers. In here we have several layers, and inheritance.

I usely put all variables on top to be more readable, but in here since we may reuse variables, putting them above the include, for now putting the settings in if and else, if need some kind of setting from file is just a matter of setting to true. “files_list = 1; // true”

to refactor functions : it transform them in a if with a true state, to use e need to set it to true.

But still have to see what will be the better design.

[u]Dynamic functions[/u]

For now setting all to file object non dynamic, lather when it evolves if procedural can't handle it i will create a “system object” to pass things to procedural or handle the parts procedural can't.

A bit like PHP : it uses procedural based on a Object, or a set of objects.

[u]How the code looks:[/u]
 

[code]#include variables.h
#mouse.h
#keys.h

language = "PT";
#include language.c

operating_system = "windows";
#include settings.c

mouse_arrow = "costume arrow";
#include mouse.c

keyboard_esq = "jump";
#include keys.c

//Concatenate

#include path.c //Open directorys

folders = {"", "c:/the_box/projects/models", "c:/the_box/projects/images"};
folders_index = {"models", "images"};
files_list = 1; // true
directory_list = 1; // true

#include open_folders.c // open folder

images = {"image1.jpg", "image2.jpg"};
images_index = {"menu_button", "menu_effect"};
#include jpg.c

models = {"model1.3D", "model2.3D"};
models_index = {"character", "character2"};
#include open_models.c // models open

3D_low_poly;

#include load_models.c

window_height = 400;
window_width = 400;

#include window.c

control_height = 400;
control_width = 400;

#include control.c

text_style = "liberation serif";
text_color = "black";

property_background = "white";
property_menu;

property_buttons = {"button1", "button2", "button3"};

property_button;

#include interface.c

draw_menu;
draw_map;
draw_models;

#include draw.c[/code]

No comments:

Post a Comment

hi

Media Fire

 Xml file for macros now at Media fire.