Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
360 Rotation/Camera UpVector problem - request for "Look At" action that is unaffected by gimbal locks.

wild-master
Registered User
Quote
2018-04-29 17:59:39

I am requesting a Behavior or Action that will allow an object to look directly at another object while it moves around, and when that object rotates to look at the other object, it must move in a non-human way.

If you want to know what I mean by non-human rotations, try this sample CCB file:
https://drive.google.com/file/d/...

In that file, I use the "moveto" feature of the ccbAICommand() function, and I set the Enemy's movement speed to zero. Do you want to know why I did that? I did that because the "moveto" feature is unaffected by gimbal locks because it uses quaternions internally, so setting it to a speed of zero will be the same as having a "Look At" feature, but even though it isn't affected by gimbal locks, it is still affected by the assumption that the character using the "moveto" feature is a human.

When you start that CCB file, please don't use the mouse and don't press other buttons except for the A and D buttons, and you will realize that you are a first-person character and you are standing directly above an enemy. When you press the A and D buttons, you will move left and right, and you will realize that the enemy rotates like it's a human who is looking upward at words written upside-down on a ceiling and is turning his body to read them! The enemy doesn't rotate perfectly like a non-living entity! The rotations of the "moveto" feature assume that the character is a human who is always standing up and only turns his head up or down without actually flipping his whole body like a non-living entity!

I hope a smarter person will read this and implement a Behavior or Action extension that will allow an object to look at another object without being affected by gimbal locks and also rotate perfectly like a non-living sphere instead of like a human who will stand up forever.

Also, I am requesting a solution for another problem that affects the Camera.

The Camera also always assumes that it is a human that is always standing up. If I gradually rotate it by 360 degrees, it will flip incorrectly!

I don't use the built-in Behaviors for the Camera because my game depends on custom camera manipulation, but rotating it myself with JavaScript still causes it to think that it is a human that is always standing up and refuses to flip his whole body vertically.

I attempted to solve this by modifying the UpVector parameter of the Camera when it reaches the 90 degree point and the 270 degree point, but that causes a flicker because the camera turns around instantly instead of actually moving upside down.

