In our previous blog, we explored how to make a human follow a predefined path using JavaScript. If you missed it, be sure to check out the previous blog before continuing!
Now, let’s take things a step further and dive into how to create and automate Human Postures in 3DEXCITE using JavaScript. By the end of this tutorial, you’ll learn how to make your human actor perform dynamic postures triggered by specific actions.
Step 1: Import Human Model
The first step is to import a human model into your scene. Here’s how you do it:
Go to the Project Tree under Actors.
Right-click and select Create Humans to add a human model to your scene.
You can now position and adjust the human as needed.
Figure 1 : Creation of Human – Creative Eperience
Step 2: Create Human Posture
Next, we define a human posture that the character will assume at a certain point. This step is crucial for adding variety and realism to the character’s actions.
In the Properties panel, select the human model.
Locate the Posture Behavior section and choose a predefined posture or create a custom one for your human actor.
Adjust the pose settings as necessary to fit your scene. You can manipulate the body parts, facial expressions, and more.
Step 3: Create Animation Editor
Now, let’s set up the Animation Editor to handle the human movements and postures:
In the Animation Editor, create a new animation sequence.
Define keyframes to transition between different postures.
You can control the timing, speed, and smoothness of the transitions, giving the illusion of dynamic, lifelike movements.
Step 4: Create Scripted Actor
To automate the posture change, we need to use JavaScript:
Go to the Scene Graph and create a Scripted Actor.
Attach a new script to the scripted actor—this is where we will write the JavaScript code to trigger the human posture.
Here is the basic JavaScript code you can use to trigger the posture change:
var PostureEventClass = function () { EP.Event.apply(this, arguments); };
if (!STU.PostureEvent) { STU.PostureEvent = PostureEventClass; }
if (!EP.EventServices.getEventByType(PostureEventClass.prototype.type)) { EP.EventServices.registerEvent(PostureEventClass); }
beScript.onStart = function () { // Initialization when the script starts };
beScript.onStop = function () { // Cleanup when the experience stops };
beScript.execute = function (context) { // Called every frame };
beScript.onAllKeyboardRelease = function (iEvent) { if (iEvent.key === this.TriggerKey) { // Use your custom key value let newEvent = new STU.PostureEvent(); this.actor.dispatchEvent(newEvent); } };
In this code:
We define a PostureEventType to trigger the posture change.
We listen for keyboard input to trigger the event (e.g., pressing ‘L’ for posture).
Once the key is pressed, a PostureEvent is dispatched to the human actor to execute the desired posture.
Step 5: Create Scene Scenario
With the Scripted Actor in place, let’s link everything together using Storytelling:
Open Storytelling and Create a New Scenario.
Add an “Each Time Script Actor is Executed” action.
Specify that the Animation should perform a posture change when the script is executed.
Step 6: Play the EXPERIENCE
Finally, hit the Play button to run the experience:
Once you start the experience, press ‘L’ (or the key you defined in the script).
The human actor will automatically transition into the posture you set up in the animation.
Conclusion
With these steps, you’ve successfully created and automated Human Postures in 3DEXCITE using JavaScript. The next time you create a scene, you can apply these techniques to bring more realism and interactivity to your 3D experience. Whether it’s for a demonstration or an immersive storytelling moment, Human Postures add a dynamic touch that enhances the user experience.
1 Comment on “Human Postures in 3DEXCITE”