Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Layer (CameraManager) #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matsuse
Copy link

@matsuse matsuse commented Feb 13, 2013

Add the controlling function of a camera to #57.
It can be treated like 3D layer. :)

Scissor rectangle is also supported.

[Example]
scene = new Object3D();
scene2 = new Object3D();

vw = new View(stage.stageWidth, stage.stageHeight, false, 0x000000, 0, 16);

camera1 = new Camera3D(1, 6000);
camera2 = new Camera3D(1, 6000);
camera3 = new Camera3D(1, 6000);

camera1.view = vw;
camera1.renderClearsContext = false;
camera1.renderPresentsContext = false;
camera1.scissorRect = new Rectangle(0, 0, 420, 480);

camera2.view = vw;
camera2.renderClearsContext = false;
camera2.renderPresentsContext = false;
camera2.scissorRect = new Rectangle(420, 0, 420, 480);

camera3.view = vw;
camera3.renderClearsContext = false;
camera3.renderPresentsContext = false;
camera3.scissorRect = new Rectangle(840, 0, 440, 480);

addChild(camera1.diagram);
camera1.diagramAlign = "TL";

addChild(camera2.diagram);
camera2.diagramAlign = "TR";

addChild(camera3.diagram);
camera3.diagramAlign = "BL";

scene.addChild(camera1);
scene2.addChild(camera2);
scene.addChild(camera3);

cm = new CameraManager(stage3D, vw);
cm.addCamera(camera1);
cm.addCamera(camera2);
cm.addCamera(camera3);

.
.
.

private function onEnterFrameHandler(ev:Event):void {
cm.clearScreen();
cm.renderLayers();
cm.drawScreen();
}

@makc
Copy link
Contributor

makc commented Feb 13, 2013

Hmm, you actually removed #57 here?

@matsuse
Copy link
Author

matsuse commented Feb 13, 2013

renderClearsContext and renderPresentsContext were deleted.
But, CameraManager is supporting the same function as #57.

@ChrisDenham
Copy link
Contributor

From a rough reading of your request, it looks as though it does not retain backward compatibilty because it will require everyone to use CameraManager class in order to present the context by calling CameraManager.drawScreen() ? Also, doesn't look like you retained a mechanism to prevent Camera3D from clearing the context.

@matsuse
Copy link
Author

matsuse commented Feb 13, 2013

For the following reason, I proposed this method.

  1. Same technique (clear -> All layer render -> present) is used by Away3D + Starling.
  2. Check "clear" and "present" each time's cost.

Of course, if there is a method of taking compatibility,
I will also think that it is ideal. :)

@makc
Copy link
Contributor

makc commented Feb 13, 2013

you could easily do so by duplicating camera class into ManagedCamera or something, but that obviusly sucks. do you know if extending the camera is possible, or it has too much private stuff?

@ChrisDenham
Copy link
Contributor

Could you retain compatibility by keeping the flags added in #57, but set them appropriately in your CameraManager class?

@matsuse
Copy link
Author

matsuse commented Feb 13, 2013

Thank you. I try solution of the following problem.

@makc
Copy link
Contributor

makc commented Feb 14, 2013

Seems so. So, could you post some short demo too?

@makc
Copy link
Contributor

makc commented Feb 14, 2013

Support extends Camera Class

actually what you mean by that? did you successfully extended their camera? e.g. for using scissors for multiple cameras view you need to be able to tweak projection, so that it's centered in scissor rectangle. I never tried myself, but I think someone said it was no feasible.

@matsuse
Copy link
Author

matsuse commented Feb 14, 2013

Before, it was only a Camera class which can be treated by CameraManager.
Now, the restriction does not exist.

The following screen shot is an example which uses scissor rectangle.
https://twitter.com/matsuse/status/291930767930585089/photo/1

I have not realized yet the function which rectifies distortion of scissor rectangle. ;(
However, If it can be deceived well, there will also be a case which can be used like the upper screen shot. :)

@matsuse
Copy link
Author

matsuse commented Feb 17, 2013

3D Layer Simple Example was added.
https://github.com/matsuse/Alternativa3D-3DLayer-Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants