updating camera helper projection matrix (three.js) - camera

I'm switching a camera between two exported dummies from 3dsmax by setting it to use their matrixWorld properties.
camera_foreground.matrixWorld = (dummy_shot1.matrixWorld);
camera_foreground.updateProjectionMatrix();
This works great but the camera_helper that I've created doesn't inherit the matrix changes.
It doesn't allow me to run updateProjectionMatrix() on the helper itself. I've tried parenting the helper to the original camera. I've also tried to set the helper.matrixWorld to the same dummy_shot1.matrixWorld. What would be the best way to get the helper to update along with the camera it's created for/from?

You can update the frustum of a camera helper with THREE.CameraHelper.update().
Given two cameras: camera1 and camera2, you can switch the CameraHelper transformation from camera1 to camera2 like this :
cameraHelper.camera = camera2;
cameraHelper.matrix = camera2.matrixWorld;
cameraHelper.update();
Note
Another solution that seems more convenient for you, would be to create one THREE.CameraHelper for each camera and switch the currently displayed helper with :
camera1.helper.visible = false;
camera2.helper.visible = true;
In addition, THREE.Layers can also be used to control the currently displayed helper.

3dsmax cameras/camera animation aren't supported by the 3dsmax collada exporter. To get around this I was exporting dummies (from max to threejs) that had been parented to said cameras. I had worried that the dummies would come through without their animation (since the parents (3dsmax cameras) are ignored).
The dummies were coming through fine (I'd thought) since camera location/rotation worked fine when copying matrixes to three.js cameras. The problem arose when trying to get the helpers to do the same (apparent when viewing the scene via a debug camera).
It seems camera_helper objects in three.js don't play nicely with the matrix of these particular dummies (probably because in 3dsmax they are inherting from a parent). What's strange is that the cameras (as mentioned above) work fine.
To get around the issue I used a great maxscript (http://www.breidt.net/scripts/mb_collapse.mcr) to copy/bake all the parent keyframe data from the 3dsmax camera to it's dummy (no longer inheriting). The collada friendly dummy was then exported to three.js where both the camera and it's helper work great with.
Thanks Neeh for help and questions. It was rebuilding a test scene to upload that I noticed the new dummies (not parented to cameras) worked fine with helpers.

Related

Unreal Engine 5.1 Retargeted Animation From Manny to Mixamo Model Causes Single Animation Sequence To Rotate 90*

I apologize if this has been asked before. I tried searching for this first and nothing is coming up. I'm pretty new to Unreal Engine 5.1 so this might be something I'm doing as well.
I've been exploring animation retargeting in unreal and have tried following the steps we learned in class using one of the models from mixamo.com. Everything appears to work fine at the start and I can get the actual IK and IKR objects working just fine. However when I try to export the animations either from the IKR object or by right clicking the ABP object for the source mesh one and only one of the animation sequences rotates 90*. It is always the same animation (the Land animation sequence) and I'm not sure how to go about fixing it.
Also tried looking on google and turned up nothing.
I'm hoping this is some stupid newb mistake that is easy to fix or maybe there's something I'm overlooking. Any help is greatly appreciated and I will continue trying to fix the problem myself as well and will post if I fix it
Tried retargeting using the following steps
Create an IK_Object for the model you wish to project your animations on with chains for each. Mine looked like the following
IK_Remy
Repeat step 1 for the model you wish to source animations from. Mine looked like the following
IK_Manny
Create an IKR_Object Linking the two together, here's what mine looked like
IKR_Remy
Find the ABP for your source model, right click, and select "Retarget Animation Assets->Duplicate and Retarget Animation Assets". Here's what I'm selecting for that
Retarget Dialog
When I do the following most of the animation sequences for "Manny" export just fine. However the "Land" animation flips for some reason (see image below)
Exported Animation Images
Even stranger, when I preview the MM_Land animation in my IKR object it looks fine i.e. not rotated. However, if I try to export the animation from the IKR object the same thing happens i.e. it rotates 90*. I would expect this to be a case of WYSIWYG where if it's working in the preview it would export correctly. However that apparently is not the case
Also I tried modifying the animation sequence manually but it won't let me. If I try to rotate the model in the animation sequence and save it, once I close the sequence it's re-rotated and the changes do not persist.
I can export the sequence as a new sequence, modify it, and save it, and then rename it as my exported "Land" animation to hard force it and it at least looks normal. However when I actually play the game and jump, when the land animation it still flips sideways and in addition causes the character to scale and warp for a second which makes me think there's something going on here that I don't know enough to fix. Really hoping someone with more experience in Unreal Engine can help.
EDIT: Fixed Image Descriptions
I can confirm that this is an issue - I'm seeing the same behaviour. I haven't managed to fix it yet, but my suspicion is that it's due to scaling - in my instance, I have had to scale up my custom character by around 2.5 times to replicate the scale of the default mannequin. Did you scale your custom character at all?

Render don't start in blender while using Cycles

I just appended two blender files to get my two models in one scene. when I hit Render Image. It doesn't start rendering although before appending the two files the render was working properly. I tried to render the default scene(Cube scene) in blender and it rendered. I guess the problem is not with my camera because I created a new camera and made it my active camera and still not working. all the objects appear in the viewport shading and none of them are hidden.
one more thing the GPU compute option is no longer active besides it was active before and worked with me.
I just figured out the problem. the sequencer in the output properties was checked on. to check it off go to Output Properties > Post Processing > Sequencer.
I'd just like to add my solution which bugged my mind an hour ago:
Blender has two options for rendering, which confused me at first, and might confuse others as well.
Render -> View Render will view the previous rendered image. However, if you've just opened Blender, then there's no previously rendered image of your viewport.
In order to render the viewport, you'll have to tap Render -> Render Image first. Then at a later stage you can do Render -> View Render to view that image.
I guess the same works for animations as well, first you'll need to do Render -> Render Animation to render your animation, then later do Render -> View Animation.
Encountered the same problem. Disabling the sequencer, as OP mentioned, didn't do anything. For me the problem was in the output path for animation; in Output Properties > Output.
My destination folder was moved (it was a very old project) and Blender seems to have no problem with rendering images to a folder that does not exist. However this is not the case with animation. I imagine that when rendering animation, blender uses the target folder to store rendered frames and when everything is rendered, takes the frames and makes the animation.
I do not have any insight into how blender works nor do I have experience with programming so take this as an uneducated guess.
;TLDR:
Check your destination folder, blender seems to be fine with rendering images to non existent folders. This is not the case with animations.

Usings Verold's 3ds max exporter - animation not working

If I export the max project as an .FBX it will work (HERE - the pedal depresses ok), but then I loose turbo smooth (wheel alloys) and line objects (cables) disappear (why is that btw?). Using the Verold exporter, the animation asset appears in the 'key frame animation' tab in the 'choose asset' section, but when applied it never actually animates. And yet, if I animate a simple box next to the pedal, that works (HERE).
Partial solution: It seems the problem for Verold was that the pedal's parts were grouped, it works if they are attached instead. –
To clarify, it sounds like there are three issues:
Your TurboSmooth modifier is not being applied when exporting to FBX
Your line objects are not rendering
Your animation is not playing correctly, when exported by Verold Publisher
To apply TurboSmooth when exporting to FBX, please see the following:
http://answers.unity3d.com/questions/23085/3ds-max-fbx-turbosmooth-export.html
Note that line objects are not currently supported in Verold Studio, so they will not render.
Regarding animation, when I look at your first example, I see an animated pedal. In your second example, I see an animated box. Should there be additional animated objects in either example?

UI on Android Game - What are my options?

First of all let me give a bit of context to make the question more precise:
I am developing an Android game (using SurfaceView, Canvas, etc), and it is working perfectly for the gameplay part. I initially tried to use View-derived elements on top of it for menus and other UI elements, and rapidly realized by experimentation and looking at some questions here on Stackoverflow that this was a really bad idea, since they dont mix well (say a LinearLayout on top of a SurfaceView).
I see 3 possible paths:
A) Continue using View elements on top of SurfaceView (and deal with the problems with it, such as horrendous lag)
B) Draw UI elements manually on SurfaceView/Canvas. Something like: canvas.drawBitmap(menuBitmap, posX, posY, ...); and then handle the touches manually, and suffer with screen fragmentation
C) Use a library/framework designed specifically for this that handles all the drawing of UI, touch on buttons, drag to scroll, etc. Something like the View and its derived elements, but designed for games and apps that draw using SurfaceView.
Are there more options that Im not seeing? And "C" seems the best to me, but is there a library for that? Which one?
Edit: forgot to ask the most obvious question, also: How does other professional/commercial games deal with this?
Thanks
I really don't like these game engines (AndEngine, Corona, Unity3D, cocos2d, etc). I want to learn Android, which will be more useful for my professional life than engine X or Y.
All my games were created without game engines. I use option (A) for almost everything and I don't see any lag or sluggishness.
Examples:
The game screen for Minesweeper 3D is a set of layouts and views plus a SurfaceView to hold the OpenGL 3D field.
The game screen for Box Topple is also a set of layouts and views together with a custom view created to handle and display the box2d physics engine.
See my other games as well...
I had these same exact issues.
Then I found a free game engine called AndEngine.
This engine handles just about everything you need.
For example:
OpenGL wrapper classes for simple, efficient drawing
Sprite classes (animated or not)
Particle effects
Cameras to view different parts of the scene you draw on
Scrolling backgrounds
Online multiplayer and Box2D physics engine extensions
etc.
And for your case:
It has a HUD that you attach to a camera, which stays static as the camera moves.
You can then attach buttons (already built-in, with click events) to this.
Here is some example code to create a button:
moveRightButton = new ButtonSprite(10, 10, moveRightButtonTexture, getVertexBufferObjectManager()) {
#Override
public boolean onAreaTouched(TouchEvent event, float x, float y) {
if (event.isActionDown()) {
player.moveRight();
// Set to 'clicked' image
this.setCurrentTileIndex(1);
}
else if (event.isActionUp()) {
// Set to 'unclicked' image
this.setCurrentTileIndex(0);
}
return super.onAreaTouched(event, x, y);
};
};
You can find the engine and its extensions at https://github.com/nicolasgramlich?tab=repositories.
The main problem with the engine is that there is no documentation.
However, there is a forum dedicated to the engine at http://www.andengine.org/forums/.
Also, you can download AndEngine Examples (via the same repository I mentioned above), created by the developer to give examples of usages of various aspects of the engine.
It takes a bit to get used to, but it has been very rewarding.

