I've been working on a 3D image made with CSS, the idea was to add some kind of animation to it and use it as a center piece in my portfolio, unfortunately I've been having trouble getting the animation to look smooth.
I am unsure if this is caused by a limit of CSS animation or by the fact that I am working in 3D, but I have not been able to get it to look quite right.
So far I've tried a lot of different values as well as adding more keyframes in the hopes the animation would smooth itself out but I have not had any luck.
I have a Codepen with all of the code, it can be found here.
I placed said keyframe animation at the top of the CSS file, it is named loading-cube
Unless I have been staring at this for too long and my eyes are playing tricks on me, the animation as it is currently has a "bounce".
This Codepen is a more accurate representation of how I would like my rotation to look like.
Your order of the 2 different rotations is wrong, you should set the rotateX before the rotateY. If you do so, the animation is much more easy, just a 360 deg turn on the Y axis:
#keyframes loading-cube {
0% {transform: translateZ(-800px) rotateX(-19deg) rotateY(0deg);}
100% {transform: translateZ(-800px) rotateX(-19deg) rotateY(360deg);}
}
edited demo
Related
I currently have an ray-tracer that can read .obj models and then render the objects described on them. Until now, I was basically working with .obj models where the vertices where around the origin, generally closer than 10 of distance, at maximum being around 100.
Now, I downloaded a different model, where the vertices are far away from the origin, Always at least at hundreds of units from the origin, some vertices being about 5000 away in some axis.
The problem is that now I cannot focus the entire car!
One of my tests was with the distance from camera to origin of -3639.
And the result was this:
Then I step the camera away at -4639 and what was produced was this:
Changing my approach, decided to approach it, placing the camera at -2639
The result:
So at -2639 a I am being able to visualize the entire car but it does not fit in my field of view. At -3669 the light is already fading away by some reason.
I imagine that might be possible to see the full car proper lightened using a intermediate distance between -2669 and -3669 and also experimenting with the filed of view value, but there is something odd about the Light not covering the entire car at -3669 and I would like to find out the reason.
So I would appreciate suggestions about the cause of this issue and how to proceed in this kind of situation, how to focus the entire car.
Your question mentions you are changing the camera position. However, the images show the lighting area changing between the various cases. Just a spotlight in one case, and more of the car being lit in the other.
Most likely, in the third case, nothing of the car is lit, hence everything comes up black. Start by fixing the light staying the same when the camera moves, and see if it fixes your issue.
If you move the camera: It could help looking into the settings for the front and back clipping planes.
If you don't move the camera: The FOV show be larger if the object is larger. I would avoid doing this as this likely will lead to more problems when you read more than one object that are different.
Personally I would scale the input from the file. Ideally to some SI-unit that makes sense.
I am currently working on my game-engine and I run into some troubles I can not figure out myself. I changed my mind about setting up my own math library so I went back to use GLM because it is a perfect solution.
But here comes the problem, with my Code everything worked well but now with the functions changed I get a problem with object clipping and intersection.
Zoomed In
This first image shows how my scene looks when it is zoomed in. Everything looks almost perfect and the plane intersects the cube properly.
Zoomed Out
Scrolling out the intersection gets randomly dissorted and I cannot explain what's happening nor do I have any clue where my problem is located.
This is the way I calculate my projection Matrix:
proj = glm::perspective((double)fovy, (double)aspect, (double)nearPlane,(double) farPlane);
and this is the way I calculate the view:
view = glm::lookAt(pos, tar, gameObject->transform.getUp());
I know I should poste more code but there is so much that I really don't know where to start. So please tell me which code could be of importance and I poste it. Thank you very much in advance and I hope somebody could help me. If more pictures are needed please tell me.
It looks like you don't have enough depth resolution. This happens when nearPlane is very small and farPlane is very large. For example, 0.0001 to 10000.0 will give you low depth resolution.
Make nearPlane larger and farPlane smaller.
Skewing x and y coordinates doesn't give that kind of effect. Any ideas on how to achieve this kind of effect? I already use cccamera but there are no examples on how to properly implement this. This image btw is from cocos2dx tried the c++ code still didn't work
I feel I need to share this once and for all. So this is how camera works when you want a slanting ,45degree or pseudo3d view of your background :
First set your director to 3d perspective
[director_ setProjection:kCCDirectorProjection3D];
If you only want some of the sprites to appear this way then remember this
all nodes have camera (cocos2d v.3 doesn't seem to have it anymore I don't know why)
so you do this:
[mysprite.camera setEyeX:0 eyeY:-40 eyeZ:10];
[mysprite.camera setUpX:0 upY:0 upZ:1];
Play with the values that fits your need. Hope it will help others!
I'm trying to make anaglyps to show antenna diagrams for my students. I used one of the classic techniques by using glAccum: Draw left eye, 'load' into the accumulator, draw right eye, and Accumulate, the bring the Accu back in front. (Note that I know this does not produce a perfect anaglyph. After all I'm not even using perspective projection - I use glOrtho (maybe that is the problem?). I am just concerned why glAccum isn't working as expected)
This seems to work, but only partly.
The image shows an axis system in 3D, which shows that the generation actually works, but at the left, RED incorrectly overwrites CYAN while at the right, CYAN actually mixes with RED producing white, as it should do. Maybe the following images are clearer:
The left image show expected color addition while the right image shows red overwriting cyan.
Can anyone shed some light on this? The actual plot is more complicated of course.
BTW, I know of the other methods to generate anaglyphs...
Well, #Bahbar's idea pointed me into the right direction. Though I have actually seen various pages with examples where it's not done, I suspected that clearing the depth buffer could have an effect on the graph. So I added
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
in between rendering both views, and the problem was solved!
Looking around more on the 'net, I actually found examples where it is done that way. I'm happy - I even added the correct, frustum-based stereo perspective. The result is:
Thanks for the attention, maybe this can help someone else...
Question on how this could be done, if possible.
I have sprites in each of the following directions (up, down, left, right, upright, upleft, downright, and downleft). I am making a similar game to the old school zelda, running around a tile map (using tiled editor). This is working well, until now, I want to be able to shoot arrows/spells at any location on the map. I can do so, but the graphics look horrible because my guy will only turn each 45 degrees.
I have corrected this so I can only shoot in the direction my guy is facing, but now I can't hit them if they are not at a 45 degree angle from me. To fix this, I need to have a sprite at every 1 degree, or somehow combine the images say at 0 degrees (up) and 45 degrees (upright) to be able to get say 10 degrees via interpolation. Is this possible? Any ideas on how to do this?
I am looking into working with key animations since I wouldn't have to have so many sprites and use much less video memory (and smoother animations), but I still run into this same problem. Would like to know if this is conceptually possible and if so, a little psuedo code or snipit would be much appreciated.
One other question, if this is possible, do I need to be rendering this via openGL in 3D? Didn't really know if 3d would help in a 2d (orthogonal tile) game, but it might help spells falling look like they are falling downward more than moving across tiles from above to below?