コード例 #1
0
 public static Instance createTemporary(PrimitiveList primitives, Matrix4 transform, IShader shader)
 {
     Instance i = new Instance();
     i.o2w = new MovingMatrix4(transform);
     i.w2o = i.o2w.inverse();
     if (i.w2o == null) {
         UI.printError(UI.Module.GEOM, "Unable to compute transform inverse");
         return null;
     }
     i.geometry = new Geometry(primitives);
     i.shaders = new IShader[] { shader };
     i.updateBounds();
     return i;
 }
コード例 #2
0
ファイル: Scene.cs プロジェクト: rzel/sunflowsharp
        /**
         * Creates an empty scene.
         */
        public Scene()
        {
            lightServer = new LightServer(this);
            instanceList = new InstanceList();
            infiniteInstanceList = new InstanceList();
            acceltype = "auto";

            bakingViewDependent = false;
            bakingInstance = null;
            bakingPrimitives = null;
            bakingAccel = null;

            camera = null;
            imageWidth = 640;
            imageHeight = 480;
            threads = 0;
            lowPriority = true;

            rebuildAccel = true;
        }
コード例 #3
0
ファイル: RenderObjectMap.cs プロジェクト: rzel/sunflowsharp
 public RenderObjectHandle(Instance instance)
 {
     obj = instance;
     type = RenderObjectType.INSTANCE;
 }
コード例 #4
0
ファイル: RenderObjectMap.cs プロジェクト: rzel/sunflowsharp
        public void updateScene(Scene scene)
        {
            if (rebuildInstanceList)
            {
                UI.printInfo(UI.Module.API, "Building scene instance list for rendering ...");
                int numInfinite = 0, numInstance = 0;
                foreach (KeyValuePair<string, RenderObjectHandle> e in renderObjects)
                {
                    Instance i = e.Value.getInstance();
                    if (i != null)
                    {
                        i.updateBounds();
                        if (i.getBounds() == null)
                            numInfinite++;
                        else
                            numInstance++;
                    }
                }
                Instance[] infinite = new Instance[numInfinite];
                Instance[] instance = new Instance[numInstance];
                numInfinite = numInstance = 0;
                foreach (KeyValuePair<string, RenderObjectHandle> e in renderObjects)
                {
                    Instance i = e.Value.getInstance();
                    if (i != null)
                    {
                        if (i.getBounds() == null)
                        {
                            infinite[numInfinite] = i;
                            numInfinite++;
                        }
                        else
                        {
                            instance[numInstance] = i;
                            numInstance++;
                        }
                    }
                }
                scene.setInstanceLists(instance, infinite);
                rebuildInstanceList = false;
            }
            if (rebuildLightList)
            {
                UI.printInfo(UI.Module.API, "Building scene light list for rendering ...");
                List<LightSource> lightList = new List<LightSource>();
                foreach (KeyValuePair<string, RenderObjectHandle> e in renderObjects)
                {
                    LightSource light = e.Value.getLight();
                    if (light != null)
                        lightList.Add(light);

                }
                scene.setLightList(lightList.ToArray());
                rebuildLightList = false;
            }
        }
コード例 #5
0
ファイル: RenderObjectMap.cs プロジェクト: rzel/sunflowsharp
 public void put(string name, Instance instance)
 {
     renderObjects[name] = new RenderObjectHandle(instance);
 }
コード例 #6
0
 /**
  * Record an intersection with the specified primitive id. The parent object
  * is assumed to be the current instance. The u and v parameters are used to
  * pinpoint the location on the surface if needed.
  *
  * @param id primitive id of the intersected object
  * @param u u surface paramater of the intersection point
  * @param v v surface parameter of the intersection point
  */
 public void setIntersection(int id)
 {
     instance = current;
     this.id = id;
 }
コード例 #7
0
 /**
  * Record an intersection with the specified primitive id. The parent object
  * is assumed to be the current instance. The u and v parameters are used to
  * pinpoint the location on the surface if needed.
  *
  * @param id primitive id of the intersected object
  * @param u u surface paramater of the intersection point
  * @param v v surface parameter of the intersection point
  */
 public void setIntersection(int id, float u, float v, float w)
 {
     instance = current;
     this.id = id;
     this.u = u;
     this.v = v;
     this.w = w;
 }
コード例 #8
0
            public void set(ShadingState state)
            {
                if (state == null)
                    c = Color.BLACK;
                else
                {
                    c = state.getResult();
                    shader = state.getShader();
                    instance = state.getInstance();
                    if (state.getNormal() != null)
                    {
                        nx = state.getNormal().x;
                        ny = state.getNormal().y;
                        nz = state.getNormal().z;
                    }
					alpha = state.getInstance() == null ? 0 : 1;
                }
                n = 1;
            }
コード例 #9
0
            public ImageSample(float rx, float ry, int i)
            {
                this.rx = rx;
                this.ry = ry;
                this.i = i;
                n = 0;
                c = null;
				alpha = 0.0f;
                instance = null;
                shader = null;
                nx = ny = nz = 1;
            }
コード例 #10
0
ファイル: InstanceList.cs プロジェクト: rzel/sunflowsharp
 public InstanceList(Instance[] instances)
 {
     this.instances = instances;
 }
コード例 #11
0
ファイル: Scene.cs プロジェクト: rzel/sunflowsharp
 /**
  * Update the instance lists for this scene.
  *
  * @param instances regular instances
  * @param infinite infinite instances (no bounds)
  */
 public void setInstanceLists(Instance[] instances, Instance[] infinite)
 {
     infiniteInstanceList = new InstanceList(infinite);
     instanceList = new InstanceList(instances);
     rebuildAccel = true;
 }
コード例 #12
0
ファイル: Scene.cs プロジェクト: rzel/sunflowsharp
 /**
  * The provided instance will be considered for lightmap baking. If the
  * specified instance is <code>null</code>, lightmap baking will be
  * disabled and normal rendering will occur.
  *
  * @param instance instance to bake
  */
 public void setBakingInstance(Instance instance)
 {
     bakingInstance = instance;
 }
コード例 #13
0
 public void addLightSourceInstances(Instance[] lights)
 {
     this.lights = lights;
 }
コード例 #14
0
 public InstanceList(Instance[] instances)
 {
     this.instances = instances;
     clearLightSources();
 }