void PreRender() { if (needsRender) { world.InitFromMap(null); var spawnArgs = new Dictionary <string, string> { { "classname", "light" }, { "name", "light_1" }, { "origin", lightOrigin.ToVec3().ToString() }, { "_color", lightColor.ToVec3().ToString() }, }; gameEdit.ParseSpawnArgsToRenderLight(spawnArgs, rLight); lightDef = world.AddLightDef(rLight); if (((string)modelName).Length == 0) { common.Warning($"Window '{Name}' in gui '{Gui.SourceFile}': no model set"); } worldEntity.memset(); spawnArgs.Clear(); spawnArgs.Add("classname", "func_static"); spawnArgs.Add("model", modelName); spawnArgs.Add("origin", modelOrigin.ToString()); gameEdit.ParseSpawnArgsToRenderEntity(spawnArgs, worldEntity); if (worldEntity.hModel != null) { var v = modelRotate.ToVec3(); worldEntity.axis = v.ToMat3(); worldEntity.shaderParms[0] = 1f; worldEntity.shaderParms[1] = 1f; worldEntity.shaderParms[2] = 1f; worldEntity.shaderParms[3] = 1f; modelDef = world.AddEntityDef(worldEntity); } needsRender = false; } }
public override void Draw(int time, float x_, float y_) { PreRender(); Render(time); refdef.memset(); refdef.vieworg = viewOffset.ToVec3(); //: refdef.vieworg.Set(-128f, 0f, 0f); refdef.viewaxis.Identity(); refdef.shaderParms[0] = 1; refdef.shaderParms[1] = 1; refdef.shaderParms[2] = 1; refdef.shaderParms[3] = 1; // DG: for scaling menus to 4:3 (like that spinning mars globe in the main menu) var x = drawRect.x; var y = drawRect.y; var w = drawRect.w; var h = drawRect.h; if (dc.IsMenuScaleFixActive) { dc.AdjustCoords(ref x, ref y, ref w, ref h); } refdef.x = (int)x; refdef.y = (int)y; refdef.width = (int)w; refdef.height = (int)h; // DG end refdef.fov_x = 90; refdef.fov_y = (float)(2 * Math.Atan(drawRect.h / drawRect.w) * MathX.M_RAD2DEG); refdef.time = time; world.RenderScene(refdef); }