Hi Bill,
Thank you for the reply. If i understood correctly,
I) you are suggesting me to use 'house front view and every rooms inside' separately in models (pod) and load the rooms thru code whenever navigation (move one room to another) is happening? Could you show any example for dynamically loading each pod models when user action is happening (may be a button click)?
II) And, you have mentioned that if i want closer 3d picture in the app, i can move the camera closer to the object in blender and export the models. I created a Cone which is bigger in height, and very close to camera and export it as pod file and using it in my project to show at launch. But it still shows the Cone image very smaller in the app. Here is my code below. Could you please correct this as well, what i'm doing wrong here?
AppDelegate:
-(void) applicationDidFinishLaunching: (UIApplication*) application {
// Establish the type of CCDirector to use.
// Try to use CADisplayLink director and if it fails (SDK < 3.1) use the default director.
// This must be the first thing we do and must be done before establishing view controller.
if( ! [CCDirector setDirectorType: kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType: kCCDirectorTypeDefault];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images.
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565. You can change anytime.
CCTexture2D.defaultAlphaPixelFormat = kCCTexture2DPixelFormat_RGBA8888;
// Create the view controller for the 3D view.
viewController = [CC3DeviceCameraOverlayUIViewController new];
viewController.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;
// Create the CCDirector, set the frame rate, and attach the view.
CCDirector *director = CCDirector.sharedDirector;
//director.runLoopCommon = YES; // Improves display link integration with UIKit
director.animationInterval = (1.0f / kAnimationFrameRate);
director.displayFPS = YES;
director.openGLView = viewController.view;
// Enables High Res mode on Retina Displays and maintains low res on all other devices
// This must be done after the GL view is assigned to the director!
[director enableRetinaDisplay: YES];
// Create the window, make the controller (and its view) the root of the window, and present the window
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
[window addSubview: viewController.view];
window.rootViewController = viewController;
[window makeKeyAndVisible];
// Set to YES for Augmented Reality 3D overlay on device camera.
// This must be done after the window is made visible!
// viewController.isOverlayingDeviceCamera = YES;
// ******** START OF COCOS3D SETUP CODE... ********
// Create the customized CC3Layer that supports 3D rendering and schedule it for automatic updates.
CC3Layer* cc3Layer = viewController.isOverlayingDeviceCamera
? [HomeOwners3DLayer node]
: [HomeOwners3DLayer layerWithColor: ccc4(100, 120, 220, 255)];
//cc3Layer.position = ccp(0.0, 0.0);
[cc3Layer scheduleUpdate];
// Create the customized 3D scene and attach it to the layer.
// Could also just create this inside the customer layer.
cc3Layer.cc3Scene = [HomeOwners3DScene scene];
// Assign to a generic variable so we can uncomment options below to play with the capabilities
CC3ControllableLayer* mainLayer = cc3Layer;
// Attach the layer to the controller and run a scene with it.
[viewController runSceneOnNode: mainLayer];
}
xxxxxScene.m file:
-(void) initializeScene {
[self initCustomState];
// Create the camera, place it back a bit, and add it to the scene
CC3Camera* cam = [CC3Camera nodeWithName: @"Camera"];
cam.location = cc3v( 100.0, 50.0, 1000.0 ); // Pra: z - will go back and show the house front view properly, more than 1100 or less than 900 is not showing properly
[self addChild: cam];
// Create a light, place it back and to the left at a specific
// position (not just directional lighting), and add it to the scene
CC3Light* lamp = [CC3Light nodeWithName: @"Lamp"];
lamp.location = cc3v( -2.0, 100.0, 100.0 );
lamp.isDirectionalOnly = NO;
[cam addChild: lamp];
[self addGround];
[self addRobot];
//[self addDieCube];
[self configureLighting]; // Set up the lighting
[self configureCamera]; // Check out some interesting camera options.
// Create OpenGL ES buffers for the vertex arrays to keep things fast and efficient,
// and to save memory, release the vertex data in main memory because it is now redundant.
[self retainVertexLocations];
[self retainVertexIndices];
[self retainVertexWeights];
[self retainVertexMatrixIndices];
[self createGLBuffers];
[self releaseRedundantData];
}
-(void) addRobot {
// We introduce a specialized resource subclass, not because it is needed in general,
// but because the original PVR demo app ignores some data in the POD file. To replicate
// the PVR demo faithfully, we must do the same, by tweaking the loader to act accordingly
// by creating a specialized subclass.
CC3PODResourceNode* podRezNode = [CC3PODResourceNode nodeWithName: @"RobotPODRez"];
podRezNode.resource = [IntroducingPODResource resourceFromFile: @"Cone.pod"];
podRezNode.location = cc3v(100.0, -90.0, 500.0);
podRezNode.isTouchEnabled = YES;
[self addChild: podRezNode];
}
-(void) configureCamera {
CC3Camera* cam = self.activeCamera;
// Camera starts out embedded in the scene.
cameraZoomType = kCameraZoomNone;
// The camera comes from the POD file and is actually animated.
// Stop the camera from being animated so the user can control it via the user interface.
[cam disableAnimation];
// Keep track of which object the camera is pointing at
origCamTarget = cam.target;
camTarget = origCamTarget;
// For cameras, the scale property determines camera zooming, and the effective field-of-view.
// You can adjust this value to play with camera zooming. Conversely, if you find that objects
// in the periphery of your view appear elongated, you can adjust the fieldOfView and/or
// uniformScale properties to reduce this "fish-eye" effect. See the notes of the CC3Camera
// fieldOfView property for more on this.
cam.uniformScale = 0.9;
}
/** Configure the lighting. */
-(void) configureLighting {
// Set the ambient scene lighting.
self.ambientLight = CCC4FMake(0.3, 0.3, 0.3, 1.0);
// Adjust the relative ambient and diffuse lighting of the main light to
// improve realisim, particularly on shadow effects.
podLight.diffuseColor = CCC4FMake(0.8, 0.8, 0.8, 1.0);
// Another mechansim for adjusting shadow intensities is shadowIntensityFactor.
// For better effect, set here to a value less than one to lighten the shadows
// cast by the main light.
podLight.shadowIntensityFactor = 0.75f;
// The light from the robot POD file is animated to move back and forth, changing
// the lighting of the scene as it moves. To turn this animation off, comment out
// the following line. This can be useful when reviewing shadowing.
// [podLight disableAnimation];
}
-(void) addGround {
ground = [CC3PlaneNode nodeWithName: @"Ground"];
[ground populateAsDiskWithRadius: 1000 andTessellation: ccg(8, 32)];
ground.texture = [CC3Texture textureFromFile: @"Grass.jpg"];
// To experiment with repeating textures, uncomment the following line
[ground repeatTexture: (ccTex2F){10, 10}]; // Grass
// [ground repeatTexture: (ccTex2F){3, 3}]; // MountainGrass
ground.location = cc3v(0.0, -100.0, 0.0);
ground.rotation = cc3v(-90.0, 180.0, 0.0);
ground.shouldCullBackFaces = NO; // Show the ground from below as well.
ground.isTouchEnabled = YES; // Allow the ground to be selected by touch events.
[ground retainVertexLocations]; // Retain location data in main memory, even when it
// is buffered to a GL VBO via releaseRedundantData,
// so that it may be accessed for further calculations
// when dropping objects on the ground.
[self addChild: ground];
}