示例#1
0
//}}}1
//{{{1 private functions
void Scene::buildScene(Json::Value node) {
    Json::Value cam = node["camera"];
    buildCamera(cam);

    Json::Value lights = node["lights"];
    for(int i=0; i<lights.size(); i++) {
        buildLight(lights[i]);
    }

    Json::Value models = node["models"];
    for(int i=0; i<models.size(); i++) {
        buildNode(models[i]);
    }

    if(node.isMember("instances")) {
        Json::Value instances = node["instances"];
        for(int i=0; i<instances.size(); i++) {
            buildInstance(instances[i]);
        }
    }

    Json::Value anims = node["animations"];
    for(int i=0; i<anims.size(); i++) {
        buildAnimation(anims[i]);
    }

    mat4 wm = LookAt(eye, at, up);
    setWorldMatrix(LookAt(eye, at, up));
    printf("set init world matrix\n");
}
示例#2
0
/*
================
idCameraDef::getActiveSegmentInfo
================
*/
void idCameraDef::getActiveSegmentInfo(int segment, idVec3 &origin, idVec3 &direction, float *fov) {
#if 0
	if (!cameraSpline.validTime()) {
		buildCamera();
	}
	double d = (double)segment / numSegments();
	getCameraInfo(d * totalTime * 1000, origin, direction, fov);
#endif
/*
	if (!cameraSpline.validTime()) {
		buildCamera();
	}
	origin = *cameraSpline.getSegmentPoint(segment);
	

	idVec3 temp;

	int numTargets = getTargetSpline()->controlPoints.Num();
	int count = cameraSpline.splineTime.Num();
	if (numTargets == 0) {
		// follow the path
		if (cameraSpline.getActiveSegment() < count - 1) {
			temp = *cameraSpline.splinePoints[cameraSpline.getActiveSegment()+1];
		}
	} else if (numTargets == 1) {
		temp = *getTargetSpline()->controlPoints[0];
	} else {
		temp = *getTargetSpline()->getSegmentPoint(segment);
	}

	temp -= origin;
	temp.Normalize();
	direction = temp;
*/
}
示例#3
0
void idCameraDef::startCamera(long t) {
	buildCamera();
	cameraPosition->start(t);
	//for (int i = 0; i < targetPositions.Num(); i++) {
	//	targetPositions[i]->
	//}
	startTime = t;
	cameraRunning = true;
}
示例#4
0
void idCameraDef::startCamera(long t) {
	cameraPosition->clearVelocities();
	cameraPosition->start(t);
	buildCamera();
	fov.reset(90, 90, t, 0);
	//for (int i = 0; i < targetPositions.Num(); i++) {
	//	targetPositions[i]->
	//}
	startTime = t;
	cameraRunning = true;
}
示例#5
0
void Picture::render(int w, int h )
{
//while(true){
    // Get BasicObjects
    BasicObject* obj = new BasicObject( OBJ_FILE );

    Vertex* eye = new Vertex( 0,0,0 );
    Vertex* at = new Vertex(0,0,0);
    Matrix* camera = buildCamera( CMRA_FILE, eye, at );

    // Scene creation
    Scene* scene = new Scene();

    // Set up lighting
    double shading[8];
    getShadingInfo( SHADE_FILE, shading );

    Light* light = new Light();
    Vertex* light_loc = new Vertex( shading[0], shading[1], shading[2] );
    Color* light_clr = new Color( LGHT_CLR );

    light->setLocation( light_loc );
    light->setColor( light_clr );

    Color* amb = new Color( AMB_CLR );

    // Add objects to the scene.
    InstanceObject* sp = buildInstanceObject( TRS_FILE, obj );
    sp->setShininess( shading[7] );

    scene->addNode( sp );

    scene->render( w, h, light, eye, at, amb );

    delete eye;
    delete at;
    delete amb;
    delete light;
    delete scene;
//}
}
示例#6
0
/*
================
idCameraDef::addEvent
================
*/
void idCameraDef::addEvent(idCameraEvent::eventType t, const char *param, long time) {
	addEvent(new idCameraEvent(t, param, time));
	buildCamera();
}
示例#7
0
void idCameraDef::removeEvent(int index) {
	events.RemoveIndex(index);
	buildCamera();
}
示例#8
0
void Picture::render(Pixel* pix)
{
//while(true){
    // Get BasicObjects
    BasicObject* obj = readObject( OBJ_FILE );

    double z[3];
    getZValues( FOV_FILE, z );

    //WNACI
    Matrix* wnd = AffineTransforms::windowingTransform(pix->getWidth(),
        pix->getHeight());
    Matrix* aspct = AffineTransforms::aspectRatio(pix->getWidth(),
        pix->getHeight(), z[0]);    // Matrix for aspect ratio.

    Vertex* eye = new Vertex( 0,0,0 );
    Matrix* camera = buildCamera( CMRA_FILE, eye );
    Matrix* normal = AffineTransforms::perspective( z[1], z[2] );

    Matrix* tmp = aspct->multiply(camera);
    delete camera;
    delete aspct;

    Matrix* tmp2 = normal->multiply( tmp );
    delete tmp;
    delete normal;

    Matrix* wnca = wnd->multiply(tmp2);
    delete tmp2;
    delete wnd;
    // END WNACI

    // Scene creation
    Scene* scene = new Scene(wnca);

    // Set up lighting
    double shading[8];
    getShadingInfo( SHADE_FILE, shading );

    Light* light = new Light();
    Vertex* light_loc = new Vertex( shading[0], shading[1], shading[2] );
    Color* light_clr = new Color( LGHT_CLR );
    
    light->setLocation( light_loc );
    light->setColor( light_clr );
    
    Color* amb = new Color( AMB_CLR );
    
    // Add objects to the scene.
    InstanceObject* sp = buildInstanceObject( TRS_FILE, obj );
    sp->setShininess( shading[7] );

    scene->addNode( sp );

    scene->render( pix, light, eye, amb, shading[6] );

    delete eye;
    delete amb;
    delete light;
    delete scene;
//}
}