Posted on Leave a comment

New features in Red Hat CodeReady Studio 12.13.0.GA and JBoss Tools 4.13.0.Final for Eclipse 2019-09

JBoss Tools 4.13.0 and Red Hat CodeReady Studio 12.13 for Eclipse 2019-09 are here and waiting for you. In this article, I’ll cover the highlights of the new releases and show how to get started.

Installation

Red Hat CodeReady Studio (previously known as Red Hat Developer Studio) comes with everything pre-bundled in its installer. Simply download it from our Red Hat CodeReady Studio product page and run it like this:

java -jar codereadystudio-<installername>.jar

JBoss Tools or Bring-Your-Own-Eclipse (BYOE) CodeReady Studio requires a bit more.

This release requires at least Eclipse 4.13 (2019-09), but we recommend using the latest Eclipse 4.13 2019-09 JEE Bundle because then you get most of the dependencies pre-installed.

Once you have installed Eclipse, you can either find us on the Eclipse Marketplace under “JBoss Tools” or “Red Hat CodeReady Studio.”

For JBoss Tools, you can also use our update site directly:

http://download.jboss.org/jbosstools/photon/stable/updates/

What’s new?

Our main focus for this release was improvements for container-based development and bug fixing. Eclipse 2019-06 itself has a lot of new cool stuff, but I’ll highlight just a few updates in both Eclipse 2019-06 and JBoss Tools plugins that I think are worth mentioning.

Red Hat OpenShift

OpenShift Container Platform 4.2 support

With the new OpenShift Container Platform (OCP) 4.2 now available (see the announcement), even if this is a major shift compared to OCP 3, Red Hat CodeReady Studio and JBoss Tools are compatible with this major release in a transparent way. Just define your connection to your OCP 4.2 based cluster as you did before for an OCP 3 cluster, and use the tooling!

CodeReady Containers 1.0 Server Adapter

A new server adapter has been added to support the next generation of CodeReady Containers 1.0. Although the server adapter itself has limited functionality, it is able to start and stop the CodeReady Containers virtual machine via its crc binary. Simply hit Ctrl+3 (Cmd+3 on OSX) and type new server, which will bring up a command to set up a new server.

crc server adapter

Enter crc in the filter textbox.

You should see the Red Hat CodeReady Containers 1.0 server adapter.

Select Red Hat CodeReady Containers 1.0 and click Next.

All you have to do is set the location of the CodeReady Containers crc binary file and the pull secret file location, which can be downloaded from https://cloud.redhat.com/openshift/install/crc/installer-provisioned.

Once you’re finished, a new CodeReady Containers server adapter will then be created and visible in the Servers view.

Once the server is started, a new OpenShift connection should appear in the OpenShift Explorer view, allowing the user to quickly create a new Openshift application and begin developing their AwesomeApp in a highly replicatable environment.

Server tools

Wildfly 18 Server Adapter

A server adapter has been added to work with Wildfly 18. It adds support for Java EE 8 and Jakarta EE 8.

EAP 7.3 Beta Server Adapter

A server adapter has been added to work with EAP 7.3 Beta.

Hibernate Tools

Hibernate Runtime Provider Updates

A number of additions and updates have been performed on the available Hibernate runtime providers.

The Hibernate 5.4 runtime provider now incorporates Hibernate Core version 5.4.7.Final and Hibernate Tools version 5.4.7.Final.

The Hibernate 5.3 runtime provider now incorporates Hibernate Core version 5.3.13.Final and Hibernate Tools version 5.3.13.Final.

Platform

Views, Dialogs and Toolbar

The new Quick Search dialog provides a convenient, simple and fast way to run a textual search across your workspace and jump to matches in your code. The dialog provides a quick overview showing matching lines of text at a glance. It updates as quickly as you can type and allows for quick navigation using only the keyboard. A typical workflow starts by pressing the keyboard shortcut Ctrl+Alt+Shift+L (or Cmd+Alt+Shift+L on Mac). Typing a few letters updates the search result as you type. Use Up-Down arrow keys to select a match, then hit Enter to open it in an editor.

Save editor when Project Explorer has focus

You can now save the active editor even when the Project Explorer has focus. In cases where an extension contributes Saveables to the Project Explorer, the extension is honored and the save action on the Project Explorer will save the provided saveable item instead of the active editor.

“Show In” context menu available for normal resources

The Show In context menu is now available for an element inside a resource project on the Project Explorer.

Show colors for additions and deletions in Compare viewer

In simple cases such as a two-way comparison or a three-way comparison with no merges and conflicts, the Compare viewer now shows different colors, depending on whether text has been added, removed, or modified. The default colors are green, red, and black, respectively.

The colors can be customized through usual theme customization approaches, including using related entries in the Colors and Fonts preference page.

Editor status line shows more selection details

The status line for Text Editors now shows the cursor position, and when the editor has something selected, it shows the number of characters in the selection as well. This also works in the block selection mode.

These two new additions to the status line can be disabled via the General > Editors > Text Editors preference page.

Shorter dialog text

Several dialog texts have been shortened. This allows you to capture important information faster.

Previously:

Now:

Close project via middle-click

In the Project Explorer, you can now close a project using middle-click.

Debug

Improved usability of Environment tab in Launch Configurations

In the Environment tab of the Launch Configuration dialog, you can now double-click on an environment variable name or value and start editing it directly from the table.

Right-clicking on the environment variable table now opens a context menu, allowing for quick addition, removal, copying, and pasting of environment variables.

Show Command Line for external program launch

The External Tools Configuration dialog for launching an external program now supports the Show Command Line button.

Preferences

Close editors automatically when reaching 99 open editors

The preference to close editors automatically is now enabled by default. It will be triggered when you have opened 99 files. If you continue to open editors, old editors will be closed to protect you from performance problems. You can modify this setting in the Preferences dialog via the General > Editors > Close editors automatically preference.

In-table color previews for Text Editor appearance color options

You can now see all the colors currently being used in Text Editors from the Appearance color options table, located in the Preferences > General > Editors > Text Editor page.

Automatic detection of UI freezes in the Eclipse SDK

The Eclipse SDK has been configured to show stack traces for UI freezes in the Error Log view by default for new workspaces. You can use this information to identify and report slow parts of the Eclipse IDE.

You can disable the monitoring or tweak its settings via the options in the General > UI Responsiveness Monitoring preference page as shown below.

Themes and Styling

Start automatically in dark theme based on OS theme

On Linux and Mac, Eclipse can now start automatically in dark theme when the OS theme is dark. This works by default, that is on a new workspace or when the user has not explicitly set or changed the theme in Eclipse.

Display of Help content respects OS theme

More and more operating systems provide a system-wide dark theme. Eclipse now respects this system-wide theme setting when the Eclipse help content is displayed in an external browser. A prerequisite for this is a browser that supports the prefers-color-scheme CSS media query.

As of the time of writing, the following browser versions support it:

  • Firefox version 67
  • Chrome version 76
  • Safari version 12.1

Help content uses high-resolution icons.

The Help System, as well as the help content of the Eclipse Platform, the Java Development Tooling, and the Plug-in Development Environment, now uses high-resolution icons. They are now crisp on high-resolution displays and also look much better in the dark theme.

Improved dark theme on Windows

Labels, Sections, Checkboxes, Radio Buttons, FormTexts, and Sashes on forms now use the correct background color in the dark mode on windows.

General Updates

Interactive performance

Interactive performance has been further improved in this release and several UI freezes have been fixed.

Show key bindings when command is invoked

For presentations, screencasts, and learning purposes, it is very helpful to show the corresponding key binding when a command is invoked. When the command is invoked (via a key binding or menu interaction) the key binding, the command’s name and description are shown on the screen.

You can activate this in the Preferences dialog via the Show key binding when command is invoked checkbox on the General > Keys preference page. To toggle this setting quickly, you can use the Toggle Whether to Show Key Binding command (e.g., via the quick access).

Java Developement Tools (JDT)

Java 13 Support

Java 13 is out, and Eclipse JDT supports Java 13 for 4.13 via Marketplace.

The release notably includes the following Java 13 features:

  • JEP 354: Switch Expressions (Preview).
  • JEP 355: Text Blocks (Preview).

Please note that these are preview language features; hence, the enable preview option should be on. For an informal introduction of the support, please refer to Java 13 Examples wiki.

Java Views and Dialogs

Synchronize standard and error output in console

The Eclipse Console view currently can not ensure that mixed standard and error output is shown in the same order as it is produced by the running process. For Java applications, the launch configuration Common tab now provides an option to merge standard and error output. This ensures that standard and error output is shown in the same order it was produced but also disables the individual coloring of error output.

Java Editor

Convert to enhanced ‘for’ loop using Collections

The Java quickfix/cleanup Convert to enhanced ‘for’ loop is now offered on for loops that are iterating through Collections. The loop must reference the size method as part of the condition and if accessing elements in the body, must use the get method. All other Collection methods other than isEmpty invalidate the quickfix being offered.

Initialize ‘final’ fields

A Java quickfix is now offered to initialize an uninitialized final field in the class constructor. The fix will initialize a String to the empty string, a numeric base type to 0, and, for class fields, it initializes them using their default constructor if available or null if no default constructor exists.

Autoboxing and Unboxing

Use Autoboxing and Unboxing when possible. These features are enabled only for Java 5 and higher.

Improved redundant modifier removal

The Remove redundant modifier now also removes useless abstract modifier on the interfaces.

For the given code:

You get this:

Javadoc comment generation for module

Adding a Javadoc comment to a Java module (module-info.java) will result in automatic annotations being added per the new module comment preferences.

The $(tags) directive will add @uses and @provides tags for all uses and provides module statements.

Chain Completion Code Assist

Code assist for “Chain Template Proposals” will be available. These will traverse reachable local variables, fields, and methods, to produce a chain whose return type is compatible with the expected type in a particular context.

The preference to enable the feature can be found in the Advanced sub-menu of the Content Assist menu group (Preferences > Java > Editor > Content Assist > Advanced).

Java Formatter

Remove excess blank lines

All the settings in the Blank lines section can now be configured to remove excess blank lines, effectively taking precedence over the Number of empty lines to preserve setting. Each setting has its own button to turn the feature on, right next to its number control. The button is enabled only if the selected number of lines is smaller than the Number of empty lines to preserve; otherwise, any excess lines are removed anyway.

Changes in blank lines settings

There’s quite a lot of changes in the Blank lines section of the formatter profile.

Some of the existing subsections and settings are now phrased differently to better express their function:

  • The Blank lines within class declarations subsection is now Blank lines within type declaration.
  • Before first declaration is now Before first member declaration.
  • Before declarations of the same kind is now Between member declarations of different kind.
  • Before member class declarations is now Between member type declarations.
  • Before field declarations is now Between field declarations.
  • Before method declarations is now Between method/constructor declarations.

More importantly, a few new settings have been added to support more places where the number of empty lines can be controlled:

  • After last member declaration in a type (to complement previously existing Before first member declaration setting).
  • Between abstract method declarations in a type (these cases were previously handled by Between method/constructor declarations).
  • At end of method/constructor body (to complement previously existing At beginning of method/constructor body setting).
  • At beginning of code block and At end of code block.
  • Before statement with code block and After statement with code block.
  • Between statement groups in ‘switch.’

Most of the new settings have been put in a new subsection Blank lines within method/constructor declarations.

JUnit

JUnit 5.5.1

JUnit 5.5.1 is here and Eclipse JDT has been updated to use this version.