Sensor Orientiation -> GLRotation doesn't work properly

I want to use the Android orientation sensor data for my GLES camera - giving it the rotation matrix. I found a very good example here:
How to use onSensorChanged sensor data in combination with OpenGL
but this is only working with GL1.0 and I need to work on it for GLES2.0. Using my own shaders, everything works, moving the camera manuall is fine. But the moment I use the rotation matrix like in the example, it doesn't really work.
I generate the rotation matrix with:
SensorManager.getRotationMatrix(rotationMatrix, null, bufferedAccelGData, bufferedMagnetData);
My application is running in LANDSCAPe so I use that methode after (like in the example code):
float[] result = new float[16];
SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, result);
return result;
It worked fine on my phone in his code but not in mine. My screen looks like that:
The rotation matrix seems to be rotated 90° to the right (almost as if I have forgotten to switch to landscape for my activity).
I was thinking of using the remap() method in a wrong way but in the example it makes sense, the camera movement works now. If I rotate to the left, the screen rotates to the left as well, even though, since everything is turned, it rotates "up" (compared to the ground, which is not on the bottom but on the right). It just looks like I made a wall instead of a ground but I'm sure my coordinates are right for the vertices.
I took a look ath the draw method for the GLSurface and I don't see what I might have done wrong here:
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
MatrixStack.glLoadMatrix(sensorManager.getRotationMatrix()); // Schreibt die MVMatrix mit der ogn. Rotationsmatrix
GameRenderer.setPerspMatrix(); // Schreibt die Perspektivmatrix Uniform für GLES. Daran sollte es nicht liegen.
MatrixStack.mvPushMatrix();
drawGround();
MatrixStack.mvPopMatrix();
As I said, when moving my camera manually everything works perfect. So what is wrong with the rotation matrix I get?
Well, okay, it was a very old problem but now that I took a look at the code again I found the solution.
Having the phone in landscape I had to remap the axis using
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, R);
But that still didn't rotate the image - even though the mapping of the Y and -X Axis worked fine. So simply using
Matrix.rotateM(R, 0, 90, 1, 0, 0);
Does the job. Not really nicely but it works.
I know it was a very old question and I don't see why I made this mistake but perhaps anyone else has the same problem one day.
Hope this helps,
Tobias
If it is (was) working on a specific phone but not on yours, I guess the android version may play a role here. We faced the issue in mixare Augmented Reality Engine where a Surfaceview is superimposed over a Camera view. Pleas consider that the information here may not apply to your case since we are not using OpenGL.
Modern version of android will return a default orientation, whereas previously portrait was the default. You can check how we query this in the Compatibility class. This information is then used to apply different values to the RemapCoordinateSystem call check lines 739 and onwards of this file.
Mixare is as well using landscape mode by default, so I guess our values for the remapping should apply to your case just as well. As I said earlier, we are using the 3x3 matrices, since we are not using OpenGL, but I guess this should be the same for OpenGL compatible matrices.
Take time, play with the orientation matrix, you will find a column that contains useful vaule.
Besides Log vales for each column, see which one is useful, try quaternions, keep playing with values never try the code directly in renderer, first check the values
Because later, you will have more options for input like touch, there too you have to test the values, play with them, use sensitivity constants with matrices too