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; }
/** * 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; }
public RenderObjectHandle(Instance instance) { obj = instance; type = RenderObjectType.INSTANCE; }
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; } }
public void put(string name, Instance instance) { renderObjects[name] = new RenderObjectHandle(instance); }
/** * 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; }
/** * 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; }
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; }
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; }
public InstanceList(Instance[] instances) { this.instances = instances; }
/** * 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; }
/** * 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; }
public void addLightSourceInstances(Instance[] lights) { this.lights = lights; }
public InstanceList(Instance[] instances) { this.instances = instances; clearLightSources(); }