Debug

Enhanced support for –patch-module during launch

The Java Launch Configuration now supports patching of different modules by different sources during the launch. This can be verified in the Override Dependencies…​ dialog in the Dependencies tab in a Java Launch Configuration.

Java Build

Full build on JDT core preferences change

Manually changing the settings file .settings/org.eclipse.jdt.core.prefs of a project will result in a full project build, if the workspace auto-build is on. For example, pulling different settings from a git repository or generating the settings with a tool will now trigger a build. Note that this includes timestamp changes, even if actual settings file contents were not changed.

For the 4.13 release, it is possible to disable this new behavior with the VM property: -Dorg.eclipse.disableAutoBuildOnSettingsChange=true. It is planned to remove this VM property in a future release.

And more…​

You can find more noteworthy updates in on this page.

What is next?

Having JBoss Tools 4.13.0 and Red Hat CodeReady Studio 12.13 out we are already working on the next release for Eclipse 2019-12.

Share

The post New features in Red Hat CodeReady Studio 12.13.0.GA and JBoss Tools 4.13.0.Final for Eclipse 2019-09 appeared first on Red Hat Developer.

Posted on Leave a comment

Quarkus: Modernize “helloworld” JBoss EAP quickstart, Part 1

Quarkus is, in its own words, “Supersonic subatomic Java” and a “Kubernetes native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards.” For the purpose of illustrating how to modernize an existing Java application to Quarkus, I will use the Red Hat JBoss Enterprise Application Platform (JBoss EAP) quickstarts helloworld quickstart as sample of a Java application builds using technologies (CDI and Servlet 3) supported in Quarkus.

It’s important to note that both Quarkus and JBoss EAP rely on providing developers with tools based—as much as possible—on standards. If your application is not already running on JBoss EAP, there’s no problem. You can migrate it from your current application server to JBoss EAP using the Red Hat Application Migration Toolkit. After that, the final and working modernized version of the code is available in the https://github.com/mrizzi/jboss-eap-quickstarts/tree/quarkus repository inside the helloworld module.

This article is based on the guides Quarkus provides, mainly Creating Your First Application and Building a Native Executable.

Get the code

To start, clone the JBoss EAP quickstarts repository locally, running:

$ git clone https://github.com/jboss-developer/jboss-eap-quickstarts.git Cloning into 'jboss-eap-quickstarts'... remote: Enumerating objects: 148133, done. remote: Total 148133 (delta 0), reused 0 (delta 0), pack-reused 148133 Receiving objects: 100% (148133/148133), 59.90 MiB | 7.62 MiB/s, done. Resolving deltas: 100% (66476/66476), done. $ cd jboss-eap-quickstarts/helloworld/

Try plain, vanilla helloworld

The name of the quickstart is a strong clue about what this application does, but let’s follow a scientific approach in modernizing this code, so first things first: Try the application as it is.

Deploy helloworld

  1. Open a terminal and navigate to the root of the JBoss EAP directory EAP_HOME (which you can download).
  2. Start the JBoss EAP server with the default profile by typing the following command:
$ EAP_HOME/bin/standalone.sh 

Note: For Windows, use the EAP_HOME\bin\standalone.bat script.

After a few seconds, the log should look like:

[org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.2.0.GA (WildFly Core 6.0.11.Final-redhat-00001) started in 3315ms - Started 306 of 527 services (321 services are lazy, passive or on-demand)
  1. Open http://127.0.0.1:8080 in a browser, and a page like Figure 1 should appear:
The JBoss EAP home page.

Figure 1: The JBoss EAP home page.

  1. Following instructions from Build and Deploy the Quickstart, deploy the helloworld quickstart and execute (from the project root directory) the command:
$ mvn clean install wildfly:deploy 

This command should end successfully with a log like this:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.224 s 

The helloworld application has now been deployed for the first time in JBoss EAP in about eight seconds.

Test helloworld

Following the Access the Application guide, open http://127.0.0.1:8080/helloworld in the browser and see the application page, as shown in Figure 2:

JBoss EAP's Hello World.

Figure 2: JBoss EAP’s Hello World.

Make changes

Change the createHelloMessage(String name) input parameter from World to Marco (my ego is cheap):

writer.println("<h1>" + helloService.createHelloMessage("Marco") + "</h1>");

Execute again the command:

$ mvn clean install wildfly:deploy 

and then refresh the web page in the browser to check the message displayed changes, as shown in Figure 3:

JBoss EAP's Hello Marco.

Figure 3: JBoss EAP’s Hello Marco.

Undeploy helloworld and shut down

If you want to undeploy (optional) the application before shutting down JBoss EAP, run the following command:

$ mvn clean install wildfly:undeploy 

To shut down the JBoss EAP instance, enter Ctrl+C in the terminal where it’s running.

Let’s modernize helloworld

Now we can leave the original helloworld behind and update it.

Create a new branch

Create a new working branch once the quickstart project finishes executing:

$ git checkout -b quarkus 7.2.0.GA 

Change the pom.xml file

The time has come to start changing the application. starting from the pom.xml file. From the helloworld folder, run the following command to let Quarkus add XML blocks:

$ mvn io.quarkus:quarkus-maven-plugin:0.23.2:create 

This article uses the 0.23.2 version. To know which is the latest version is, please refer to https://github.com/quarkusio/quarkus/releases/latest/, since the Quarkus release cycles are short.

This command changed the pom.xml, file adding:

  • The property <quarkus.version> to define the Quarkus version to be used.
  • The <dependencyManagement> block to import the Quarkus bill of materials (BOM). In this way, there’s no need to add the version to each Quarkus dependency.
  • The quarkus-maven-plugin plugin responsible for packaging the application, and also providing the development mode.
  • The native profile to create application native executables.

Further changes required to pom.xml, to be done manually:

  1. Move the <groupId> tag outside of the <parent> block, and above the <artifactId> tag. Because we remove the <parent> block in the next step, the <groupId> must be preserved.
  2. Remove the <parent> block: The application doesn’t need the JBoss parent pom anymore to run with Quarkus.
  3. Add the <version> tag (below the <artifactId> tag) with the value you prefer.
  4. Remove the <packaging> tag: The application won’t be a WAR anymore, but a plain JAR.
  5. Change the following dependencies:
    1. Replace the javax.enterprise:cdi-api dependency with io.quarkus:quarkus-arc, removing <scope>provided</scope> because—as stated in the documentation—this Quarkus extension provides the CDI dependency injection.
    2. Replace the org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec dependency with io.quarkus:quarkus-undertow, removing the <scope>provided</scope>, because—again as stated in the documentation—this is the Quarkus extension that provides support for servlets.
    3. Remove the org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec dependency because it’s coming with the previously changed dependencies.

The pom.xml file’s fully changed version is available at https://github.com/mrizzi/jboss-eap-quickstarts/blob/quarkus/helloworld/pom.xml.

Note that the above mvn io.quarkus:quarkus-maven-plugin:0.23.2:create command, besides the changes to the pom.xml file, added components to the project. The added file and folders are:

  • The files mvnw and mvnw.cmd, and .mvn folder: The Maven Wrapper allows you to run Maven projects with a specific version of Maven without requiring that you install that specific Maven version.
  • The docker folder (in src/main/): This folder contains example Dockerfile files for both native and jvm modes (together with a .dockerignore file).
  • The resources folder (in src/main/): This folder contains an empty application.properties file and the sample Quarkus landing page index.html (more in the section “Run the modernized helloworld“).

Run helloworld

To test the application, use quarkus:dev, which runs Quarkus in development mode (more details on Development Mode here).

Note: We expect this step to fail as changes are still required to the application, as detailed in this section.

Now run the command to check if and how it works:

$ ./mvnw compile quarkus:dev [INFO] Scanning for projects... [INFO] [INFO] ----------------< org.jboss.eap.quickstarts:helloworld >---------------- [INFO] Building Quickstart: helloworld quarkus [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- quarkus-maven-plugin:0.23.2:dev (default-cli) @ helloworld --- Listening for transport dt_socket at address: 5005 INFO [io.qua.dep.QuarkusAugmentor] Beginning quarkus augmentation INFO [org.jbo.threads] JBoss Threads version 3.0.0.Final ERROR [io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.jboss.as.quickstarts.helloworld.HelloService and qualifiers [@Default] - java member: org.jboss.as.quickstarts.helloworld.HelloWorldServlet#helloService - declared on CLASS bean [types=[javax.servlet.ServletConfig, java.io.Serializable, org.jboss.as.quickstarts.helloworld.HelloWorldServlet, javax.servlet.GenericServlet, javax.servlet.Servlet, java.lang.Object, javax.servlet.http.HttpServlet], qualifiers=[@Default, @Any], target=org.jboss.as.quickstarts.helloworld.HelloWorldServlet] at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:841) at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:214) at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106) at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:249) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:780) at io.quarkus.builder.BuildContext.run(BuildContext.java:415) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java:479) Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.jboss.as.quickstarts.helloworld.HelloService and qualifiers [@Default] - java member: org.jboss.as.quickstarts.helloworld.HelloWorldServlet#helloService - declared on CLASS bean [types=[javax.servlet.ServletConfig, java.io.Serializable, org.jboss.as.quickstarts.helloworld.HelloWorldServlet, javax.servlet.GenericServlet, javax.servlet.Servlet, java.lang.Object, javax.servlet.http.HttpServlet], qualifiers=[@Default, @Any], target=org.jboss.as.quickstarts.helloworld.HelloWorldServlet] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:428) at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:371) at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:206) ... 14 more 

It failed. Why? What happened?

The UnsatisfiedResolutionException exception refers to the HelloService class, which is a member of the HelloWorldServlet class (java member: org.jboss.as.quickstarts.helloworld.HelloWorldServlet#helloService). The problem is that HelloWorldServlet needs an injected instance of HelloService, but it can not be found (even if the two classes are in the very same package).

It’s time to return to Quarkus guides to leverage the documentation and understand how @Inject—and hence Contexts and Dependency Injection (CDI)—works in Quarkus, thanks to the Contexts and Dependency Injection guide. In the Bean Discovery paragraph, it says, “Bean classes that don’t have a bean defining annotation are not discovered.”

Looking at the HelloService class, it’s clear there’s no bean defining annotation, and one has to be added to have Quarkus to discover the bean. So, because it’s a stateless object, it’s safe to add the @ApplicationScoped annotation:

@ApplicationScoped public class HelloService { 

Note: The IDE should prompt you to add the required package shown here (add it manually if need be):

import javax.enterprise.context.ApplicationScoped; 

If you’re in doubt about which scope to apply when the original bean has no scope defined, please refer to the JSR 365: Contexts and Dependency Injection for Java 2.0—Default scope documentation.

Now, try again to run the application, executing again the ./mvnw compile quarkus:dev command:

$ ./mvnw compile quarkus:dev [INFO] Scanning for projects... [INFO] [INFO] ----------------< org.jboss.eap.quickstarts:helloworld >---------------- [INFO] Building Quickstart: helloworld quarkus [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /home/mrizzi/git/forked/jboss-eap-quickstarts/helloworld/target/classes [INFO] [INFO] --- quarkus-maven-plugin:0.23.2:dev (default-cli) @ helloworld --- Listening for transport dt_socket at address: 5005 INFO [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 576ms INFO [io.quarkus] (main) Quarkus 0.23.2 started in 1.083s. Listening on: http://0.0.0.0:8080 INFO [io.quarkus] (main) Profile dev activated. Live Coding activated. INFO [io.quarkus] (main) Installed features: [cdi] 

This time the application runs successfully.

Run the modernized helloworld

As the terminal log suggests, open a browser to http://0.0.0.0:8080(the default Quarkus landing page), and the page shown in Figure 4 appears:

The Quarkus dev landing page.

Figure 4: The Quarkus dev landing page.

This application has the following context’s definition in the WebServlet annotation:

@WebServlet("/HelloWorld") public class HelloWorldServlet extends HttpServlet { 

Hence, you can browse to http://0.0.0.0:8080/HelloWorldto reach the page shown in Figure 5:

The Quarkus dev Hello World page.

Figure 5: The Quarkus dev Hello World page.

It works!

Make changes

Please, pay attention to the fact that the ./mvnw compile quarkus:dev command is still running, and we’re not going to stop it. Now, try to apply the same—very trivial—change to the code and see how Quarkus improves the developer experience:

writer.println("<h1>" + helloService.createHelloMessage("Marco") + "</h1>");

Save the file, and then refresh the web page to check that Hello Marco appears, as shown in Figure 6:

The Quarkus dev Hello Marco page.

Figure 6: The Quarkus dev Hello Marco page.

Take time to check the terminal output:

INFO [io.qua.dev] (vert.x-worker-thread-3) Changed source files detected, recompiling [/home/mrizzi/git/forked/jboss-eap-quickstarts/helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java] INFO [io.quarkus] (vert.x-worker-thread-3) Quarkus stopped in 0.003s INFO [io.qua.dep.QuarkusAugmentor] (vert.x-worker-thread-3) Beginning quarkus augmentation INFO [io.qua.dep.QuarkusAugmentor] (vert.x-worker-thread-3) Quarkus augmentation completed in 232ms INFO [io.quarkus] (vert.x-worker-thread-3) Quarkus 0.23.2 started in 0.257s. Listening on: http://0.0.0.0:8080 INFO [io.quarkus] (vert.x-worker-thread-3) Profile dev activated. Live Coding activated. INFO [io.quarkus] (vert.x-worker-thread-3) Installed features: [cdi] INFO [io.qua.dev] (vert.x-worker-thread-3) Hot replace total time: 0.371s 

Refreshing the page triggered the source code change detection and the Quarkus automagic “stop-and-start.” All of this executed in just 0.371 seconds (that’s part of the Quarkus “Supersonic Subatomic Java” experience).

Build the helloworld packaged JAR

Now that the code works as expected, it can be packaged using the command:

$ ./mvnw clean package

This command creates two JARs in the /target folder. The first is helloworld-<version>.jar, which is the standard artifact built from the Maven command with the project’s classes and resources. The second is helloworld-<version>-runner.jar, which is an executable JAR.

Please pay attention to the fact that this is not an uber-jar, because all of the dependencies are copied into the /target/lib folder (and not bundled within the JAR). Hence, to run this JAR in another location or host, both the JAR file and the libraries in the /lib folder have to be copied, considering that the Class-Path entry of the MANIFEST.MF file in the JAR explicitly lists the JARs from the lib folder.

To create an uber-jar application, please refer to the Uber-Jar Creation Quarkus guide.

Run the helloworld packaged JAR

Now, the packaged JAR can be executed using the standard java command:

$ java -jar ./target/helloworld-<version>-runner.jar INFO [io.quarkus] (main) Quarkus 0.23.2 started in 0.673s. Listening on: http://0.0.0.0:8080 INFO [io.quarkus] (main) Profile prod activated. INFO [io.quarkus] (main) Installed features: [cdi] 

As done above, open the http://0.0.0.0:8080 URL in a browser, and test that everything works.

Build the helloworld quickstart-native executable

So far so good. The helloworld quickstart ran as a standalone Java application using Quarkus dependencies, but more can be achieved by adding a further step to the modernization path: Build a native executable.

Install GraalVM

First of all, the tools for creating the native executable have to be installed:

  1. Download GraalVM 19.2.0.1 from https://github.com/oracle/graal/releases/tag/vm-19.2.0.1.
  2. Untar the file using the command:

$ tar xvzf graalvm-ce-linux-amd64-19.2.0.1.tar.gz

  1. Go to the untar folder.
  2. Execute the following to download and add the native image component:

$ ./bin/gu install native-image

  1. Set the GRAALVM_HOME environment variable to the folder created in step two, for example:

$ export GRAALVM_HOME={untar-folder}/graalvm-ce-19.2.0.1)

More details and install instructions for other operating systems are available in Building a Native Executable—Prerequisites Quarkus guide.

Build the helloworld native executable

As stated in the Building a Native Executable—Producing a native executable Quarkus guide, “Let’s now produce a native executable for our application. It improves the startup time of the application and produces a minimal disk footprint. The executable would have everything to run the application including the ‘JVM’ (shrunk to be just enough to run the application), and the application.”

To create the native executable, the Maven native profile has to be enabled by executing:

$ ./mvnw package -Pnative

The build took me about 1:10 minutes and the result is the helloworld-<version>-runner file in the /target folder.

Run the helloworld native executable

The /target/helloworld-<version>-runner file created in the previous step. It’s executable, so running it is easy:

$ ./target/helloworld-<version>-runner INFO [io.quarkus] (main) Quarkus 0.23.2 started in 0.006s. Listening on: http://0.0.0.0:8080 INFO [io.quarkus] (main) Profile prod activated. INFO [io.quarkus] (main) Installed features: [cdi] 

As done before, open the http://0.0.0.0:8080 URL in a browser and test that everything is working.

Next steps

I believe that this modernization, even of a basic application, is the right way to approach a brownfield application using technologies available in Quarkus. This way, you can start facing the issues and tackling them to understand and learn how to solve them.

In part two of this series, I’ll look at how to capture memory consumption data in order to evaluate performance improvements, which is a fundamental part of the modernization process.

Share

The post Quarkus: Modernize “helloworld” JBoss EAP quickstart, Part 1 appeared first on Red Hat Developer.

Posted on Leave a comment

Managing JBoss EAP/Wildfly using Jcliff

Systems management can be a difficult task. Not only does one need to determine what the end state should be but, more importantly, how to ensure systems attain and remain at this state. Doing so in an automated fashion is just as critical, because there may be a large number of target instances. In regard to enterprise Java middleware application servers, these instances are typically configured using a set of XML based files. Although these files may be manually configured, most application servers have a command-line based tool or set of tools that abstracts the end user from having to worry about the underlying configuration. WebSphere Liberty includes a variety of tools to manage these resources, whereas JBoss contains the jboss-cli tool.

Although each tool accomplishes its utilitarian use case as it allows for proper server management, it does fail to adhere to one of the principles of automation and configuration management: idempotence. Ensuring the desired state does not equate to executing the same action with every iteration. Additional intelligence must be introduced. Along with idempotence, another core principle of configuration management is that values be expressed declaratively and stored in a version control system.

Jcliff is a Java-based utility that is built on top of the JBoss command-line interface and allows for the desired intent for the server configuration to be expressed declaratively, which in turn can be stored in a version control system. We’ll provide an overview of the Jcliff utility including inherent benefits, installation options, and several examples showcasing the use.

The problem space

Before beginning to work with Jcliff, one must be cognizant of the underlying JBoss architecture. The configuration of the JBoss server can be expressed using Dynamic Model Representation (DMR) notation. The following is an example of DMR:

{ "system-property" => { "foo" => "bar", "bah" => "gah" } } 

The DMR example above describes several Java system properties that will be stored within the JBoss configuration. These properties can be added using the JBoss CLI by executing the following command:

/system-property=foo:add(value=bar) /system-property=bah:add(value=gah) 

The challenge is that the same commands cannot be executed more than once. Otherwise, an error similar to the following is produced.

{ "outcome" => "failed", "failure-description" => "WFLYCTL0212: Duplicate resource [(\"system-property\" => \"foo\")]", "rolled-back" => true } 

Where Jcliff excels is that it includes the necessary intelligence to determine the current state of the JBoss configuration and then applying the appropriate configurations necessary. This is critical to adopting proper configuration management when working with JBoss.

Installing Jcliff

With a baseline understanding of Jcliff, let’s discuss the methods in which one can obtain the utility. First, Jcliff can be built from source from the project repository, given that it’s a freely open source project. Alternatively, Jcliff can be installed using popular software packaging tools in each of the primary operating system families.

Linux (rpm)

Jcliff can be consumed on a Linux package when capable of consuming an rpm using a package manager.

First, install the yum repository:

$ cat /etc/yum.repos.d/jcliff.repo [jcliff] baseurl = http://people.redhat.com/~rpelisse/jcliff.yum/ gpgcheck = 0 name = JCliff repository 

Once this repository has been added, JCliff can be installed by using Yum or Dnf:

Using yum:

$ sudo yum install jcliff 

Or using dnf:

$ sudo dnf install jcliff 

Manual installation

Jcliff can also be installed manually without the need to leverage a package manager. This is useful for those on Linux distributions that cannot consume rpm packages. Simply download and unpack the archive from the release artifact from the project repository.

$ curl -O \ https://github.com/bserdar/jcliff/releases/download/v2.12.1/jcliff-2.12.1-dist.tar.gz $ tar xzvf jcliff-2.12.1-dist.tar.gz 

Place the resulting Jcliff folder in the destination of your choosing. This location is known as JCLIFF_HOME. Add this environment variable and add it to the path as described below:

$ export JCLIFF_HOME=/path/to/jcliff-2.12.1/ $ export PATH=${JCLIFF_HOME}/bin:${PATH} 

At this point, you should be able to execute the jcliff command.

OSX

While users on OSX can take advantage of the manual installation option, those making use of the brew package manager can use this tool as well.

Execute the following commands to install Jcliff using Brew:

$ brew tap redhat-cop/redhat-cop $ brew install redhat-cop/redhat-cop/jcliff 

Windows

Fear not, Windows users; you can also make use of Jcliff without having to compile from source. Windows, in the same vein as OSX, does not have an official package manager, but Chocolatey has been given this role.

Execute the following command to install Jcliff using Chocolatey:

$ choco install jcliff 

Using Jcliff

With Jcliff properly installed on your machine, let’s walk through a simple example to demonstrate the use of the tool. As discussed previously, Jcliff makes use of files that describe the target configuration. At this point, you may have questions like: What is the format of these configurations, and where do I begin?

Let’s take a simple example and look into adding a new system property to the JBoss configuration. Launch an instance of JBoss and connect using the JBoss command-line interface:

$ /bin/jboss-cli.sh --connect [standalone@localhost:9990 /] ls /system-property [standalone@localhost:9990 /] 

Now, use Jcliff to update the configuration. First, we’ll need to create a Jcliff rule. The rule resembles DMR format and appears similar to the following:

$ cat jcliff-prop { "system-property" => { "jcliff.enabled" => "true", } } 

Then we can simply ask JCliff to run this script against our JBoss server:

$ jcliff jcliff-prop Jcliff version 2.12.4 2019-10-02 17:03:40:0008: /core-service=platform-mbean/type=runtime:read-attribute(name=system-properties) 2019-10-02 17:03:41:0974: /system-property=jcliff.enabled:add(value="true") 

Use the JBoss CLI to verify the changes have been applied.

$ “${JBOSS_HOME}/bin/jboss-cli.sh” --connect --command=/system-property=jcliff.enabled:read-resource { "outcome" => "success", "result" => {"value" => "true"} } 

To demonstrate how Jcliff handles repetitive executions, run the previous Jcliff command again. Inspect the output.

$ jcliff jcliff-prop Jcliff version 2.12.4 2019-10-02 17:05:34:0107: /core-service=platform-mbean/type=runtime:read-attribute(name=system-properties) 

Notice that only 1 command was executed against the JBoss server instead of two? This action was a result of assessing the current state within JBoss and determining that no action was necessary to reach the desired state. Mission accomplished.

Next steps

Although the preceding scenario was not overly complex, you should now have the knowledge necessary to understand the capabilities and functionality of the Jcliff utility as well as the benefits afforded through declarative configurations and automation. When building out enterprise-grade systems, however, Jcliff would not be executed manually. You would want to integrate the utility into a proper configuration management tool that employs many of the automation and configuration principles described earlier. Fortunately, Jcliff has been integrated into several popular configuration management tools.

In an upcoming article, we’ll provide an overview of the configuration management options available with Jcliff, along with examples that will allow you to quickly build out enterprise-grade confidence with Jcliff.

Share

The post Managing JBoss EAP/Wildfly using Jcliff appeared first on Red Hat Developer.

Posted on Leave a comment

Bring joy to development with Quarkus, the cloud-native Java framework

Our first DevNation Live regional event was held in Bengaluru, India in July. This free technology event focused on open source innovations, with sessions presented by elite Red Hat technologists.

Quarkus is revolutionizing the way that we develop Java applications for the cloud-native era, and in this presentation, Edson Yanaga explains why it also sparks joy.

Watch this live coding session to get familiar with Quarkus and learn how your old and new favorite APIs will start in a matter of milliseconds and consume tiny amounts of memory. Hot reload capabilities for development will bring you instant joy.

Watch the complete presentation:

See the slides here.

Learn more

Join us at an upcoming developer event, and see our collection of past DevNation Live tech talks.

Share

The post Bring joy to development with Quarkus, the cloud-native Java framework appeared first on Red Hat Developer.

Posted on Leave a comment

What’s new in Red Hat Dependency Analytics

We are excited to announce a new release of Red Hat Dependency Analytics, a solution that enables developers to create better applications by evaluating and adding high-quality open source components, directly from their IDE.

Red Hat Dependency Analytics helps your development team avoid security and licensing issues when building your applications. It plugs into the developer’s IDE, automatically analyzes your software composition, and provides recommendations to address security holes and licensing problems that your team may be missing.

Without further ado, let’s jump into the new capabilities offered in this release. This release includes a new version of the IDE plugin and the server-side analysis service hosted by Red Hat.

Support for Python applications

Along with Java (maven) and JavaScript (npm), Dependency Analytics now offers its full set of capabilities for Python (PyPI) applications. From your IDE, you can perform the vulnerability and license analysis of the “requirements.txt” file of your Python application, incorporate the recommended fixes, and generate the stack analysis report for more details.

Software composition analysis based on current vulnerability data

An estimated 15,000 open source packages get updated every day. On average, three new vulnerabilities get posted every day across JavaScript (npm) and Python (PyPi) packages. With this new release, the server-side analysis service hosted by Red Hat automatically processes the daily updates to open source packages that it is tracking. The hosted service also automatically ingests new vulnerability data posted to National Vulnerability Database (NVD) for JavaScript and Python packages. This allows the IDE plugin and API calls to provide source code analysis based on current vulnerability and release data.

Analyze transitive dependencies

In addition to the direct dependencies included in your application, Dependency Analytics now leverages the package managers to discover and add the dependencies of those dependencies, called “transitive” dependencies, to the dependency graph of your application. Analysis of your application is performed across the whole graph model and recommendations for fixes are provided across the entire set of dependencies.

Recommendations about complementary open source libraries

With this release, Dependency Analytics looks to recommend high-quality open source libraries that are complementary to the dependencies included in your application. The machine learning technology of the hosted service collects and analyzes various statistics on GitHub to curate a list of high-quality open source libraries that can be added to the current set of dependencies to augment your application. You can provide your feedback about the add-on libraries by clicking on the “thumbs-up” or “thumbs-down” icons shown for each recommendation. Your feedback is automatically processed to improve the quality of the recommendations.

IDE plugin support

The Dependency Analytics IDE plugin is now available for VS Code, Eclipse Che, and any JetBrains IDE, including IntelliJ and PyCharm.

We will continuously release new updates to our Dependency Analytics solution so you can minimize the delays in delivery of your applications due to last-minute security and licensing related issues.

Stay tuned for further updates; we look forward to your feedback about Dependency Analytics.

Share

The post What’s new in Red Hat Dependency Analytics appeared first on Red Hat Developer.

Posted on Leave a comment

How to Create an Alarm Clock in Cinema 4D: Part 1

Final product image
What You’ll Be Creating

Follow this tutorial step-by-step to create a 3D Alarm Clock model that you can use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly and easily. 

Some of the skills you’ll learn in this tutorial include creating basic 3D modelling, adding lighting to the scene and basic rendering techniques.

In this, the first part of the two-part tutorial, I’ll show you how to:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Alarm Clock

1. How to Import Reference Images

Step 1

To use the reference image in this tutorial, you will need to switch your viewport to the Front View

Use the middle mouse button to click anywhere on the viewport. This displays all four views (by default this will be perspective, top, right and front). From there, use the middle mouse button to select the Front View.

Viewport showing four view points

Step 2

In the Attributes tab select Mode > View Settings.

Select View Settings

Step 3

In Viewport [Right] select the Back button and click on the button next to Image. 

Select the Back tab

Step 4

Select the reference image from the Finder and open it. In this tutorial I’ll use the front view of an Alarm Clock from Envato Elements to help me.

Alarm clock reference image

Step 5

Adjust the image size and transparency to your liking in the Properties window.

Reference image properties

2. Adjust and Edit the Cylinder Shape

Step 1

In the top menu bar click and hold on the Cube Button (or click on the small black arrow in the bottom right corner of the button). 

In the menu that appears select the Cylinder Button to spawn a cylinder into the scene.

Select the Cylinder button

Step 2

You may need to rotate the cylinder in order to get the right orientation. 

To do this click on the Rotate Tool button and use the tool to rotate the cylinder 90 degrees so that the circular face is pointing forward.

Rotate the Cylinder shape

Step 3

Click on the Object tab in the Properties window. Adjust the size so that the shape of the cylinder fits the shape of the Alarm Clock background image. For this tutorial the following properties are used:

  • Radius: 140 cm
  • Height: 100 cm
  • Height Segments: 1
  • Rotation Segments: 80
  • Orientation: +Y
Adjust the Cylinder Object properties

Step 4

Click on the Caps tab of the properties window. Make sure that Caps has been ticked and the Segments are set to a value of 2.

Adjust the Cap properties

Step 5

By activating caps and setting the segments value to 2, you will see that an extra cap has been created on the face of the cylinder. The shape of the cylinder should roughly fit the shape of the Alarm Clock background image at this stage. 

Ensure that you check the shape using the other camera views as well (perspective, side and top etc).

Using the Alarm Clock reference image

Step 6

Ensure the cylinder is still selected and then click on the Make Editable button to make the shape editable. 

Next select the Polygon Selection button which will allow you to select the polygons of the object.

Click on the Make Editable and the Polygon Selection buttons

Step 7

Hover the mouse over the face of the cylinder and select all of it’s faces (click and hold on the mouse button to select a large area).

Select the front polygons

Step 8

Once all the polygons have been selected, right click on the selected area and select the Bevel Tool.

Select the Bevel Tool

Step 9

Click and drag over the selected area to create a beveled edge for the cylinder. Repeat the steps for the other side.

Use the Bevel Tool

Step 10

Use the Selection Tool again and select all the polygons in the centre of the circle. Then use the Scale Tool to enlarge it (click and drag in the area outside the object to uniform scale).

Expand the selection using the Scale Tool

Step 11

Right-click on the selection and click on the Extrude Tool.

Select the Extrude Tool

Step 12

Click and drag over the selected area to move the polygons inside the cylinder.

Extrude the selection inside the object

Step 13

With the polygons still selected, use the Scale Tool to scale the selection down, making it slightly smaller.

Reduce the size of the selection using the Scale Tool

Step 14

Delete the Phong Tag from the cylinder. This sharpens all the edges and faces of the model. This is further illustrated in step 15.

Remove the Phong Tag

Step 15

In the image below you will see how the edges of the cylinder are very smooth at first before deleting the Phong Tag

Once the Phong Tag has been deleted, the edges sharpen.

Phong Tag removed

3. How to Create a Hemisphere

Step 1

Clear the viewport to make modelling the hemisphere easier. 

To do this you must hide the cylinder model by clicking on the small little grey circle until it turns red. To make it appear in the viewport again, click on the grey circle until it becomes green or grey.

Hide the Cylinder object

Step 2

Create a Sphere by clicking on Cube > Sphere.

Create a new Sphere object

Step 3

Use the Scale Tool to scale the reduce the size of the sphere so that it matches the size of the bells as closely as possible.

Resize the Sphere object using the Scale Tool

Step 4

In the properties window, select the Object Tab and set the properties to the following:

  • Radius: 55 cm
  • Segments: 50
  • Type: Hemisphere
Adjust the object using the properties window

Step 5

By selecting the type to Hemisphere, the shape will be split in half as shown in the image below.

Create a Hemisphere

4. Add Thickness to an Object

Step 1

To add thickness to the hemisphere you will first need to make it into an editable object. Make sure that the object is selected and click on the Make Editable button.

Click on the Make Editable button

Step 2

In the top menu bar, select Simulate > Cloth > Cloth Surface.

Select the Cloth Surface modifier

Step 3

In the List View, move the sphere object below the newly created Cloth Surface.  

Apply the Cloth Surface to the Sphere object

Step 4

Ensure the Cloth Surface has been selected and select the Object tab in the properties window. Set the properties to the following:

  • Subdivisions: 1
  • Factor: 100%
  • Thickness: 10 cm
Adjust the Cloth Surface properties

Step 5

Adjusting the Thickness value in the properties window changes the thickness of the hemisphere.

Adjust the thickness of the Hemisphere object

5. Create the Alarm Clock Bell

Step 1

Rotate the hemisphere by 180 Degrees so that it starts to take on the appearance of the bell.

Rotate the Hemisphere by 180 degrees

Step 2

In the Front View, use the reference image to ensure the size of the hemisphere is roughly the same size as the bells.

Use the Alarm Clock reference image

Step 3

Create a capsule by selecting the Capsule Button from the shapes menu.

Create a Capsule object

Step 4

Ensure the capsule object is selected and change the properties to the following:

  • Radius: 10 cm
  • Height: 200 cm
  • Height Segments: 1
  • Cap Segments: 8
  • Rotation Segments: 36
  • Orientation: +Y
Adjust the Capsule properties

Step 5

Use the Move Tool to move the capsule down so that only a little bit of the tip is sticking out from the top of the hemisphere.

Lower the capsule

Step 6

Select both the Capsule and the Cloth Surface by clicking and holding the Shift Key on the keyboard. Then group them by pressing Alt-G on the keyboard. You can then rename the Null by double clicking on it.

Group the Capsule and Cloth Surface together

Step 7

Make sure that the new group is still selected, use a combination of the Move Tool and the Rotation Tool to position the bell correctly. You can use the reference image to guide you.

Move the group into place

Step 8

Reveal the cylinder shape by clicking on the small red circle until it is grey (or green) again.

Reveal the Cylinder object

Step 9

You can then make any final adjustments to the bell’s position by comparing it to the reference image and the cylinder.

Adjust the bell using the Move and Rotate tools

6. How to use Symmetry in Cinema 4D

Step 1

In the top menu bar select Array > Symmetry.

Select the Symmetry button

Step 2

In the list window move the group containing the bell objects inside the Symmetry Modifier.

Apply the Symmetry Modifier to the group

Step 3

Anything inside the Symmetry Modifier will create a symmetrical object.

Symmetry modifier applied to the bell

7. Add Legs and Details to the Alarm Clock

Step 1

Use the Capsule Object to create legs for the alarm clock. Do this by creating a new capsule object and using the Move Tool and the Rotate Tool to position it into place.

Another way you can do this is by duplicating the capsule (hold the CTRL button on the keyboard whilst using the Move Tool) which was used to create the bell. 

Move the duplicated capsule into position using the Move Tool and the Rotate Tool.

Add a capsule leg

Step 2

Duplicate the leg by using the Symmetry Modifier

Add another capsule leg

Step 3

Adjust the size and radius of the legs by going to the Object tab in the Properties window.

Adjust the capsule leg properties

Step 4

Create a new Capsule and place it in on top of the alarm clock.

Add a capsule object

Step 5

Create a new Sphere and scale it down using the Scale Tool. Place the small sphere on top of the capsule.

Add a sphere object

8. Create the Clock Hands

Step 1

Create a new Cylinder by clicking on Cube > Cylinder from the top menu bar.

Create a new Cylinder Object

Step 2

Adjust the size of the cylinder in the Properties window so that it matches the width of the clock hand. Use the reference image in the front view to help you with this. The settings for the hand used in this tutorial are as follows:

  • Radius: 10 cm
  • Height: 10 cm
  • Height Segments: 1
  • Rotation Segments: 60
  • Orientation: +Y
Adjust the properties of the Cylinder object

Step 3

Ensure the cylinder is selected and then click on the Make Editable button.

Click on the Make Editable button

Step 4

To edit the shape further select the Points Tool and then select the Rectangle Selection Tool.

Select the Points Tool and the Rectangle Selection Tool

Step 5

Then go to the Properties window and un-tick Only Select Visible Elements. This allows you to select all the points within the rectangle selection.

Un-tick Only Select Visible Elements

Step 6

Use the Rectangle Selection Tool to select all the points in the bottom half of the cylinder. 

Select and use the Move Tool and move all the selected points down to create the clock hand.

Move selection downwards

Step 7

When moving a whole object, select and use the Model button. If this is not selected, you may find that you will be moving the points, edges or faces instead.

Select the Model mode button

Step 8

Position the clock hand object by using the Move Tool.

Place clock hand object

Step 8

YUse the Scale Tool to adjust the scale of the object once it is in place.

Use the scale tool for any last minute adjustments

Step 9

Duplicate the clock hand object by using the Move Tool and holding the CTRL button on the keyboard.

Duplicate the hand tool

Step 10

Once you have the hands, position both on the clock face by using the Move Tool and the Rotation Tool

Use the Scale Tool to make one hand smaller if you wish.

Position the hand objects using the Rotate and Move Tools

Coming Next…

Final Alarm Clock 3D Model

In the second part of the the tutorial series, I’ll show you how to:

  • How to Create Coloured Materials
  • How to Add Lighting to the Scene
  • How to Render the Alarm Clock
Posted on Leave a comment

How to Create an Alarm Clock in Cinema 4D: Part 2

Final product image
What You’ll Be Creating

Follow this tutorial step-by-step to create a 3D Alarm Clock model that you can use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly and easily. 

Some of the skills you’ll learn in this tutorial include creating basic 3D modelling, adding lighting to the scene and basic rendering techniques.

In the first part of the two-part tutorial, I showed you how to:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Alarm Clock

In this, the second part of the the tutorial series, I’ll show you how to:

  • How to Create Colored Materials
  • How to Add Lighting to the Scene
  • How to Render the Alarm Clock

9. How to Create a New Material

Step 1

Located near the bottom of the screen there should be a material selection window. Click on Create > New Material to create a new material to use that you can edit. 

Materials are used to colour in the various objects and areas of the Alarm Clock. Such as the clock face, the hands and the bells.

Create a new material

Step 2

Double click on the new material icon (displayed as a sphere). This brings up the Material Editor, where you adjust the various properties of the material such as the colour, transparency and reflectance. 

For this particular style I’m only be interested in flat colour (Luminance).

Open the material editor

Step 3

Tick the button for Luminance and untick the boxes for Color and Reflectance. This gives the cel shaded look for our final image of the Alarm Clock.

Select luminance

Step 4

Colour the Alarm Clock by adding the material to your object. Drag and drop the material to the object using the mouse. 

You may drag and drop the material onto the object listed on the right of the screen. 

This process will be repeated for the other parts of the Alarm Clock. The base colour of the Alarm Clock are as follows:

  • R: 248
  • G: 62
  • B: 81
Change the color

Step 5

Apply this colour to the two bells and the ringer as well.

Apply the color to the bells

10. How to Use Sketch and Toon

Step 1

In the Material Editor, click on the arrow button next to Texture and select Sketch and Toon > Cel from the menu.

Select sketch and toon

Step 2

Click on the new Cel button that appears next to Texture to bring up a new menu.

Click on the cel button

Step 3

In this new menu, adjust the settings as follows:

  1. Change the Diffuse to match the image at below. It should be grey scale with the colour getting light from left to right
  2. Un-tick Camera
  3. Tick Lights
  4. Tick Shadows 
  5. Select Multiply from the drop down menu
Adjust the cel settings

Step 4

Select a colour by double-clicking on the Color option box . 

The Material Editor gives many different options for choosing and picking a colour. These include RGB, HSV etc. 

Choose whichever option you’re most familiar with as a flat colour. Because of the Multiply shading mode, the different colour shades will also appear in the material.

If the material has already been applied to the model, the colour of the model is automatically be adjusted to the new material colour. This is useful if you change your mind on a certain colour or a certain part of the Alarm Clock model.

Select a color

Step 5

Because you’ve already applied the material to the model, the colour of the Alarm Clock will is adjusted to the new material colour. Click on the Render View button to preview the render.

Render view

11. How to Adjust the Shading

Step 1

To get a better idea of the shading and how the render will turn out as you work on it, click and hold on the Render Button and select Interactive Render Region from the menu. 

Select interactive render region

Step 2

Use the mouse to adjust the window so that it fits around the Alarm Clock model. 

Look for the very small arrow on the right hand side of the window and use the mouse to drag it to the top right corner of the box. This increases the resolution. 

Decrease the resolution by moving the arrow down if you find that performance is suffering.

Increase the resolution

Step 3

Right-click on the small arrow and select Alpha Mode. This removes the black background.

Select alpha mode

Step 4

To change the way the light source is facing go to Options > Default Light.

Change the light source in the Default Light window. Click where you would like the light source to come from on the sphere and it will sync with the view port. 

Experiment with different lighting positions to come up with a lighting situation that you like. 

This can be adjusted at anytime so you can change the lighting again if you changed your mind.

Adjust the default light

12. Other Lighting Solutions

Step 1

To set up the basic lighting, go to the Floor button located in the top menu bar. Left Click-Hold and then select Physical Sky from the menu.

Select physical sky

Step 2

Make sure that Physical Sky is selected in the menu on the right, a new menu will appear on the bottom right of the screen. Select the Time and Location tab and choose a time using the left and right arrow keys. 

This changes the lighting of the scene, according to the time of the day. Choose a suitable time to light up the scene. You will be able to see how the lighting will affect the scene in the viewport.

Select the time and location

Step 3

To add a light to the scene, select the Add Light button in the top menu bar at the top of the screen.

This will create a Light Object which you can move around the scene. Move the light object using the Move Tool to a suitable position.

Create a light object

Step 4

To customise the lighting further, experiment with the light object options in the bottom right of the screen. Here, adjust the Intensity, Light Type and even Color.

Adjust the light object

13. How to Colour the Clock Face

Step 1

To create a new material, duplicate the material by holding CTRL on the keyboard and then using the mouse to click and drag the material to the side.

Duplicate the material

Step 2

Double-click on the new material to open up the Material Editor and select Luminance. From there we can change the colour to the following:

  • R: 247
  • G: 244
  • B: 225
Select a new color for the material

Step 4

Use the selection tool to highlight the polygons on the face of the clock. This is the area that will be coloured using the new material.

Highlight polygons on clock face

Step 5

Apply the colour by click and dragging the new material directly on to the highlighted selection.

Apply new color

14. How to Color the Hands and Legs

Step 1

Create a new material. You can also duplicate a previous material in order to keep the settings from before.

Double click on the new material to open up the Material Editor and select Luminance. From there we can change the colour to the following:

  • R: 70
  • G: 69
  • B: 65
Create a new material

Step 2

Apply the new material to the legs, bell stands and the clock hands by either clicking on the material and dragging it to the objects via the viewport or via the object list window.

Apply the new material color

15. How to Render the Alarm Clock

Step 1

On the top menu bar, click on the Render Settings button. This brings up the render settings window.

Click on render settings

Step 2

In the render settings menu, change the options to what you need. First you’ll need to tick the Save Settings to select a file location, file format and alpha channel.

Select Alpha Channel if you wish to keep the background see through. This could be useful if you wanted to add a background to the image in Adobe Photoshop.

Adjust the save settings

Step 3

In the Output Settings choose the resolution, height and width of the image. 

Adjust the output settings

Step 4

To ensure that the Alarm Clock render is nice and sharp, go to the Anti-Aliasing settings. Select Cubic (Still Image) which is found under Filter

Adjust the anti-aliasing settings

Step 5

To create the final image of the Alarm Clock, click on the Render button. Remember to ensure you’ve selected the correct view in the viewport (front, right, left or perspective etc.) and that you’re happy with the camera angle. 

Choose a suitable angle in the viewport by navigating around the scene.

Click on the render button

Step 6

If you want to have more control over how the final render looks, create a camera object to help. Find a suitable view using the viewport first and then click on the camera button. 

This creates a camera using the current view in the viewport. Check out the camera settings to see how they affect the final render.

Click on the camera button

The End Result

Final Alarm Clock color render

Wait for the final render to finish. Once the render is complete, repeat the steps above and change the camera or the view port to create a new image from a different angle. 

Throughout the course of the project you have successfully learnt:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Alarm Clock
  • How to Create Coloured Materials
  • How to Add Lighting to the Scene
  • How to Render the Alarm Clock

Feel free to share your own creations below. You can also export your image into Adobe Photoshop to enhance it further or to use it as part of a larger image.

Posted on Leave a comment

How to Create a Switch in Cinema 4D: Part 2

Final product image
What You’ll Be Creating

Follow this tutorial step-by-step to create a 3D Nintendo Switch model to use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly. 

Some of the skills you’ll learn in this tutorial include creating basic 3D modelling, importing reference images, adding lighting to the scene and basic rendering techniques.

In the first part (How to Create a Switch in Cinema 4D: Part 1) of the two-part tutorial, I showed you how to:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Switch

In this, the second part of the the tutorial series, I’ll show you how to:

  • How to Create Coloured Materials
  • Color in the Nintendo Switch Model
  • Render the Nintendo Switch Model

16. How to Create a New Material

Step 1

Located near the bottom of the screen there is a material selection window. Click on Create > New Material to create a new material to use that you can edit. 

Materials are used to colour in the the Nintendo Switch.

Select New Material from the menu
Select New Material from the menu

Step 2

Double-click on the new material icon (displayed as a sphere). This brings up the Material Editor, where you adjust the various properties of the material such as the colour, transparency and reflectance. 

For this particular style you’ll only be interested in flat colour (Luminance).

Open the Material Editor
Open the Material Editor

Step 3

Tick the button for Luminance and untick the boxes for Colour and Reflectance. This will give the cel shaded look for the final image. 

Select Luminance
Select Luminance

Step 4

Colour the body of the Nintendo Switch by adding the material to the object. Drag and drop the material to the object using the mouse. You can also drag and drop the material onto the object listed on the right of the screen. 

Drag new material on to the 3D model
Drag new material on to the 3D model

17. How to Adjust the Material Properties

Step 1

In the Material Editor, click on the arrow button next to Texture and select Sketch and Toon > Cel from the menu.

Select Sketch and Toon and Cel from the menu
Select Sketch and Toon and Cel from the menu

Step 2

Click on the new Cel button that appears next to Texture to bring up a new menu.

Click on the Cel button
Click on the Cel button

Step 3

In this new menu, adjust the settings as follows:

  1. Change the Diffuse to match the image at below. It should be grey scale with the colour getting light from left to right.
  2. Untick Camera.
  3. Tick Lights.
  4. Tick Shadows 
  5. Select Multiply from the drop down menu.
Adjust the settings in the editor
Adjust the settings in the editor

Step 4

Select a colour by double-clicking on the colour option box . 

The Material Editor gives many different options for choosing and picking colours. These include RGB, HSV and so on. 

Choose whichever option you’re most familiar with as a flat colour. Because of the Multiply shading mode, the different colour shades will also appear in the material.

If the material has already been applied to the model, the colour of the model will automatically be adjusted to the new material colour. This is useful if you change your mind on a certain colour or a certain part of the Nintendo Switch model. 

Choose the following colours for this tutorial:

  • R: 84
  • G: 100
  • B: 153
Create a colour for the object
Create a colour for the object

Step 5

Because you’ve already applied the material to the model, the colour of the Switch is automatically adjusted to the new material colour.

Apply the colour
Apply the colour

18. How to Adjust the Shading

Step 1

To get a  better idea of the shading and how our render will turn out as we work on it, click and hold the Render Button and select Interactive Render Region from the menu. 

Select Interactive Render Region
Select Interactive Render Region

Step 2

Use the mouse to adjust the window so that it fits around the Nintendo Switch model. Look for the very small arrow on the right hand side of the window and use the mouse to drag it to the top right corner of the box (this increases the resolution). 

Decrease the resolution by moving the arrow down if you find that the performance is decreasing.

Adjust the resolution
Adjust the resolution

Step 3

To change the way the light source is facing go to Options > Default Light.

You can also add a light object to the scene if you are more comfortable working that way.  

Select default light
Select default light

Step 4

Change the light source in the Default Light window. Click where you’d like the light source to come from on the sphere and it will sync with the view port. Experiment with different lighting positions to come up with a lighting situation that you like. 

This can be adjusted at anytime so you can change the lighting again if you changed your mind.

Change the lighting direction
Change the lighting direction

19. Other Lighting Solutions

Step 1

To set up the basic lighting, go to the Floor button located in the top menu bar. Primary-Click-Hold and then select Physical Sky from the menu.

Select Physical Sky
Select Physical Sky

Step 2

Make sure that Physical Sky is selected in the menu on the right, a new menu appears on the bottom right of the screen. Select the Time and Location tab and choose a time using the left and right arrow keys. 

This changes the lighting of the scene (according to the time of the day). Choose a suitable time to light up the scene. You’ll see how the lighting affects the scene in the viewport.

Select a Time
Select a Time 

Step 3

To add a light to the scene, select the Add Light button in the top menu bar at the top of the screen.

This creates a Light Object which you can move around the scene. Move the light object using the Move Tool to a suitable position.

Select the Add Light Button
Select the Add Light Button

Step 4

To customise the lighting further, experiment with the light object options in the bottom right of the screen. Here you can adjust the Intensity, Light Type and even Colour.

Light Object adjustments
Light Object adjustments

20. How to Colour the Switch Screen

Step 1

To create a new material we can duplicate the material by holding CTRL on the keyboard and then using the mouse to click and drag the material to the side.

Duplicate material
Duplicate material

Step 2

Double-click on the new material to open up the Material Editor and select Luminance. From there we can change the colour to the following:

  • R: 81
  • G: 223
  • B: 185
Choose a new colour
Choose a new colour

Step 3

Apply the new material to the screen by clicking and dragging it directly onto the object.

Apply material to model
Apply material to model

21. How to Colour the Joy-Cons

Step 1

Create a new material. Duplicate a previous material in order to keep the settings from before.

Double-click on the new material to open up the Material Editor and select Luminance. From there we can change the colour to the following:

  • R: 61
  • G: 182
  • B: 255
Create a blue colour for the Joy-Con
Create a blue colour for the Joy-Con

Step 2

Duplicate another new material. Double-click on the new material to open up the Material Editor and select Luminance. From there we can change the colour to the following:

  • R: 255
  • G: 121
  • B: 122
Create a red colour for the Joy-Con
Create a red colour for the Joy-Con

Step 3

Apply the materials to the relevant Joy-Con’s by dragging and dropping the colours onto the objects in the viewport. 

Use the list of objects in the object manager on the right of the screen. 

Apply new materials to Joy-Cons
Apply new materials to Joy-Cons

22. How to Color the Switch Details

Part 1

To color the details of the Nintendo Switch (such as the joystick and the buttons etc.) we are going to use the dark blue material which was the first material created to colour in the screen.

  • R: 84
  • G: 100
  • B: 153
Use the first material
Use the first material

Part 2

Apply the material to the rail of the Joy-Con by dragging and dropping it onto the object.

Apply material to the rail
Apply material to the rail

Part 3

Apply the material to the four buttons of the Joy-Con by dragging and dropping it onto the button objects one at a time.

Apply material to the buttons
Apply material to the buttons

Part 4

Apply the material to the joysick of the Joy-Con by dragging and dropping it onto the objects.

Apply material to the joystick
Apply material to the joystick

Part 5

Apply the material to the “-” button and the “home” button of the Joy-Con by dragging and dropping it onto the objects.

Apply material to the buttons
Apply material to the buttons

Part 6

For the remaining details, create a new material which should be a slightly darker colour than the first material that was created. 

Choose the following colours for this tutorial:

  • R: 73
  • G: 87
  • B: 133
Create a darker material colour
Create a darker material colour

Part 7

Apply the new material onto the details highlighted in the image below.

Apply material to the details
Apply material to the details

Part 8

For the last part of the Joy-Con, use the main blue colour and apply it by dragging and dropping it onto the object.

Apply material to the object
Apply material to the object

Part 9

Repeat the same steps for the second Joy-Con and replace the blue material with the red material.

Apply the materials to the red Joy-Con
Apply the materials to the red Joy-Con

Part 10

For the final details of the Nintendo Switch apply the dark blue material as shown in the image below.

Apply material to the Nintendo Switch
Apply material to the Nintendo Switch

23. How to Render the Nintendo Switch

Part 1

Click on the camera button to return to the camera view. This should be the same composition used in the previous tutorial ‘How to Create a Switch in Cinema 4D: Part 1‘.

Switch the camera on

Part 2

On the top menu bar, click on the Render Settings button. This brings up the render settings window.

Click on the Render Settings button
Click on the Render Settings button

Part 3

In the render settings menu, you can change the options to what you need. First, tick the Save Settings to select a file location, file format and alpha channel.

Select Alpha Channel if you wish to keep the background see through.

Save settings
Save settings

Part 4

In the Output Settings choose the resolution, height and width of the image. 

Output settings
Output settings

Part 5

To ensure that the render is nice and sharp go to the Anti-Aliasing settings. Select Cubic (Still Image) which can be found under Filter. 

Anti-Aliasing settings
Anti-Aliasing settings

Part 6

To create the final image, click on the Render button. Remember to select the right view in the viewport (front, right, left or perspective etc.) and that you’re happy with the camera angle. 

Choose a suitable angle in the viewport by navigating around the scene.

Click on the Render button
Click on the Render button

Part 7

To create the final image, click on the Render button. Remember to select the right view in the viewport (front, right, left or perspective etc.) and that you’re happy with the camera angle. 

Choose a suitable angle in the viewport by navigating around the scene.

Click on the Camera button
Click on the Camera button

The End Result

Wait for the final render to finish. Once the render is complete you can repeat the steps above and change the camera or the view port to create a new image from a different angle. 

Throughout the course of the project you have successfully learnt how to:

  • Import Reference Images
  • Prepare for Modelling
  • Model a Nintendo Switch
  • Create Materials
  • Colour the Model
  • Render the Nintendo Switch

Feel free to share your own creations below. You can also export your image into Adobe Photoshop to enhance it further or to use it as part of a larger image.

Final Nintendo Switch render
Final Nintendo Switch render
Posted on Leave a comment

How to Create a Switch in Cinema 4D: Part 1

Final product image
What You’ll Be Creating

Follow this tutorial step-by-step to create a 3D Nintendo Switch model that you can use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly. 

Some of the skills you’ll learn in this tutorial include creating basic 3D modelling, importing reference images, adding lighting to the scene and basic rendering techniques.

In this, the first part of the two-part tutorial, I’ll show you:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Switch

1. How to Import Reference Images

Step 1

To use the reference image in this tutorial, you will need to switch your viewport to the Front View

Use the middle mouse button to click anywhere on the viewport. This will display all four views—by default this will be perspective, top, right and front. From there, use the middle mouse button to select the Front View.

Cinema 4D 4 views
Cinema 4D 4 views

Step 2

In the Attributes tab select Mode > View Settings.

Select View Settings
Select View Settings

Step 3

In Viewport [Right] select the Back button and click on the button next to Image. 

Select the Back button
Select the Back button

Step 4

Select the reference image from the finder and open it. In this tutorial I’ll use the front view of a Nintendo Switch to help me.

Imported Nintendo Switch image in Cinema 4D
Imported Nintendo Switch image in Cinema 4D

Step 5

Once the image is displayed in the background of the viewport, you can change the transparency of the image to your liking. This sometimes makes it easier to model from the reference image.

You can also change the position and size of your reference image from here using Offset X, Offset Y, Size X and Size Y.

Note that the reference image will only appear when selecting front view from the viewport.

Adjust the transparency settings
Adjust the transparency settings

2. How to Create the Base Model

Step 1

To start modelling the main body of the Nintendo Switch, select the Cube object from the top menu bar. This will spawn a cube in the viewport.

Select the Cube object
Select the Cube object

Step 2

Use the reference image of the Nintendo Switch in the Front View to help adjust the cube.

Use the Scale Tool to make the shape of the cube match up with the shape of the Nintendo Switch in the image.

Ensure that you use the other views—front, left, right, perspective etc—to check that the shape looks correct from every angle.

Adjust the cube object to fit the reference image
Adjust the cube object to fit the reference image

Step 3

The shape of the cube should roughly fit the shape of the Nintendo Switch background image at this stage. 

Select the Move Tool. To duplicate this shape you’ll need to hold CTRL button on the keyboard and then click and drag one of the arrows using the mouse. In this case I’ve used the red arrow to drag the new object along the x-axis.

Duplicate object
Duplicate object

Step 4

Use the Scale Tool to adjust the shape of the cube to match up with the shape of the blue Joy-Con in the reference image.

Scale the cube object
Scale the cube object

Step 5

Use the Perspective View to move around the objects and make sure that the overall thickness of the base objects are correct. In the example below the objects are too thick, so the Scale Tool is used to reduce the thickness (click and drag along the z-axis).

Scale the width of the cube objects
Scale the width of the cube objects

3. How to Curve the Joy-Con Corners

Step 1

Ensure you have the object selected and then click on the Make Editable button to make the object editable. Select the Edge Selection button.

Select the Make Editable and Edge Selection buttons
Select the Make Editable and Edge Selection buttons

Step 2

Select the two left corners of the Joy-Con using the selection tool. The selected edges will be highlighted in orange.

Select edges
Select edges

Step 3

Once the edges have been selected, use the mouse to right click on the selected edges. In the menu that appears, find Bevel and select it.

Select Bevel
Select Bevel

Step 4

In the adjustment window (usually located in the bottom right of the screen), play around with the following:

  • Bevel Mode: Chamfer
  • Offset Mode: Fixed Distance
  • Offset: 50 cm
  • Subdivision: 20
  • Depth: 100%

Feel free to adjust the sliders and values until you are satisfied with the object’s appearance. You can also use the Front View and adjust corners to fit the reference image.

Curve the corners
Curve the corners

Step 5

To make visualising the Joy-Con in the view port easier, switch off the screen object by clicking on the small round grey button (until it turns red). This is located to the right of the screen object in the object manager list view.

Click on the button until it turns green (or grey) to make the object reappear again.

Select the red button
Select the red button

Step 6

With the screen object hidden from view it makes navigating around the Joy-Con a lot easier. Use the reference image in the front view to check the shape of the object.

Curve the corners
Curve the corners

Step 7

Select the final two corners of the Joy-Con using the Edge Selection tool.

Select the edges
Select the edges

Step 8

Once the edges have been selected, use the mouse to right click on the selected edges. In the menu that appears, find Bevel and select it. Use the Bevel too to curve the two remaining corners of the Joy-Con.

  • Bevel Mode: Chamfer
  • Offset Mode: Fixed Distance
  • Offset: 10cm
  • Subdivision: 10
  • Depth: 100%
Curve the corners
Curve the corners

4. How to Curve the Screen

Step 1

Select the screen object and click on the Make Editable button followed by the Edge Selection button. 

Ensure that the screen object is no longer hidden by clicking on the small round button in the object manager list view. 

Select the Make Editable and Edge Selection buttons
Select the Make Editable and Edge Selection buttons

Step 2

To make visualising the screen object in the viewport easier, switch off the Joy-Con object by clicking on the small round grey button (until it turns red). 

This is located to the right of the Joy-Con object in the object manager list view.

Click on the red button

Step 3

Once you click on the small round grey button the Joy-Con object should disappear from the viewport. 

Click on the button until it turns green (or grey) to make the object reappear again.

Front view adjustments
Front view adjustments

Step 4

Use the Edge Selection tool to select all four corners of the screen object.

Select the edges
Select the edges

Step 5

Once the edges have been selected, use the mouse to right click on the selected edges. In the menu that appears, find Bevel and select it.

Select Bevel
Select Bevel

Step 6

In the adjustment window (usually located in the bottom right of the screen), play around with the following:

  • Bevel Mode: Chamfer
  • Offset Mode: Fixed Distance
  • Offset: 15 cm
  • Subdivision: 10
  • Depth: 100%

Feel free to adjust the sliders and values until you are satisfied with the object’s appearance. 

You can also use the Front View and adjust corners to fit the reference image.

Curve the corners
Curve the corners

5. How to use Boole

Step 1

To create the top corners of the screen, use the Boole tool. To get started with this select the Cylinder object from the top menu bar. This will spawn a cylinder in the viewport.

Select the Cylinder object button
Select the Cylinder object button

Step 2

Use the Rotate Tool to rotate the cylinder 90 degrees in the z-axis.

Rotate the cylinder object
Rotate the cylinder object

Step 3

Use the Scale Tool to make the cylinder thinner.

Scale the Cylinder object
Scale the Cylinder object

Step 4

In the front view, duplicate the cylinder and use the reference image to position the cylinders to the top corners of the screen object.

Place the cylinder objects
Place the cylinder objects

Step 5

Both cylinder objects should completely cover the corners of the screen. Use the perspective view to move the cylinders into position.

Move the cylinder objects
Move the cylinder objects

Step 6

Once the cylinder objects are in position, select the Boole Tool from the top menu bar. 

Select the Boole Tool
Select the Boole Tool

Step 7

In the object manager list view, select both cylinder objects and group them (Alt-G). This will create a ‘Null’ group containing the selected objects.

Group objects together
Group objects together

Step 8

Move both the screen object and the Null object inside the Boole Tool. Make sure that the screen is positioned above the Null group.

Place objects inside the Boole
Place objects inside the Boole

Step 9

Once the objects have been placed within the Boole Tool, the cylinder object will be subtracted from the screen object. 

Create a cutout shape using Boole
Create a cutout shape using Boole

6. How to Create the Screen

Step 1

To duplicate the screen object, select the it from the object list (found within the Boole tool). Press the CTRL button on the keyboard and click and drag the object you want to duplicate. 

Make sure that the new screen object is outside the Boole tool.

Duplicate the screen
Duplicate the screen

Step 2

Use the Scale Tool to make the new screen object smaller.

Scale the screen
Scale the screen

Step 3

In the front view you can use the reference image to help adjust the size of the screen.

Check the front view
Check the front view

Step 4

Once you are satisfied with the size of the screen, use the Move Tool to move the object inside and just above the surface of the original screen object.

You can also use the Scale Tool to reduce the thickness of the shape so that it becomes thinner.

Scale the screen
Scale the screen

7. How to Create Joy-Con Details

Step 1

Isolate the Joy-Con object to make working in the viewport easier. One way you can do this, is by clicking on the small grey button next to the objects you wish to hide (as shown previously).

Joy-Con shape
Joy-Con shape

Step 2

Click on the small back arrow on the Cube button and select Cylinder from the list of options. This will spawn a cylinder in the scene.

Select the Cylinder object button
Select the Cylinder object button

Step 3

Rotate the new cylinder object in the x-axis using the Rotation Tool.

Rotate the Cylinder object
Rotate the Cylinder object

Step 4

Use the right view in the viewport to check the size of the cylinder. Then use the Scale Tool to reduce the size of the object so that it can easily fit within the width of the Joy-Con.

Scale the Cylinder object
Scale the Cylinder object

Step 5

You can also use the object properties to adjust the size of the cylinder and also the amount of segments it has.

  • Radius: 14 cm
  • Height: 200 cm
  • Height Segments: 1
  • Rotation Segments: 36
  • Orientation: +x
Adjust the object properties
Adjust the object properties

Step 6

With the new cylinder object selected, click on the Make Editable button.

Select the Make Editable button
Select the Make Editable button

Step 7

Use the Move Tool and combine it with the Points Selection Tool.

Select the Move Tool and the Points Selection Tool
Select the Move Tool and the Points Selection Tool

Step 8

In the options window, make sure that the box for ‘Only Select Visible Elements’ is not selected. This will ensure that you will select all the necessary points.

Untick Only Select Visible Elements button
Untick Only Select Visible Elements button

Step 9

Select the bottom half of the cylinder object.

Select half the Cylinder
Select half the Cylinder

Step 10

Use the Move Tool to move the selected points down and making the object longer.

Adjust object shape
Adjust object shape

Step 11

Use the Selection Tool to select the curved corners on the right of the cylinder shape.

Select corners
Select corners

Step 12

Use the Move Tool to move the selected points a little bit to the right to make the object slightly wider.

Adjust object shape
Adjust object shape

Step 13

Click on the Model Mode button on the left of the screen and move the shape to the center of the Joy-Con.

Move object into position
Move object into position

Step 14

In the perspective view, use the Move Tool and the Scale Tool to adjust the shape so that it appears slightly above the side surface of the Joy-Con.

Move object into position
Move object into position

Step 15

Create three more cylinder objects and move them into position using the Scale Tool and the Move Tool.

Create three additional cylinders
Create three additional cylinders

Step 16

Adjust the bottom cylinder using the Points Tool and the Selection Tool. Select the top half of cylinder and move the points up slightly.

Select the points
Select the points

Step 17

Return to Model Mode and adjust the shapes so that they resemble the image below.

Adjust the shape
Adjust the shape

Step 18

Use the perspective view to move the cylinder objects into position using the Move Tool. The cylinders should be placed within and just above the surface of the Joy-Con.

Move objects into position
Move objects into position

8. How to Duplicate Joy-Con

Step 1

Select all the objects related to the Joy-Con and group them (Alt-G). This will create a new ‘Null Group’.

Group objects together
Group objects together

Step 2

Select the Null group containing the Joy-Con and duplicate it (hold the CTRL button on the keyboard and use the Move Tool).

Duplicate grouped objects
Duplicate grouped objects

Step 3

Rotate the new Joy-Con object 180 degrees using the Rotation Tool.

Rotate Joy-Con
Rotate Joy-Con

Step 4

In the front view, use the reference image to move the new Joy-Con into position (above the red Joy-Con).

Place Joy-Con in the right position
Place Joy-Con in the right position

9. How to Create Buttons

Step 1

Select the Cylinder from the top menu.

Create a Cylinder object
Create a Cylinder object

Step 2

This will spawn a new cylinder object in the viewport. Use the Scale Tool to reduce the size of the cylinder so that it is the same size of the buttons shown in the reference image.

Scale the cylinder object down
Scale the cylinder object down

Step 3

Use the reference image to move the cylinder object into position. Then duplicate the cylinder object to create the other three buttons.

Create buttons
Create buttons

Step 4

Use the perspective view to move the buttons into position. The cylinders should be placed within and just above the surface of the Joy-Con.

Place the buttons
Place the buttons

Step 5

Group the buttons together (Alt-G) and duplicate the new Null object. Use the front view and use the reference image to move the new buttons into a new position above the red Joy-Con.

Duplicate the buttons
Duplicate the buttons

Step 6

Duplicate one of the cylinder buttons and place it into the Home Button position for the red Joy-Con. Once all the buttons have been placed correctly, unhide the red Joy-Con.

Unhide objects
Unhide objects

10. How to Create Joystick

Step 1

Click on the small back arrow on the Cube button and select Cylinder from the list of options. This spawns a cylinder in the scene.

Select the cylinder object
Select the cylinder object

Step 2

Use the Scale Tool to reduce the size of the cylinder so that it matches the size of the joystick.

Scale the cylinder object
Scale the cylinder object

Step 3

Use the Move Tool to move the cylinder into position (use the background reference image in the front view to help with this).

Move object into position
Move object into position

Step 4

In the perspective view use the Scale Tool to reduce the thickness of the cylinder object (click and drag along the z-axis).

Scale the cylinder object
Scale the cylinder object

Step 5

Duplicate the cylinder object and use the Scale Tool to reduce the size. 

Scale the cylinder object
Scale the cylinder object

Step 6

Once you are happy with the reduced size of the cylinder, use the Scale Tool to increase the length of the cylinder in the z-axis.

Increase height of the cylinder
Increase height of the cylinder

Step 7

Move both cylinder objects into position above the surface of the Joy-Con. Once the joystick is in position, select the top cylinder and duplicate it.

Duplicate cylinder
Duplicate cylinder

Step 8

Move the new cylinder object into position just above the surface of the Joy-Con. This will act as the base of the joystick.

Move object into position
Move object into position

Step 9

Duplicate one of the cylinders again and use the Scale Tool to reduce its size. Place the smaller cylinder just above the top of the joystick.

Move object into position
Move object into position

Step 10

Use the Boolean Tool to create a cutaway using the two top cylinder objects. Ensure the smaller cylinder is placed below the larger cylinder when viewed in the object manager list view.

Use Boole Tool
Use Boole Tool

11. How to Create Extra Joy-Con Buttons

Step 1

In the top menu bar select the Cube to spawn a cube into the scene.

Create a cube object
Create a cube object

Step 2

Use the Scale Tool to adjust the cube to the same size as the Capture Button (use the reference image in the front view to help with this). 

Then use the Move Tool to move the cube into position.

Move object into position
Move object into position

Step 3

Curve the corners of the cube using the Bevel Tool. 

Curve the corners
Curve the corners

Step 4

Use the Move Tool to place the cube object just above the surface of the Joy-Con.

Move object into position
Move object into position

Step 5

Create a new cube object and curve the corners using the Bevel Tool. Click and drag using the mouse to adjust the size of the curve so that it almost resembles a circle.

Select the corners and curve them
Select the corners and curve them

Step 6

Use the Selection Tool to select half of the object and move it to the left to create the ‘-button’.

Select half of the object and adjust
Select half of the object and adjust

Step 7

In the perspective view, use the Move Tool to move the ‘- button’ into position just above the surface of the Joy-Con.

Move object into position
Move object into position

Step 8

With all the buttons and the joystick in place, the Joy-Con should resemble the image shown below.

The Nintendo Joy-Con in 3D
The Nintendo Joy-Con in 3D

12. How to Duplicate Joystick

Step 1

Group the objects that make up the joystick by selecting them and pressing Alt-G on the keyboard. This will create a new ‘Null Object’.

Then duplicate the new ‘Null Object’ but holding the Ctrl button on the keyboard and click drag with the mouse using the Move Tool.

Duplicate joystick group
Duplicate joystick group

Step 2

Move the new joystick into position using the reference image in the front view.

Move object into position
Move object into position

13. How to Create + Button

Step 1

Duplicate the ‘- button’ and move it into position.

Move object into position
Move object into position

Step 2

Duplicate the button and use the Rotate Tool and the Move Tool to create a cross shape for the ‘+ button’.

Create the cross button
Create the cross button

Step 3

Unhide the screen object. With all the buttons and both joysticks in place, the Nintendo Switch should finally be taking shape. 

Create a pose
Create a pose

14. How to Create Bottom Screen Details

Step 1

Duplicate the objects on the side of the Joy-Con and rotate it in the z-axis by 90 degrees.

Adjust the details
Adjust the details

Step 2

Move the group of objects to the bottom of the screen just above the surface. Once the ‘Null Object’ is in position, duplicate the group.

Add Nintendo Switch details
Add Nintendo Switch details

Step 3

Select the new group and rotate it 180 degrees. 

Rotate the objects
Rotate the objects

Step 4

Group both objects together and position them in the centre of the screen.

Final Nintendo Switch model in 3D
Final Nintendo Switch model in 3D

15. How to Pose Nintendo Switch

Step 1

Select all the objects associated with each Joy-Con and create separate groups for them. One group for the left Joy-Con and one group for the right Joy-Con.

Use the Move Tool to move each Joy-Con away from the screen slightly as shown in the image below.

Spread the Joy-Cons
Spread the Joy-Cons

Step 2

Move the right Joy-Con up in the y-axis slightly to create an interesting composition. Try out different positions by using the move tool and moving the camera around. 

Post the Nintendo Switch
Post the Nintendo Switch

Coming Next…

In the second part of the the tutorial series, I’ll show you how to:

  • Create Coloured Materials
  • Colour in the Nintendo Switch Model
  • Render the Nintendo Switch Model
Posted on Leave a comment

How to Create a Smartwatch in Cinema 4D: Part 2

Final product image
What You’ll Be Creating

Follow this tutorial step-by-step to create a 3D Smartwatch model that you can use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly. 

Some of the skills you’ll learn in this tutorial include creating basic 3D modelling, importing reference images, adding lighting to the scene and basic rendering techniques.

In the first part of the two-part tutorial, I showed you how to:

  • How to Import Reference Images
  • How to Prepare for Modelling
  • How to Model the Smartwatch

In this, the second part of the the tutorial series, I’ll show you how to:

  • How to Create Coloured Materials
  • How to Add Lighting to the Scene
  • How to Render the Smartwatch

8. How to Create a New Material

Step 1

Located near the bottom of the screen there should be a material selection window. Click on Create > New Material to create a new material to use that you can edit. 

Materials are used to colour in the various objects and parts of the Smartwatch.

Create a new material

Step 2

Double click on the new material icon (displayed as a sphere). This brings up the Material Editor, where you adjust the various properties of the material such as the colour, transparency and reflectance. 

For this particular style you’ll only be interested in flat colour (Luminance).

Choose Luminance

Step 3

Tick the button for Luminance and untick the boxes for Colour and Reflectance. This will give us the cel shaded look for our final image of the Smartwatch.

Unticl Color and Reflectance

Step 4

Colour the Smartwatch, starting with the body, by adding the material to the object. Simply drag and drop the material to the object using the mouse. Drag and drop the material onto the object listed on the right of the screen. 

This process is repeated for the other parts of the Smartwatch. The base colour of the Smartwatch is as follows:

  • R: 201
  • G: 197
  • B: 198
Adjust the color

Step 5

Apply this material colour to the Smartwatch buttons as well

Add the material to the buttons

9. How to Adjust the Material Properties

Step 1

In the Material Editor, click on the arrow button next to Texture and select Sketch and Toon > Cel from the menu.

Choose Sketch and Toon

Step 2

Click on the new Cel button that appears next to Texture to bring up a new menu.

Click on the Cel button

Step 3

In the new menu, adjust the settings as follows:

  1. Change the Diffuse to match the image at below. It should be grey scale with the colour getting light from left to right.
  2. Untick Camera.
  3. Tick Lights.
  4. Tick Shadows 
  5. Select Multiply from the drop down menu.
Select Multiply

Step 4

Select a colour by double-clicking on the colour option box . 

The Material Editor gives you many different options for choosing and picking the colour. These include RGB, HSV etc. Choose whichever option you’re most familiar with as a flat colour. Because of the Multiply shading mode, the different colour shades also appears in the material.

If the material has already been applied to the model, the colour of the model is automatically adjusted to the new material colour. This is useful if you change your mind on a certain colour or a certain part of the Smartwatch model.

Use the Color Picker

Step 5

Because you’ve already applied the material to the model, the colour of the Smartwatch is automatically adjusted to the new material colour.

Adjusted material shown on watch

10. How to Adjust the Shading

Step 1

To get a  better idea of the shading and how our render will turn out as you work on it, click and hold on the Render Button and select Interactive Render Region from the menu. 

Choose Interactive Render Region

Step 2

Use the mouse to adjust the window so that it fits around the Smartwatch model. Look for the very small arrow on the right hand side of the window and use the mouse to drag it to the top right corner of the box (this increases the resolution). 

Decrease the resolution by moving the arrow down if you find that the performance is decreasing.

Increase the Resolution

Step 3

To change the way the light source is facing go to Options > Default Light.

Add a light object to the scene if you are more comfortable working that way. 

Change light source direction

Step 4

Change the light source in the Default Light window. Click where you’d like the light source to come from on the sphere and it’ll sync with the view port. Experiment with different lighting positions to come up with a lighting situation that you like. 

This is adjusted at anytime so you can change the lighting again if you changed your mind.

Click on the Default Light

11. Other Lighting Solutions

Step 1

To set up the basic lighting, go to the Floor button located in the top menu bar. Left Click-Hold and then select Physical Sky from the menu.

Choose Physical Sky

Step 2

Ensure that Physical Sky is selected in the menu on the right, a new menu appears on the bottom right of the screen. Select the Time and Location tab and choose a time using the left and right arrow keys. 

This changes the lighting of the scene (according to the time of the day). Choose a suitable time to light up the scene. You’ll see how the lighting affects the scene in the viewport.

Choose Time and Location

Step 3

To add a light to the scene, select the Add Light button in the top menu bar at the top of the screen.

This will create a Light Object which you can move around the scene. Move the light object using the Move Tool to a suitable position.

Select Light Object

Step 4

To customise the lighting further, experiment with the light object options in the bottom right of the screen. Here you can adjust the Intensity, Light Type and even Colour.

Adjust the Light Object

12. How to Colour the Smartwatch Screen

Step 1

To create a new material we can duplicate the material by holding CTRL on the keyboard and then using the mouse to click and drag the material to the side.

Duplicate the Material

Step 2

Double click on the new material to open up the Material Editor and select Luminance. From there change the colour to the following:

  • R: 56
  • G: 47
  • B: 66
Change the color of the Luminance

Step 3

Apply the new material to the screen by clicking and dragging it directly onto the object.

Color the Smartwatch screen

13. How to Colour the Smartwatch Wrist Strap

Step 1

Create a new material. Duplicate a previous material in order to keep the settings from before.

Double click on the new material to open up the Material Editor and select Luminance. From there change the colour to the following:

  • R: 70
  • G: 69
  • B: 65
Choose a new color for the wrist strap

Step 2

Apply the new material to both of the wrist straps by either clicking on the material and dragging it to the objects via the viewport or via the object list window.

Add material to the wrist strap

14. How to Render the Smartwatch

Step 1

On the top menu bar, click on the Render Settings button. This brings up the render settings window.

Click on Render Settings

Step 2

In the Render Settings menu, change the options to what you need. First you will need to tick the Save Settings to select a file location, file format and alpha channel.

Select Alpha Channel if you wish to keep the background see through. This is useful if you wish to add a background to the image in Adobe Photoshop.

Enter Save Settings

Step 3

In the Output Settings choose the resolution, height and width of the image. 

Enter Output Settings

Step 4

To ensure that the Smartwatch render is nice and sharp, go to the Anti-Aliasing settings. Select Cubic (Still Image) which can be found under Filter

Choose Cubic Still Image

Step 5

To create the final image of the Smartwatch, click on the Render button. Remember to make sure that you’ve selected the right view in your viewport (front, right, left or perspective etc.) and that you’re happy with the camera angle. 

Choose a suitable angle in the viewport by navigating around the scene.

Click on the Render button

Step 6

For more control over how the final render looks, create a camera object to help. Find a suitable view using the viewport first and then click on the camera button. 

This creates a camera using the current view in the viewport. Check out the camera settings to see how they will affect the final render.

Click on the Camera button

The End Result

Wait for the final render to finish. Once the render is complete, repeat the steps above and change the camera or the view port to create a new image from a different angle. 

Throughout the course of the project you’ve learnt how to:

  • Import Reference Images
  • Prepare for Modelling
  • Model an Smartwatch
  • Create Coloured Materials
  • Add Lighting to the Scene
  • Render the Smartwatch

Feel free to share your own creations below. You can also export your image into Adobe Photoshop to enhance it further or to use it as part of a larger image.

Final Smartwatch render