Problems with d3d9 and NVAPI - directx-9

I'm writing a stereoscopic player.
All parts(decoding, rendering) except Stereoscopic mode are done. But with 3D I have some troubles. Im using NVAPI and D3D9. Render loop looks like that:
render()
{
begin_scene();
set_left_eye();
stretch_left_side_of_surface();
set_right_eye();
stretch_right_side_of_surface();
end_scene();
present();
}
It's just like described in whitepapers. But there is no stereo effect in result. Just right eye's picture. But glasses are working(so, they are controlled by the app). What am I doing wrong? Can someone explain me how to render stereo images using d3d9 and nvapi?

I noticed that each eye should be rendered in a different scene (i.e. wrapped with begin_scene() and end_scene()).
I'm not sure if it is necessary, but I think it is better to set active eye before each begin_scene() (and not during the scene).
As follows:
render()
{
set_left_eye();
begin_scene();
stretch_left_side_of_surface();
end_scene();
set_right_eye();
begin_scene();
stretch_right_side_of_surface();
end_scene();
present();
}

Related

smooth horizontal scroll - REACT THREE FIBER

I've been trying to make a small horizontal scroll with react three fiber so I can later add some WebGL Distorsion on the elements and even though i succeeded in the most basic way, there are still some things that need improvement :
(here is the codesandbox corresponding :https://codesandbox.io/s/horizontal-scroll-with-react-three-fiber-c0okfu?file=/src/Scene.js)
first and foremost I want a smooth scroll and can't seem to be able to make it, I used the lerp function to make it but the result doesn't work very well :
let scroll = 0;
scroll = (scroll - scrollTargetMapped) * 0.03;
// any other frame, groupRef.current is undefined, don't really know why
// but because of it, i must put my logic inside an if loop
if (groupRef.current) {
groupRef.current.position.x = THREE.MathUtils.lerp(
scroll,
-scrollTarget,
0.01
);
}
secondly, the elements on my scene are placed kind of in a random way and the scene is not at all responsive. I would love to mimic the html logic and put my first element like 50px away from the left side of the screen but not sure if it's really possible with react threejs :)
If someone has any answer to one of those question, I take it 🙂
Thanks in advance !
For those interested, I managed to find a solution, using one of drei components : ScrollControl, it works perfectly !
https://codesandbox.io/s/horizontal-scroll-with-react-three-fiber-c0okfu?file=/src/Scene.js
For more info on the said component, check out the doc : https://docs.pmnd.rs/drei/controls/scroll-controls

How to optimize the rendering on my threejs program

I've been working on a rubik's cube program, and the rendering works fine on my macbook pro/google chrome browser. For computers with slower GPUs, however, my cube breaks because the rendering is slower than the animations. I've tried looking up ways to optimize the rendering and haven't had any success yet.
Rubik's Cube live link
Github code repository
I'm using react and the componentDidMount function is line 1463 where the cube meshes get generated and the animate function is line 1539. Appreciate any help, thanks!
This all depends on how you're building your geometry. I ran a WebGL inspector on your live link, and I'm getting 182 drawcalls for a 3x3x3 cube. This is unnecessarily large, since a 3x3 should only have 54 faces. Each time you add a new Mesh to the scene, it creates a new drawcall on render, and having too many drawcalls is almost always the primary reason for slow performance in WebGL.
You should consider nesting each face into its corresponding "cubelet" (one black cube with 1, 2, or 3 colored faces), as done in this Roobik's demo. This way you'd only have to draw 27 cubes + 54 faces = 81 drawcalls! The pseudocode would go something like this:
for (let i = 0; i < 27; i++) {
let cubelet = new THREE.Mesh(geom, mat);
let face1 = new THREE.Mesh(geom, faceMat1);
let face2 = new THREE.Mesh(geom, faceMat2);
let face3 = new THREE.Mesh(geom, faceMat3);
cubelet.add(face1);
cubelet.add(face2);
cubelet.add(face3);
scene.add(cubelet);
}
Of course, you'd need to set the positions and rotations, to get a result like this:
Secondly, you're going to have to re-think the way your animate() function is set up. You're starting the next rotation after a set time has progressed, but instead you should start the next rotation only after the first one is complete. Have you considered using an animation library like GSAP?

Camera will not move in OpenGL

I am having problems with using a camera in OpenGL/freeGLUT. Here is my code:
http://pastebin.com/VCi3Bjq5
(For some reason, when I paste the code into the code feature on this site, it gives extremely weird output.)
As far as I can tell this should rotate the camera when arrow keys are pressed - but it does nothing. It also seems that even the initial camera position is wrong. Any clue why this is?
The display function is only called once. You need to either set an idle function with glutIdleFunc() or tell GLUT that the display function must be called again with glutPostRedisplay().

ios 6 MapKit annotation rotation

Our app has a rotating map view which aligns with the compass heading. We counter-rotate the annotations so that their callouts remain horizontal for reading. This works fine on iOS5 devices but is broken on iOS6 (problem seen with same binary as used on iOS5 device and with binary built with iOS6 SDK). The annotations initially rotate to the correct horizontal position and then a short time later revert to the un-corrected rotation. We cannot see any events that are causing this. This is the code snippet we are using in - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id )annotation
CATransform3D transformZ = CATransform3DIdentity;
transformZ = CATransform3DRotate(transformZ, _rotationZ, 0, 0, 1);
annotation.myView.layer.transform = transformZ;
Anyone else seen this and anyone got any suggestions on how to fix it on iOS6?
I had an identical problem so my workaround may work for you. I've also submitted a bug to Apple on it. For me, every time the map got panned by the user the Annotations would get "unrotated".
In my code I set the rotations using CGAffineTransformMakeRotation and I don't set it in viewForAnnotation but whenever the users location get's updated. So that is a bit different than you.
My workaround was to add an additional minor rotation at the bottom of my viewForAnnotation method.
if(is6orMore) {
[annView setTransform:CGAffineTransformMakeRotation(.001)]; //iOS6 BUG WORKAROUND !!!!!!!
}
So for you, I'm not sure if that works, since you are rotating differently and doing it in viewForAnnotation. But give it a try.
Took me forever to find and I just happened across this fix.

DropTarget ActionScript

i have 8 movie Clips that i stored in an array. i put the movie clips on the stage and i can move them around so everything work fine until now. I made a grid where the mc's can be droped.I saved the grid parts in an array,too.
after that gave names to the mc's and to the grid parts like that:
mc.name= number.toString();
gridpart.name= number.toString();
the movie clips and the grid parts have the same name like: mc1.name=1 and gridpart1.name=1 and so on.
Now I made an if statement to check if the right mc was droped on the right grid part, like that:
if(mc.name==gridpart.name)
{
trace("correct position")
}
But nothing happens. I used "dropTarget", too like that:
if(dropTarget.name==a.target.name)
{
//code
}
I don't know what to try now. I thought to put this code in the callback function of the mouse.CLICK event handler because i want that the mc should not be moved anymore if it is on hir correct position.
I would be happy if you have a better solution for this problem.
I tried to describe my problem so that you can imagine what I am trying to say.
Sorry about my English, I am not a native English speaker.
Thank you for your time
I think you wrong using dropTarget.name. Try dropTarget.parent.name. This why dropTarget is referred to content of the DisplayObject onto which you release your dragged MovieClip.
I hope this will be usefull to you!

Resources