Tag Archives: 3D

Blender 3D – sin mesh object with python.

This is a simple example of create one object from vertrices and edges using sin function.
First you need to create the mesh with: bpy.data.meshes.new .
The n number is random, you can use any number for vertices and edges.
This number is points for the drawing sin function.
The spaces variable is the range from this points.
Using for statements we can draw the sin function.
The last step is to add all of this into one object named sin.
This object will be link to the scene.
See the source code of this tutorial:

Posted in 3D, All, Blender 3D, Programming, Python. Tagged with , , , , , , , .

Unity 3D – Shaders scripts – part 001.

This is the first tutorial in a series of shaders tutorials in Unity 3D.
Open your Unity 3D project and using right click mouse add a Unlit shader to your project, see the image:

Rename your shader file and open this shader with right click mouse.
You will see the content of the default shader into your Visual Studio IDE.
Let’s see my shader example named NewUnlitShader :

When you write your first shader then you need to know some rules:

  • take a look at this link to see the most common variables and HLSL type and rules;
  • example: vec2 types with float2;
  • example: mat2 with float2x2;
  • example: vec3(1)  is float3(1,1,1);
  • example: mainImage(out vec4 fragColor, in vec2 fragCoord) is float4 mainImage(float2 fragCoord : SV_POSITION) : SV_Target;
  • example:
  • Shader “Unlit/NewUnlitShader” – the shader will add into your material from : Unlit – NewUnlitShader;
  • you can change the name NewUnlitShader , but you need to change the name of the file shader;
  • the body of shader start with word CGPROGRAM and end with word ENDCG;
  • Shader Level of Detail (LOD) is a number (see doc);
  • the Properties word is used for: inputs like a texture (see and _MainTex (“Texture”, 2D) = “white” {} );
  • the SubShader word is used to start define your settings for shader and the content of shader;
  • the words like: #pragma, #include , struct  are reserved words and is used to set and make the body of shader;
  • any shader come with : vertex shader body and fragment shader body;

One simple example of settings for vertex and fragment body shader but also you can have pixel shader body:

The next step is to add this to your shader:

Now, about vertex shader this can manipulate the attributes of vertices.
The fragment shader is the same as pixel shader.
The fragment/pixel shader is part of the rasterization steps.
You can see in my first example I used fragment shader not pixel shader:  #pragma fragment frag
The result is this function :

This is first part of this tutorials about shaders and you will need to learn all of this and make connections with my examples.

Posted in All, Programming, Unity 3D. Tagged with , , , , .

Blender 3D – script to show python code under console.

To run this script yo need to select the render to Cycles Render.
Then go to Compositing from Screen layout ( in the top of the screen) and select Use Nodes from Material.
This will make a default material with a Diffuse BSDF .
The next step is to select Scripting from Screen layout.
This will allow you to make a script.
Create a new text and add this source code:

Press keys Alt+P or run the script from Text – Run Script.
When you click on tabs or select something the print function will print the python code into Console output area.
This can be used to see parts of python code from addons or Blender API.
Example with Archimesh addon :
You need to have this addon install and press the books button.
The result of this source code is show into console output and can be used with console shell to add books into your Scene:

Posted in 3D, All, Blender 3D, Programming, Python. Tagged with , , , , , , , .

The Virtual Reality – part 001.

Briefly the acronym is recognized as VR and come with this comes with this definition:
Virtual reality is the term used to describe a three-dimensional, computer generated environment which can be explored and interacted with by a person. That person becomes part of this virtual world or is immersed within this environment and whilst there, is able to manipulate objects or perform a series of actions.
You can try getting steps with these links:

Stages are simple: a 3D content is put into a space called a scene and is presented in a special way for virtual reality devices.
Hope this help !

Posted in 3D, All, Virtual Reality. Tagged with , , , .

Blender 3D – the measurements addon .

This addon help us with infos and data about measurements with Blender 3D working and output.
If you have used this addon the you need to delete it from this folders:
\Blender Foundation\Blender\2.78\scripts\addons
\AppData\Roaming\Blender Foundation\Blender\2.78\scripts\addons

The install is easy , just open menu from: File – User Preferences … – Install from File ….
The tool can be fond into the left area of Blender 3D screen on Display tab ( press T key to see the Panel with Display tab).
One simple example is to see the angle of the cube.
So select the Cube object, press Tab key for edit , select with Shift key and right click mouse three vertices .
With all three vertices press Angle button to see the 90 degrees.
If you want to see area then you need to select four vertices and then press Area button.
You can see the distance to origin with Origin button.
The size of the edge can be see with two vertices selected and the using the Segment button.
To put a label , the select just one vertice then add your text and color on MeasureIt Configuration.
Now you can press the Label button.
For rendering the result image is store for UV Editing and can be selected like image for UV;
The last version is 1.70 and come with new features and changes:

  • Redesign of Mesh Debug, Configuration, and N-panel settings layouts ;
  • Added option to rotate text and measurements by angles specified in degrees ;
  • Added option to horizontally align text to left, center, or right ;
  • Added option to expand or collapse all N-panel settings ;
  • Added options to Mesh Debug to display indexes of scene objects and mesh edges ;
  • Added options to Mesh Debug to display object and vertex global locations ;
  • Fixed bug causing NoneType errors when measurments were drawn off screen ;
  • Fixed bug preventing vert locations from displaying unless vert index option was enabled ;
  • Fixed bug preventing mesh position from updating when using MeasureIt’s Render button ;
  • Fixed ensure_lookup_table bug when geometry with measurements was edited ;
  • Hid most/all adjustment options when they would have no affect ;

The addon can be found here.

Posted in All, Blender 3D. Tagged with , , , , .