Please try this CCB file and only press the W button (press and hold the W button and watch what happens when it reaches the 90 degree point and the 270 degree point:
https://drive.google.com/file/d/...

If you hold the W button and do a full 360-degree motion, you will be back at the beginning because you will be looking at the Cube again, but the flickers that happen at the 90 degree point and the 270 degree point are caused because the camera is instantly turned at those points instead of smoothly moving upside down to do a real 360-degree motion. Imagine a person who looks upward at 89 degrees, and then he instantly turns around when he reaches 90 degrees while his head is still pointed upward! And when he looks at the floor at 269 degrees, he will instantly be turned around and looking at the floor at 270 degrees instead of doing a real 360-degree motion! That's how the camera work in CopperCube! I want real continuous 360-degree rotations instead of human-based turns!

(continued in next post)


wild-master
Registered User
Quote
2018-04-29 18:00:29

(I needed to split this long message because this forum has a length limit for each post)

Summary of my requests:
1. A perfect LookAt Behavior or action that is unaffected by gimbal locks and is also unaffected by human-like rotations.
2. A way to implement real vertical 360-degree freedom for the camera.

Important note for Niko about Goal Number 2 that I didn't mention in my emails:
If you decide to do request number 2, you might first assume that the solution is to create a Behavior with a name like Free-Form 360 Camera, but remember this:
Example: Right now, you have a Third-Person Camera Behavior, but I don't use it because I don't like its method of smoothing and its method of following is too quick, so I created my own Third-Person Camera by creating multiple Child nodes behind my main character and using the "Absolute Position" feature to place the Camera near the Absolute Positions of those Child nodes. My camera moves around freely with some leeway within the range of those Child nodes, and I think it seems beautiful.
So, while you may think that creating a Behavior called Free-Form 360 Camera might be the correct solution, that would mean that people who want to create their own Camera motions will be unable to use the 360-freedom feature, so a better solution would be to place a tick box for the UpVector in the Attributes column of all Cameras that would allow people to decide if they want an UpVector or if they want 360-degree freedom.

I already told most of this information to Niko, with the biggest exception being the important note above, but I am also asking here in case other members have already solved these problems with custom scripting and are willing to share.


wild-master
Registered User
Quote
2018-05-28 20:50:18

OOOOOHHH WWOOOOOOWWW!

OOOOOOOOOOHHHHHHHHH WWWWOOOOOOOWWWWWW!!!!!!!

Look at what I did!

Look at what I did!

I created a devilish amount of objects that are used as mimickers! They mimic the current position of the "UpVector" of the Camera, and force it to always be at the correct spot, so I can rotate vehicles vertically, even past 360 degrees, and the Camera's view won't be flipped!

It's not perfect. It's flawed because I don't have a non-human "Look At" feature. It simulates a LookAt feature by using the "moveto" feature of the "ccbAICommand()" function, while its speed is set to zero in the "Game Actor with Health" Behavior that's attached to the same node, so it will rotate to look at the object, but it WON'T move toward it.

I use that method to force an object to always look upward, and I capture the difference between its own position and the position of its child node with a variable, and I set that value as the new UpVector!

I believe the flaw would be removed if I could create a non-human "LookAt" feature. The flaw I am referring to is the slight "twist" that happens during the highest vertical point and the lowest vertical point. The "moveto/LookAt" feature built into CopperCube causes the object to turn around, like a human who rotates his body to read words that are upside-down on a ceiling. Without that flipping, my method of achieving a 360-degree Camera would be far better! (Don't be scared of the flaw: It doesn't successfully flip, probably because its desire to flip is limited by the fact that it's a Child node, so the 360-degree rotation isn't ruined, but it tries to, for a slight moment, like a thief in the night.)

If a professional wants to check what I am referring to when I say "it attempts to flip/twist", try the sample and look at what happens when the X-rotation of the Camera reaches these two points:
1. 360 (At this 360 point, the Camera is perfectly horizontal, but the Child node is looking perfectly upward, toward the "270" point, so this Child node tries to flip.)
2. 180 (The Camera is also perfectly horizontal here, but the Child node is looking perfectly downward, toward the "90" point, so this Child node tries to flip here, too.)

Try the CCB file here:
https://drive.google.com/file/d/...

When you test that file, press "W" or "S" to rotate vertically, and witness the splendor of the Camera as it DOESN'T flip when it reaches the "90" and "270" points!

Sinful note for Nikolaus:
I am always willing to spend colossal amounts of time to discover solutions without help, but I cannot comprehend math like you can. I wish I could understand and manipulate Matrices on my own, so I could achieve my own desires without your help. I spent around twelve hours yesterday playing with the source of CopperLicht, to try to understand the Matrix that creates the view of Cameras, but I failed, and the temporary solution that I created above required less than one hour of thoughts. I couldn't understand the math like a super tough man can, so I created a nasty method instead.

"I cannot comprehend the math of my peers, so I created a system of gears and pivots that simulates the same functionality."
~A person at NASA was fired when he said those words.


wild-master
Registered User
Quote
2018-05-29 01:06:19

Mission Accomplished! I fixed the problem mentioned in the last message!

I discovered that this pursuit doesn't require a "LookAt" feature!

I removed the "moveto/LookAt" portion of the code, and I tried a slightly different method, and the Camera now rotates over 360 degrees without flipping/twisting!

Try this new CCB file:
https://drive.google.com/file/d/...

Use the "WASD" keys to rotate.

I removed many unused portions from the scripts inside of the CCB file, so it's easier to study. (The seven cones are just visual guides. They don't have other uses.)

Important Note:
1. The left and right turns will be flipped while the camera is upside-down. That should be easy to fix, but I haven't tried yet. I'm too tired.


just_in_case
Moderator
Quote
2018-05-29 08:21:11

Sounds awesome! Will check out the sample once i reach home!!

edit: it works really great... Rotation is good now..


wild-master
Registered User
Quote
2018-05-30 23:49:44

Update:
Yesterday, within the source code of CopperLicht, I created a second version of the Matrix function called "buildCameraLookAtMatrixLH". I removed all visual features from it, so it can be attached to all nodes. It works like a normal "LookAt" feature, but I am still proud of the practice I gained. I also implemented the 360-degree Camera in CopperLicht.

