Logo
Toggle Menu
  • home
  • blog
  • about
    • about this site
    • contact
    • privacy policy
  • cinema 4d
    • plugins
    • creating c4d plugins
    • plugin cookbook
    • software
  • models
    • nodes
    • plants 1
    • other models - 1
    • other models - 2
  • osl
    • writing osl shaders
    • osl shaders for download

Creating a new plugin: 4

Creating the atoms

Now we have all the atom data required, it's time to create the atoms. This plugin is an ObjectData plugin, so creating objects will be done in GetVirtualObjects (GVO). Before we do that, there is an additional set of data that will be needed for the display. Supplied with the plugin is a comma-separated CSV file. This is a simple text file containing data about the first 94 elements in the periodic table. This data includes:

  • atomic symbol
  • colour (CPK colours, see here for details)
  • covalent radius
  • mass
  • Van der Waal radius

This data lets us colour and scale the sphere representing the atom. The file (ptable.csv) is loaded when the plugin runs, keeping it in memory as an array (m_chElements) of structures holding the above data. As long as we know the atomic number of the atom to be created, we can use that as an index into the array of elements and use the colour data etc. for that atom. So, in GetVirtualObjects() the process is very simple:

        if(m_theOpts.display != PROT_MOL_DISPLAY_BONDS)
        {
            for (index = 0; index < m_ProtAtoms.GetCount(); index++)
            {
                atomObj = CreateAtom(hh, index);
                if (atomObj != nullptr)
                {

The first line simply bypasses the atom creation if the user only wants to show bonds. GVO will call the function CreateAtom() with the index of the atom structure in the array of atoms, repeating for every atom in the array. All the CreateAtom( ) function does is generate a sphere primitive with the colour specified for that atom in the array m_chElements, and scales it using the option selected by the user, again using radius or mass data from m_chElements. The sphere is returned to GVO, which inserts it below a placeholder object - which is a null object in this case. GVO then returns the null object to the scene with all its atoms as child objects of the null.

The result

The above is basically all there is to it. The hard work was done when loading the atom data from the PDB file. What you get looks like these examples here:

  • Glucagon
  • Insulin
  • Gastrin-releasing peptide receptor
  • CFA/I Fimbrial subunit B
  • Glucagon
    Simple one-chain molecule with 29 residues.
  • Insulin
    More complex protein with two chains and a total of 51 residues.
  • Gastrin-releasing peptide receptor
    Much larger molecule with 521 residues in one chain and over 3400 atoms in the peptide chain.
  • CFA/I Fimbrial subunit B
    Complex molecule with 3 chains comprising more than 440 residues and over 3,200 atoms.

You can see from the colours that, as you'd expect, most atoms are carbon, nitrogen and oxygen, with the occasional sulphur atom (the bright yellow ones).

Good progess so far, but...

This is interesting in itself and proves that the atom loading part works fine. The next part is really tricky, and it's how to show the covalent bonds in the molecule. That's essential to get some idea of the structure of the molecule. However, it's going to take a while to figure out, because not only are there the bonds within each amino acid residue, but also bonds between peptide chains. And the main issue is that, unlike simple molecules in .mol or .sdf files (see ChemLoader and its manual for more on this) there is very little or no bond information in the PDB file. How do we handle that?

Page last updated May 23rd 2026

Blog articles

Creating a new plugin: 8 (June 4th 2026)

Creating a new plugin: 7 (May 31st 2026)

Creating a new plugin: 6 (May 28th 2026)

Creating a new plugin: 5 (May 26th 2026)

Creating a new plugin: 4 (May 23rd 2026)

Creating a new plugin: 3 (May 22nd 2026)

Creating a new plugin: 2 (May 20th 2026)

Creating a new plugin: 1 (May 17th 2026)

The 'Space' plugins (May 7th 2026)

Creating PBR materials (March 24th 2026)

Data Storage - Then and Now (March 6th 2026)

Old Poser assets (March 2nd 2026)

More Noise, please (January 18th 2026)

Using GIT in VS 2022 (December 26th 2025)

Handling missing plugins (December 12th 2025)

Plugin compatibility with R2026 (November 24th 2025)

Affinity is now free! (November 3rd 2025)

World Creator 2025.1 (October 10th 2025)

So that was Cinema R2026? (September 19th 2025)

How to browse 3D assets (August 24th 2025)

Using Unity assets in Cinema 4D (August 15th 2025)

Plant Factory->Cinema 4D->World Creator (August 12th 2025)

Viewing glTF files (August 9th 2025)

Tessellation part 2 (August 5th 2025)

Shader writing with OSL - 3 (July 11th 2025)

Tessellation (June 23rd 2025)

Creating plants for C4D (June 15th 2025)

Adobe alternatives (May 28th 2025)

Using Graswald assets in C4D (May 7th 2025)

Which Mac for plugin development? (May 3rd 2025)

Why do plugin writers do it? (April 11th 2025)

Updating StarScape (February 26th 2025)

Using Cinema 4D shaders in Redshift (January 31st 2025)

PHP and MySQL (December 19th 2024)

Shader writing with OSL - 2 (November 11th 2024)

Shader writing with OSL (October 29th 2024)

StarScape (September 25th 2024)

Converting plugins from C4D 2024 to 2025 (September 16th 2024)

Cinema 4D 2025 and macOS plugins (September 15th 2025)

© 2021-2025 Microbion. All Rights Reserved.