コード例 #1
0
	Entity* SkyboxSystem::AddSkybox()
	{
		Entity* result = skyboxEntity;
		
		if(NULL == skyboxEntity)
		{
			SkyboxRenderObject* skyboxRenderObject = new SkyboxRenderObject();
			
			AABBox3 box = AABBox3(Vector3(-0.5f, -0.5f, -0.5f), Vector3(0.5f, 0.5f, 0.5f));
			skyboxRenderObject->Initialize(box); //first time initialization
			
			RenderComponent* renderComponent = new RenderComponent();
			renderComponent->SetRenderObject(skyboxRenderObject);
			
			
			result = new Entity();
			result->SetName("Skybox");

			result->RemoveComponent(Component::RENDER_COMPONENT);
			result->AddComponent(renderComponent);
			renderComponent->Release();

			GetScene()->AddNode(result);
			
			Matrix4 * worldTransformPointer = ((TransformComponent*)result->GetComponent(Component::TRANSFORM_COMPONENT))->GetWorldTransformPtr();
			skyboxRenderObject->SetWorldTransformPtr(worldTransformPointer);
			result->GetScene()->renderSystem->MarkForUpdate(skyboxRenderObject);
			SafeRelease(skyboxRenderObject);
			
			DVASSERT(skyboxEntity);
			result->Release();
		}
		
		return result;
	}
コード例 #2
0
void CreateNodesDialog::CreateNode(ResourceEditor::eNodeType nodeType)
{
    SafeRelease(sceneNode);

    SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
    EditorScene * editorScene = activeScene->GetScene();
	scene = editorScene;

    switch (nodeType) 
    {
        case ResourceEditor::NODE_LANDSCAPE:
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LANDSCAPE));
            sceneNode = new Entity();
            sceneNode->AddComponent(ScopedPtr<RenderComponent> (new RenderComponent(ScopedPtr<Landscape>(new Landscape()))));
            sceneNode->SetName(ResourceEditor::LANDSCAPE_NODE_NAME);
            break;

        case ResourceEditor::NODE_LIGHT:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LIGHT));
            
            //sceneNode = //EditorLightNode::CreateSceneAndEditorLight();
            sceneNode = new Entity();
            sceneNode->AddComponent(ScopedPtr<LightComponent> (new LightComponent(ScopedPtr<Light>(new Light))));
            sceneNode->SetName(ResourceEditor::LIGHT_NODE_NAME);
            break;
        }

        case ResourceEditor::NODE_SERVICE_NODE:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SERVICE));
            sceneNode = new Entity();
            KeyedArchive *customProperties = sceneNode->GetCustomProperties();
            customProperties->SetBool(ResourceEditor::EDITOR_IS_LOCKED, true);
            sceneNode->SetName(ResourceEditor::SERVICE_NODE_NAME);
            break;
        }

        case ResourceEditor::NODE_CAMERA:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_CAMERA));
            sceneNode = new Entity();
            
            Camera * camera = new Camera();
            camera->SetUp(Vector3(0.0f, 0.0f, 1.0f));
            sceneNode->AddComponent(ScopedPtr<CameraComponent> (new CameraComponent(camera)));
            sceneNode->SetName(ResourceEditor::CAMERA_NODE_NAME);
            SafeRelease(camera);
        }break;

		case ResourceEditor::NODE_IMPOSTER:
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_IMPOSTER));
			sceneNode = new ImposterNode();
			sceneNode->SetName(ResourceEditor::IMPOSTER_NODE_NAME);
			break;

		case ResourceEditor::NODE_PARTICLE_EMITTER:
		{
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_PARTICLE_EMITTER));
			sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::PARTICLE_EMITTER_NODE_NAME);

			ParticleEmitter3D* newEmitter = new ParticleEmitter3D();

			RenderComponent * renderComponent = new RenderComponent();
			renderComponent->SetRenderObject(newEmitter);
			sceneNode->AddComponent(renderComponent);
            
            newEmitter->Release();
			renderComponent->Release();

			break;
		}

		case ResourceEditor::NODE_USER_NODE:
        {
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_USER));
			sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::USER_NODE_NAME);
			sceneNode->AddComponent(ScopedPtr<UserComponent> (new UserComponent()));
			break;
        }

		case ResourceEditor::NODE_SWITCH_NODE:
		{
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SWITCH));
            sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::SWITCH_NODE_NAME);
            sceneNode->AddComponent(ScopedPtr<SwitchComponent> (new SwitchComponent()));
            
			KeyedArchive *customProperties = sceneNode->GetCustomProperties();
			customProperties->SetBool(Entity::SCENE_NODE_IS_SOLID_PROPERTY_NAME, false);
		}
			break;


		case ResourceEditor::NODE_PARTICLE_EFFECT:
		{
			SetHeader(ResourceEditor::CREATE_NODE_PARTICLE_EFFECT);

			sceneNode = new Entity();
			sceneNode->AddComponent(ScopedPtr<ParticleEffectComponent> (new ParticleEffectComponent()));
			sceneNode->SetName(ResourceEditor::PARTICLE_EFFECT_NODE_NAME);

			break;
		}

		case ResourceEditor::NODE_SKYBOX:
		{
			SetHeader(L"SkyBox");
			
			//TODO: add skybox creation code here
			break;
		}

        default:
            break;
    }

	propertyList = PropertyControlCreator::Instance()->CreateControlForNode(sceneNode, propertyRect, true);
    SafeRetain(propertyList);
	AddControl(propertyList);

	SetScene(editorScene);
    
    propertyList->ReadFrom(sceneNode);
}