Today, I learned how to use "Forward Vectors", and I learned how to create a "LookAt" feature with Quaternions. I combined it with CopperLicht's function called "setRotateToTargetAndStop()", which uses "Spherical Linear Interpolation". I captured the Forward Vector of the current rotation of an object, and I compared it to the Forward Vector that the same object would have if it would be looking directly toward me. It works like a normal "LookAt" feature, but I can use it to set the speed of the rotations, so I can have custom speeds for my vehicles! I would be unhappy if all vehicles rotate at the same speed! Imagine if a tank could rotate as fast as a person! Forward Vectors also allow me to decide which part of each object is the front!

Sinful fact that will cause your limbs to shiver:
I looked through the C++ source code of the client of CopperCube 5.7.1, but I didn't discover how to insert my own code into it. For example, CopperLicht has a file called "example.html" that shows an idea of how my main script will function, but I didn't notice a sample template in the C++ source. I searched all files for terms like "main script", and I found a few mentions of it, but I didn't notice how to insert one.

You may say "Only the toughest men can wield the power of C++", and that is definitely true, but I was quite curious to discover the extent of my inferiority, and imagine how I shivered when I learned that I could not simply uncover the method of starting a main script.

I want to be a master. I want to become one hundred percent perfect.

It eludes me.

It still eludes me.

My mind will be frozen, until the end of time.

Edit:
I don't want to practice C++ now, so don't worry, Ambiera, I won't bother you with questions about it. I just wanted to mention my foolish quick glance at the code. Almost one year ago, I imported it into Visual Studio Community 2017, and I wasted at least one week to fix all of the compilation errors, and I probably didn't fix them correctly. I don't want to do that process again right now. I would rather gain a firm grasp of JavaScript first. When I feel like I have become a professional of JavaScript, I will initiate a sincere venture into the realm of C++.



"I was once a professional programmer, but I lost my power, because I became rich, and didn't need to improve."
~ Billiard Gates


wild-master
Registered User
Quote
2018-05-31 16:07:01

Deep in the night, a whisper could be heard.

Nikolaus awoke. He heard a noise, but he couldn't hear what it was.

He walked toward his window, still unable to hear what the voice was saying.

He opened the window, quite curious about what was being said, and what he heard next was a shock to his system.



"I created a perfect 'LookAt' behavior in CopperLicht, unafflicted by flips at points 90 and 270."



Nikolaus' body jolted.

The voice he heard was the most sinister of voices.

A deep voice, ruthlessly deep; viciously deep, sinful like a demon.

The words filled his mind: "I created a perfect"

He could hear it: "I created a perfect"

He could feeeeeel it in his bones: "A perfect 'LookAt' behavior."

He felt the words. He felt them so strongly that he lost focus of his dark room. As he walked, he misstepped. He placed a foot in a bad position, shifting his body backward so fast that he crushed his head into a strong wall, developing a concussion that infuriated him, so he attempted to punch a wall, but he missed, and his body flipped backward down steps, steps he built for his family when they asked for a second floor, steps he built with cedar and pine.

As he fell, he could feel them.

He could feel the words, in his blood and his veins.

"Unaffected by flips."

"Unaffected by flips."

"Unaffected by flips at points 90 and 270."

The words petrified him; he lost his desires, not even attempting to stop his fall.

The voice was deep, so deep; mercilessly deep, deep like a heathen.

"90 and 270."

"90 and 270."

"I created a perfect"

"A perfect 'LookAt' behavior."

Nikolaus lied in bed now, unable to sleep. His mind developed such a trauma that it damaged his ability to think and feel. He didn't know if he would live, he lost all of his zeal, lost all of his desires, didn't know if he'd heal. He knew he'd need a fortune to repair the damage he just unleashed on his home, a cottage he built for vacations in Rome.

Nikolaus was quite impressed by the deep voice of the whisperer outside of his window; quite jealous, in fact. But, as he screeched to the air, waking his children and wife, he realized that he has a deep voice of his own, quite impressed by the sounds and power of his words:

"THE MONKEY FINALLY CREATED A PERFECT 'LOOKAT' BEHAVIOR. I DIDN'T KNOW A SIMIAN COULD ACHIEVE SUCH A GOAL. I DESPISE HIM. HE DESERVES TO LIVE IN A TOMB. I WOULD LOVE TO INFLICT AND WITNESS HIS DOOM."


just_in_case
Moderator
Quote
2018-06-01 16:03:47

Hahahahahahahahahahahahahahhaahahhaahha ..... What is the name of your Novel???


hgi
Registered User
Quote
2018-06-02 00:45:55

That is so dope! Good work


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact