Search Results

Search found 2679 results on 108 pages for 'water cooler v2'.

Page 15/108 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • doing arithmetic upto two significant figures in Python?

    - by user248237
    I have two floats in Python that I'd like to subtract, i.e. v1 = float(value1) v2 = float(value2) diff = v1 - v2 I want "diff" to be computed upto two significant figures, that is compute it using %.2f of v1 and %.2f of v2. How can I do this? I know how to print v1 and v2 up to two decimals, but not how to do arithmetic like that. thanks.

    Read the article

  • xsl for-each group-by

    - by user348810
    My input xml is in this format: <Root> <Name>N1</Name> <YEAR>2010</YEAR> <MYVALE> <F1>V1</F1> <V1>100</V1> <MYVALUE> <MYVALE> <F1>V2</F1> <V1>100</V1> <MYVALUE> <MYVALE> <F1>V3</F1> <V1>100</V1> <MYVALUE> <Name>N1</Name> <YEAR>2011</YEAR> <MYVALE> <F1>V1</F1> <V1>100</V1> <MYVALUE> <MYVALE> <F1>V4</F1> <V1>400</V1> <MYVALUE> </Root> i want to group-by Name with the following child element <myvalue>. If the myvalue TAG has the same F1 TAG value then I need to group by these values. My expected output is this: <Root> <Name>N1</Name> <MYVALE> <F1>V1</F1> <V1>200</V1> </MYVALUE> <MYVALE> <F1>V2</F1> <V2>100</V2> </MYVALUE> <MYVALE> <F1>V3</F1> <V2>100</V2> </MYVALUE> <MYVALE> <F1>V4</F1> <V2>400</V2> <MYVALUE> </Root>

    Read the article

  • NVIDIA Driver Crashing on Custom-Built Windows 7 PC

    - by srunni
    I've got a custom-built PC with these specs: Fractal Design Define R3 ASUS P8Z77-V motherboard Intel Core i7-2700k with Thermalright HR-02 Macho Cooler NVIDIA GeForce GTX 560 with Arctic Cooling Accelero Twin Turbo II Cooler Crucial M4 128 GB SSD 1 TB Hitachi HDD G.SKILL Ares Series 2x8 GB RAM (x2) SeaSonic 520W PSU Windows 7 Ultimate SP1 (x64) NVIDIA driver version 301.42 Upon building the PC, I overclocked the CPU (but never the GPU), and there were no problems for 1-2 months. Then I started getting crashes with this error when doing anything that's computationally or graphically intensive: I un-overclocked the CPU, but that hasn't fixed anything. This is what the inside of my case looks like: I'd appreciate any guidance on resolving this problem. I did get some of the thermal paste on the graphics card when installing the aftermarket cooler, but there were no issues for a month or two. Update I did a clean install and the issue persisted - looks like it's a hardware issue. I will try removing/cleaning/reseating all the parts.

    Read the article

  • Strange error with VS2008 on Windows 7

    - by Christian
    We have a solution with two projects, one of them is a Silverlight 3 application which is embedded on the other ASP.NET MVC project. Just recently an error started to appear which makes the build fail. Here is the output: `------ Build started: Project: DotCoquiMap, Configuration: Debug Any CPU ------ C:\Program Files\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Ria.Client.targets : warning : Could not find necessary input file 'C:\Users\Michael\Documents\DotCoqui\trunk\DotCoquiMap\Bin\Debug\DotCoquiMap.dll'. Done building project "DotCoquiMap.csproj" -- FAILED. ------ Build started: Project: DotCoquiProject, Configuration: Debug Any CPU ------ C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\Users\Michael\Documents\DotCoqui\trunk\DotCoquiMap\Bin\Debug\DotCoquiMap.dll /reference:..\ExternalLibraries\itextsharp.dll /reference:..\ExternalLibraries\MvcMembership.dll /reference:..\ExternalLibraries\PagedList.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Abstractions.dll" /reference:............\Windows\assembly\GAC_MSIL\System.Web.DataVisualization\3.5.0.0__31bf3856ad364e35\System.Web.DataVisualization.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll /reference:"C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 1.0\Assemblies\System.Web.Mvc.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Routing.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /optimize- /out:obj\Debug\DotCoquiProject.dll /target:library Controllers\AccountController.cs Controllers\AdministrationController.cs Controllers\ApiController.cs Controllers\CampaignsCategoriesController.cs Controllers\CampaignsController.cs Controllers\CampaignsFormViewModel.cs Controllers\CampaignStatisticsController.cs Controllers\CampaignStatisticsDetailsViewModel.cs Controllers\ControllerHelpers.cs Controllers\CountriesController.cs Controllers\ErrorController.cs Controllers\HomeController.cs Controllers\MapController.cs Controllers\MediaController.cs Controllers\MediaViewModel.cs Controllers\NewsController.cs Controllers\OrganizationsController.cs Controllers\OrgCenterController.cs Controllers\UserAdministrationController.cs Default.aspx.cs Global.asax.cs Models\Campaigns.cs Models\CategoriesRuleValidation.cs Models\DotCoquiDBModel.designer.cs Models\DotCoquiRepository.cs Models\DQcodes.cs Models\FileRepository.cs Models\ISmtpClient.cs Models\JsonModels.cs Models\OrgCenter\IndexViewModel.cs Models\SmtpClientProxy.cs Models\Statistic.cs Models\User.cs Models\UserAdministration\DetailsViewModel.cs Models\UserAdministration\IndexViewModel.cs Models\UserAdministration\RoleViewModel.cs Properties\AssemblyInfo.cs error CS0006: Metadata file 'C:\Users\Michael\Documents\DotCoqui\trunk\DotCoquiMap\Bin\Debug\DotCoquiMap.dll' could not be found Compile complete -- 1 errors, 0 warnings ========== Build: 0 succeeded or up-to-date, 2 failed, 0 skipped ==========` And here is the errors / warnings: Warning 2 Could not find necessary input file 'C:\Users\Michael\Documents\DotCoqui\trunk\DotCoquiMap\Bin\Debug\DotCoquiMap.dll'. DotCoquiMap Error 1 Metadata file 'C:\Users\Michael\Documents\DotCoqui\trunk\DotCoquiMap\Bin\Debug\DotCoquiMap.dll' could not be found DotCoquiProject The DotCoquiMap is not getting built therefore the DotCoquiProject (ASP.NET MVC) cannot find the .dll. Now here is the really odd thing, under Windows XP the very same code compiles and runs perfectly.... under windows 7 it gives us these errors. It is the very same code, we have tested it on 3 different Win7 machines to no avail. Help will be really really helpful. Thanks in advance.

    Read the article

  • Ingredient Substitutes while Baking

    - by Rekha
    In our normal cooking, we substitute the vegetables for the gravies we prepare. When we start baking, we look for a good recipe. At least one or two ingredient will be missing. We do not know where to substitute what to bring same output. So we finally drop the plan of baking. Again after a month, we get the interest in baking. Again one or two lack of ingredient and that’s it. We keep on doing this for months. When I was going through the cooking blogs, I came across a site with the Ingredient Substitutes for Baking: (*) is to indicate that this substitution is ideal from personal experience. Flour Substitutes ( For 1 cup of Flour) All Purpose Flour 1/2 cup white cake flour plus 1/2 cup whole wheat flour 1 cup self-rising flour (omit using salt and baking powder if the recipe calls for it since self raising flour has it already) 1 cup plus 2 tablespoons cake flour 1/2 cup (75 grams) whole wheat flour 7/8 cup (130 grams) rice flour (starch) (do not replace all of the flour with the rice flour) 7/8 cup whole wheat Bread Flour 1 cup all purpose flour 1 cup all purpose flour plus 1 teaspoon wheat gluten (*) Cake Flour Place 2 tbsp cornstarch in 1 cup and fill the rest up with All Purpose flour (*) 1 cup all purpose flour minus 2 tablespoons Pastry flour Place 2 tbsp cornstarch in 1 cup and fill the rest up with All Purpose flour Equal parts of All purpose flour plus cake flour (*) Self-rising Flour 1½ teaspoons of baking powder plus ½ teaspoon of salt plus 1 cup of all-purpose flour. Cornstarch (1 tbsp) 2 tablespoons all-purpose flour 1 tablespoon arrowroot 4 teaspoons quick-cooking tapioca 1 tablespoon potato starch or rice starch or flour Tapioca (1 tbsp) 1 – 1/2 tablespoons all-purpose flour Cornmeal (stone ground) polenta OR corn flour (gives baked goods a lighter texture) if using cornmeal for breading,crush corn chips in a blender until they have the consistency of cornmeal. maize meal Corn grits Sweeteners ( for Every 1 cup ) * * (HV) denotes Healthy Version for low fat or fat free substitution in Baking Light Brown Sugar 2 tablespoons molasses plus 1 cup of white sugar Dark Brown Sugar 3 tablespoons molasses plus 1 cup of white sugar Confectioner’s/Powdered Sugar Process 1 cup sugar plus 1 tablespoon cornstarch Corn Syrup 1 cup sugar plus 1/4 cup water 1 cup Golden Syrup 1 cup honey (may be little sweeter) 1 cup molasses Golden Syrup Combine two parts light corn syrup plus one part molasses 1/2 cup honey plus 1/2 cup corn syrup 1 cup maple syrup 1 cup corn syrup Honey 1- 1/4 cups sugar plus 1/4 cup water 3/4 cup maple syrup plus 1/2 cup granulated sugar 3/4 cup corn syrup plus 1/2 cup granulated sugar 3/4 cup light molasses plus 1/2 cup granulated white sugar 1 1/4 cups granulated white or brown sugar plus 1/4 cup additional liquid in recipe plus 1/2 teaspoon cream of tartar Maple Syrup 1 cup honey,thinned with water or fruit juice like apple 3/4 cup corn syrup plus 1/4 cup butter 1 cup Brown Rice Syrup 1 cup Brown sugar (in case of cereals) 1 cup light molasses (on pancakes, cereals etc) 1 cup granulated sugar for every 3/4 cup of maple syrup and increase liquid in the recipe by 3 tbsp for every cup of sugar.If baking soda is used, decrease the amount by 1/4 teaspoon per cup of sugar substituted, since sugar is less acidic than maple syrup Molasses 1 cup honey 1 cup dark corn syrup 1 cup maple syrup 3/4 cup brown sugar warmed and dissolved in 1/4 cup of liquid ( use this if taste of molasses is important in the baked good) Cocoa Powder (Natural, Unsweetened) 3 tablespoons (20 grams) Dutch-processed cocoa plus 1/8 teaspoon cream of tartar, lemon juice or white vinegar 1 ounce (30 grams) unsweetened chocolate (reduce fat in recipe by 1 tablespoon) 3 tablespoons (20 grams) carob powder Semisweet baking chocolate (1 oz) 1 oz unsweetened baking chocolate plus 1 Tbsp sugar Unsweetened baking chocolate (1 oz ) 3 Tbsp baking cocoa plus 1 Tbsp vegetable oil or melted shortening or margarine Semisweet chocolate chips (1 cup) 6 oz semisweet baking chocolate, chopped (Alternatively) For 1 cup of Semi sweet chocolate chips you can use : 6 tablespoons unsweetened cocoa powder, 7 tablespoons sugar ,1/4 cup fat (butter or oil) Leaveners and Diary * * (HV) denotes Healthy Version for low fat or fat free substitution in Baking Compressed Yeast (1 cake) 1 envelope or 2 teaspoons active dry yeast 1 packet (1/4 ounce) Active Dry yeast 1 cake fresh compressed yeast 1 tablespoon fast-rising active yeast Baking Powder (1 tsp) 1/3 teaspoon baking soda plus 1/2 teaspoon cream of tartar 1/2 teaspoon baking soda plus 1/2 cup buttermilk or plain yogurt 1/4 teaspoon baking soda plus 1/3 cup molasses. When using the substitutions that include liquid, reduce other liquid in recipe accordingly Baking Soda(1 tsp) 3 tsp Baking Powder ( and reduce the acidic ingredients in the recipe. Ex Instead of buttermilk add milk) 1 tsp potassium bicarbonate Ideal substitution – 2 tsp Baking powder and omit salt in recipe Cream of tartar (1 tsp) 1 teaspoon white vinegar 1 tsp lemon juice Notes from What’s Cooking America – If cream of tartar is used along with baking soda in a cake or cookie recipe, omit both and use baking powder instead. If it calls for baking soda and cream of tarter, just use baking powder.Normally, when cream of tartar is used in a cookie, it is used together with baking soda. The two of them combined work like double-acting baking powder. When substituting for cream of tartar, you must also substitute for the baking soda. If your recipe calls for baking soda and cream of tarter, just use baking powder. One teaspoon baking powder is equivalent to 1/4 teaspoon baking soda plus 5/8 teaspoon cream of tartar. If there is additional baking soda that does not fit into the equation, simply add it to the batter. Buttermilk (1 cup) 1 tablespoon lemon juice or vinegar (white or cider) plus enough milk to make 1 cup (let stand 5-10 minutes) 1 cup plain or low fat yogurt 1 cup sour cream 1 cup water plus 1/4 cup buttermilk powder 1 cup milk plus 1 1/2 – 1 3/4 teaspoons cream of tartar Plain Yogurt (1 cup) 1 cup sour cream 1 cup buttermilk 1 cup crème fraiche 1 cup heavy whipping cream (35% butterfat) plus 1 tablespoon freshly squeezed lemon juice Whole Milk (1 cup) 1 cup fat free milk plus 1 tbsp unsaturated Oil like canola (HV) 1 cup low fat milk (HV) Heavy Cream (1 cup) 3/4 cup milk plus 1/3 cup melted butter.(whipping wont work) Sour Cream (1 cup) (pls refer also Substitutes for Fats in Baking below) 7/8 cup buttermilk or sour milk plus 3 tablespoons butter. 1 cup thickened yogurt plus 1 teaspoon baking soda. 3/4 cup sour milk plus 1/3 cup butter. 3/4 cup buttermilk plus 1/3 cup butter. Cooked sauces: 1 cup yogurt plus 1 tablespoon flour plus 2 teaspoons water. Cooked sauces: 1 cup evaporated milk plus 1 tablespoon vinegar or lemon juice. Let stand 5 minutes to thicken. Dips: 1 cup yogurt (drain through a cheesecloth-lined sieve for 30 minutes in the refrigerator for a thicker texture). Dips: 1 cup cottage cheese plus 1/4 cup yogurt or buttermilk, briefly whirled in a blender. Dips: 6 ounces cream cheese plus 3 tablespoons milk,briefly whirled in a blender. Lower fat: 1 cup low-fat cottage cheese plus 1 tablespoon lemon juice plus 2 tablespoons skim milk, whipped until smooth in a blender. Lower fat: 1 can chilled evaporated milk whipped with 1 teaspoon lemon juice. 1 cup plain yogurt plus 1 tablespoon cornstarch 1 cup plain nonfat yogurt Substitutes for Fats in Baking * * (HV) denoted Healthy Version for low fat or fat free substitution in Baking Butter (1 cup) 1 cup trans-free vegetable shortening 3/4 cups of vegetable oil (example. Canola oil) Fruit purees (example- applesauce, pureed prunes, baby-food fruits). Add it along with some vegetable oil and reduce any other sweeteners needed in the recipe since fruit purees are already sweet. 1 cup polyunsaturated margarine (HV) 3/4 cup polyunsaturated oil like safflower oil (HV) 1 cup mild olive oil (not extra virgin)(HV) Note: Butter creates the flakiness and the richness which an oil/purees cant provide. If you don’t want to compromise that much to taste, replace half the butter with the substitutions. Shortening(1 cup) 1 cup polyunsaturated margarine like Earth Balance or Smart Balance(HV) 1 cup + 2tbsp Butter ( better tasting than shortening but more expensive and has cholesterol and a higher level of saturated fat; makes cookies less crunchy, bread crusts more crispy) 1 cup + 2 tbsp Margarine (better tasting than shortening but more expensive; makes cookies less crunchy, bread crusts tougher) 1 Cup – 2tbsp Lard (Has cholesterol and a higher level of saturated fat) Oil equal amount of apple sauce stiffly beaten egg whites into batter equal parts mashed banana equal parts yogurt prune puree grated raw zucchini or seeds removed if cooked. Works well in quick breads/muffins/coffee cakes and does not alter taste pumpkin puree (if the recipe can handle the taste change) Low fat cottage cheese (use only half of the required fat in the recipe). Can give rubbery texture to the end result Silken Tofu – (use only half of the required fat in the recipe). Can give rubbery texture to the end result Equal parts of fruit juice Note: Fruit purees can alter the taste of the final product is used in large quantities. Cream Cheese (1 cup) 4 tbsps. margarine plus 1 cup low-fat cottage cheese – blended. Add few teaspoons of fat-free milk if needed (HV) Heavy Cream (1 cup) 1 cup evaporated skim milk (or full fat milk) 1/2 cup low fat Yogurt plus 1/2 low fat Cottage Cheese (HV) 1/2 cup Yogurt plus 1/2 Cottage Cheese Sour Cream (1 cup) 1 cup plain yogurt (HV) 3/4 cup buttermilk or plain yogurt plus 1/3 cup melted butter 1 cup crème fraiche 1 tablespoon lemon juice or vinegar plus enough whole milk to fill 1 cup (let stand 5-10 minutes) 1/2 cup low-fat cottage cheese plus 1/2 cup low-fat or nonfat yogurt (HV) 1 cup fat-free sour cream (HV) Note: How to Make Maple Syrup Substitute at home For 1 Cup Maple Syrup 1/2 cup granulated sugar 1 cup brown sugar, firmly packed 1 cup boiling water 1 teaspoon butter 1 teaspoon maple extract or vanilla extract Method In a heavy saucepan, place the granulated sugar and keep stirring until it melts and turns slightly brown. Alternatively in another pan, place brown sugar and water and bring to a boil without stirring. Now mix both the sugars and simmer in low heat until they come together as one thick syrup. Remove from heat, add butter and the extract. Use this in place of maple syrup. Store it in a fridge in an air tight container. Even though this was posted in their site long back, I found it helpful. So posting it for you. via chefinyou . cc image credit: flickr/zetrules

    Read the article

  • Refactoring an immediate drawing function into VBO, access violation error

    - by Alex
    I have a MD2 model loader, I am trying to substitute its immediate drawing function with a Vertex Buffer Object one.... I am getting a really annoying access violation reading error and I can't figure out why, but mostly I'd like an opinion as to whether this looks correct (never used VBOs before). This is the original function (that compiles ok) which calculates the keyframe and draws at the same time: glBegin(GL_TRIANGLES); for(int i = 0; i < numTriangles; i++) { MD2Triangle* triangle = triangles + i; for(int j = 0; j < 3; j++) { MD2Vertex* v1 = frame1->vertices + triangle->vertices[j]; MD2Vertex* v2 = frame2->vertices + triangle->vertices[j]; Vec3f pos = v1->pos * (1 - frac) + v2->pos * frac; Vec3f normal = v1->normal * (1 - frac) + v2->normal * frac; if (normal[0] == 0 && normal[1] == 0 && normal[2] == 0) { normal = Vec3f(0, 0, 1); } glNormal3f(normal[0], normal[1], normal[2]); MD2TexCoord* texCoord = texCoords + triangle->texCoords[j]; glTexCoord2f(texCoord->texCoordX, texCoord->texCoordY); glVertex3f(pos[0], pos[1], pos[2]); } } glEnd(); What I'd like to do is to calculate all positions before hand, store them in a Vertex array and then draw them. This is what I am trying to replace it with (in the exact same part of the program) int vCount = 0; for(int i = 0; i < numTriangles; i++) { MD2Triangle* triangle = triangles + i; for(int j = 0; j < 3; j++) { MD2Vertex* v1 = frame1->vertices + triangle->vertices[j]; MD2Vertex* v2 = frame2->vertices + triangle->vertices[j]; Vec3f pos = v1->pos * (1 - frac) + v2->pos * frac; Vec3f normal = v1->normal * (1 - frac) + v2->normal * frac; if (normal[0] == 0 && normal[1] == 0 && normal[2] == 0) { normal = Vec3f(0, 0, 1); } indices[vCount] = normal[0]; vCount++; indices[vCount] = normal[1]; vCount++; indices[vCount] = normal[2]; vCount++; MD2TexCoord* texCoord = texCoords + triangle->texCoords[j]; indices[vCount] = texCoord->texCoordX; vCount++; indices[vCount] = texCoord->texCoordY; vCount++; indices[vCount] = pos[0]; vCount++; indices[vCount] = pos[1]; vCount++; indices[vCount] = pos[2]; vCount++; } } totalVertices = vCount; glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, 0, indices); glTexCoordPointer(2, GL_FLOAT, sizeof(float)*3, indices); glVertexPointer(3, GL_FLOAT, sizeof(float)*5, indices); glDrawElements(GL_TRIANGLES, totalVertices, GL_UNSIGNED_BYTE, indices); glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); First of all, does it look right? Second, I get access violation error "Unhandled exception at 0x01455626 in Graphics_template_1.exe: 0xC0000005: Access violation reading location 0xed5243c0" pointing at line 7 Vec3f pos = v1->pos * (1 - frac) + v2->pos * frac; where the two Vs seems to have no value in the debugger.... Till this point the function behaves in exactly the same way as the one above, I don't understand why this happens? Thanks for any help you may be able to provide!

    Read the article

  • Refining data stored in SQLite - how to join several contacts?

    - by Krab
    Problem background Imagine this problem. You have a water molecule which is in contact with other molecules (if the contact is a hydrogen bond, there can be 4 other molecules around my water). Like in the following picture (A, B, C, D are some other atoms and dots mean the contact). A B . . O / \ H H . . C D I have the information about all the dots and I need to eliminate the water in the center and create records describing contacts of A-C, A-D, A-B, B-C, B-D, and C-D. Database structure Currently, I have the following structure in the database: Table atoms: "id" integer PRIMARY KEY, "amino" char(3) NOT NULL, (HOH for water or other value) other columns identifying the atom Table contacts: "acceptor_id" integer NOT NULL, (the atom near to my hydrogen, here C or D) "donor_id" integer NOT NULL, (here A or B) "directness" char(1) NOT NULL, (this should be D for direct and W for water-mediated) other columns about the contact, such as the distance Current solution (insufficient) Now, I'm going through all the contacts which have donor.amino = "HOH". In this sample case, this would select contacts from C and D. For each of these selected contacts, I look up contacts having the same acceptor_id as is the donor_id in the currently selected contact. From this information, I create the new contact. At the end, I delete all contacts to or from HOH. This way, I am obviously unable to create C-D and A-B contacts (the other 4 are OK). If I try a similar approach - trying to find two contacts having the same donor_id, I end up with duplicate contacts (C-D and D-C). Is there a simple way to retrieve all six contacts without duplicates? I'm dreaming about some one page long SQL query which retrievs just these six wanted rows. :-) It is preferable to conserve information about who is donor where possible, but not strictly necessary. Big thanks to all of you who read this question to this point.

    Read the article

  • #pragma directive and its uses in c

    - by sandy101
    Hello , can anyone tell my what does the #pragma can do in the c language . what are its uses and why the above program is not giving the output 'inside v1'& 'inside v2' in the following program ... include void v1(); void v2(); pragma startup v1 pragma exit v2 int main() { printf("inside main\n"); return 0; } void v1() { printf("inside v1\n"); } void v2() { printf("inside v2\n"); } i also want to know what a are the uses of the #pragma directive .... plz help

    Read the article

  • Please Help me add up the elements for this structure in Scheme/Lisp

    - by kunjaan
    I have an input which is of this form: (((lady-in-water . 1.25) (snake . 1.75) (run . 2.25) (just-my-luck . 1.5)) ((lady-in-water . 0.8235294117647058) (snake . 0.5882352941176471) (just-my-luck . 0.8235294117647058)) ((lady-in-water . 0.8888888888888888) (snake . 1.5555555555555554) (just-my-luck . 1.3333333333333333))) (context: the word denotes a movie and the number denotes the weighted rating submitted by the user) I need to add all the quantity and return a list which looks something like this ((lady-in-water 2.5) (snake 2.5) (run 2.25) (just-myluck 2.6)) How do I traverse the list and all the quantities? I am really stumped. Please help me. Thanks.

    Read the article

  • Annoying flickering of vertices and edges (possible z-fighting)

    - by Belgin
    I'm trying to make a software z-buffer implementation, however, after I generate the z-buffer and proceed with the vertex culling, I get pretty severe discrepancies between the vertex depth and the depth of the buffer at their projected coordinates on the screen (i.e. zbuffer[v.xp][v.yp] != v.z, where xp and yp are the projected x and y coordinates of the vertex v), sometimes by a small fraction of a unit and sometimes by 2 or 3 units. Here's what I think is happening: Each triangle's data structure holds the plane's (that is defined by the triangle) coefficients (a, b, c, d) computed from its three vertices from their normal: void computeNormal(Vertex *v1, Vertex *v2, Vertex *v3, double *a, double *b, double *c) { double a1 = v1 -> x - v2 -> x; double a2 = v1 -> y - v2 -> y; double a3 = v1 -> z - v2 -> z; double b1 = v3 -> x - v2 -> x; double b2 = v3 -> y - v2 -> y; double b3 = v3 -> z - v2 -> z; *a = a2*b3 - a3*b2; *b = -(a1*b3 - a3*b1); *c = a1*b2 - a2*b1; } void computePlane(Poly *p) { double x = p -> verts[0] -> x; double y = p -> verts[0] -> y; double z = p -> verts[0] -> z; computeNormal(p -> verts[0], p -> verts[1], p -> verts[2], &p -> a, &p -> b, &p -> c); p -> d = p -> a * x + p -> b * y + p -> c * z; } The z-buffer just holds the smallest depth at the respective xy coordinate by somewhat casting rays to the polygon (I haven't quite got interpolation right yet so I'm using this slower method until I do) and determining the z coordinate from the reversed perspective projection formulas (which I got from here: double z = -(b*Ez*y + a*Ez*x - d*Ez)/(b*y + a*x + c*Ez - b*Ey - a*Ex); Where x and y are the pixel's coordinates on the screen; a, b, c, and d are the planes coefficients; Ex, Ey, and Ez are the eye's (camera's) coordinates. This last formula does not accurately give the exact vertices' z coordinate at their projected x and y coordinates on the screen, probably because of some floating point inaccuracy (i.e. I've seen it return something like 3.001 when the vertex's z-coordinate was actually 2.998). Here is the portion of code that hides the vertices that shouldn't be visible: for(i = 0; i < shape.nverts; ++i) { double dist = shape.verts[i].z; if(z_buffer[shape.verts[i].yp][shape.verts[i].xp].z < dist) shape.verts[i].visible = 0; else shape.verts[i].visible = 1; } How do I solve this issue? EDIT I've implemented the near and far planes of the frustum, with 24 bit accuracy, and now I have some questions: Is this what I have to do this in order to resolve the flickering? When I compare the z value of the vertex with the z value in the buffer, do I have to convert the z value of the vertex to z' using the formula, or do I convert the value in the buffer back to the original z, and how do I do that? What are some decent values for near and far? Thanks in advance.

    Read the article

  • Haskell Syntax: Parse Error On Input

    - by NuNu
    As part of a mini-haskell compiler that I'm writing, I have a function named app. What I want this function to do is take in these arguments epp (App e1 e2). The first step would be to evaluate e1 recursively (epp e1) and check if the output would be an error. If not then evaluate e2 and then call another function eppVals to evaluate the outputs of the calls on e1 and e2 which I defined as v1 and v2 respectively. epp (App e1 e2) | epp e1 /= Error = eppVals v1 v2 | otherwise = Error where v1 = epp e1 v2 = epp e2 <- parse error on input `=' Logically I believe what I have written so far works but I'm getting a parse error on input = where I stated above. Any idea why? My second try epp :: Exp -> Error Val epp (App e1 e2) = (eppVals v1 v2) where v1 = (epp e1) v2 = (epp e2) But now throws Couldn't match expected type Val with actual type Error Val

    Read the article

  • MYSQL if statement question...

    - by Dennis_M
    Is there any way to get the if statement to evaluate a query? SELECT if(50,'EQ_Type','*') FROM EQUIPMENT; Resulting in: +-----------------------+ | IF(50,'EQ_Type','*') | +-----------------------+ | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | +-----------------------+ 9 rows in set (0.00 sec) I would like the above statement to be equivalent to the following: SELECT 'EQ_Type' FROM EQUIPMENT; And produce: +--------------+ | EQ_Type | +--------------+ | ENGINE | | ENGINE | | ENGINE | | TRAILER | | TRAILER | | TRAILER | | WATER TENDER | | WATER TENDER | | WATER TENDER | +--------------+ Thanks for any help

    Read the article

  • Build OpenGL model in parallel?

    - by Brendan Long
    I have a program which draws some terrain and simulates water flowing over it (in a cheap and easy way). Updating the water was easy to parallelize using OpenMP, so I can do ~50 updates per second. The problem is that even with a small amounts of water, my draws per second are very very low (starts at 5 and drops to around 2 once there's a significant amount of water). It's not a problem with the video card because the terrain is more complicated and gets drawn so quickly that boost::timer tells me that I get infinity draws per second if I turn the water off. It may be related to memory bandwidth though (since I assume the model stays on the card and doesn't have to be transfered every time). What I'm concerned about is that on every draw, I'm calling glVertex3f() about a million times (max size is 450*600, 4 vertices each), and it's done entirely sequentially because Glut won't let me call anything in parallel. So.. is if there's some way of building the list in parallel and then passing it to OpenGL all at once? Or some other way of making it draw this faster? Am I using the wrong method (besides the obvious "use less vertices")?

    Read the article

  • Storing tree data in Javascript

    - by Ozh
    I need to store data to represent this: Water + Fire = Steam Water + Earth = Mud Mud + Fire = Rock The goal is the following: I have draggable HTML divs, and when <div id="Fire"> and <div id="Mud"> overlap, I add <div id="Rock"> to the screen. Ever played Alchemy on iPhone or Android? Same stuff Right now, the way I'm doing this is a JS object : var stuff = { 'Steam' : { needs: [ 'Water', 'Fire'] }, 'Mud' : { needs: [ 'Water', 'Earth'] }, 'Rock' : { needs: [ 'Mud', 'Fire'] }, // etc... }; and every time a div overlaps with another one, I traverse the object keys and check the 'needs' array. I can deal with that structure but I was wondering if I could do any better? Edit: I should add that I also need to store a few other things, like a short description or an icon name. So typicall I have Steam: { needs: [ array ], desc: "short desc", icon:"steam.png"},

    Read the article

  • Quickest way to compute the number of shared elements between two vectors

    - by shn
    Suppose I have two vectors of the same size vector< pair<float, NodeDataID> > v1, v2; I want to compute how many elements from both v1 and v2 have the same NodeDataID. For example if v1 = {<3.7, 22>, <2.22, 64>, <1.9, 29>, <0.8, 7>}, and v2 = {<1.66, 7>, <0.03, 9>, <5.65, 64>, <4.9, 11>}, then I want to return 2 because there are two elements from v1 and v2 that share the same NodeDataIDs: 7 and 64. What is the quickest way to do that in C++ ? Just for information, note that the type NodeDataIDs is defined as I use boost as: typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> myGraph; typedef myGraph::vertex_descriptor NodeDataID; But it is not important since we can compare two NodeDataID using the operator == (that is, possible to do v1[i].second == v2[j].second)

    Read the article

  • C# language questions

    - by Water Cooler v2
    1) What is int? Is it any different from the struct System.Int32? I understand that the former is a C# alias (typedef or #define equivalant) for the CLR type System.Int32. Is this understanding correct? 2) When we say: IComparable x = 10; Is that like saying: IComparable x = new System.Int32(); But we can't new a struct, right? or in C like syntax: struct System.In32 *x; x=>someThing = 10; 3) What is String with a capitalized S? I see in Reflector that it is the sealed String class, which, of course, is a reference type, unlike the System.Int32 above, which is a value type. What is string, with an uncapitalized s, though? Is that also the C# alias for this class? Why can I not see the alias definitions in Reflector? 4) Try to follow me down this subtle train of thought, if you please. We know that a storage location of a particular type can only access properties and members on its interface. That means: Person p = new Customer(); p.Name = "Water Cooler v2"; // legal because as Name is defined on Person. but // illegal without an explicit cast even though the backing // store is a Customer, the storage location is of type // Person, which doesn't support the member/method being // accessed/called. p.GetTotalValueOfOrdersMade(); Now, with that inference, consider this scenario: int i = 10; // obvious System.object defines no member to // store an integer value or any other value in. // So, my question really is, when the integer is // boxed, what is the *type* it is actually boxed to. // In other words, what is the type that forms the // backing store on the heap, for this operation? object x = i;

    Read the article

  • Javascript For-Each Loop Syntax Help

    - by radrew
    Hey guys, I've got a complex block of PHP/Javascript that isn't functioning. I'm trying to manipulate a form that contains 4 dropdown select lists. Each dropdown is dependent upon what was selected in the one above it. I apologize for the huge amount of code, but I was hoping someone might be able to spot a syntax error or something else simple that I'm missing. The form in question is located in the right sidebar of the following site: http://www.buyautocovers.com $Manufacturer_array[] = array('id' => 'all', 'text' => $this->__('Choose Make')); $Model_array[] = array('id' = 'all', 'text' = $this-('Choose Model')); $Number_array[] = array('id' = 'all', 'text' = $this-('Choose Year')); $Body_array[] = array('id' = 'all', 'text' = $this-__('Choose Body Type')); $javascript = ' // var a = new Array(); var b = new Array(); var c = new Array(); var d = new Array();'; $M_a = array(); foreach ($rows as $r) { if (!isset($M_a [$r['manufacturer']])) $Manufacturer_array[] = array('id' = $r['manufacturer'], 'text' = $r['manufacturer']); $M_a [$r['manufacturer']][$r['model']][$r['number']][$r['body']] = 1; } $i = 0; foreach ($M_a as $k =$v){ $javascript .= 'a['.$i.']="'.$k.'";b['.$i.'];c['.$i.'];=new Array('; $ii = 0; $s = ''; foreach ($M_a[$k] as $kk =$vv){ $javascript .= ($ii != 0 ? ',' : '').'"'.$kk.'"'; $ss = ''; $iii = 0; foreach ($M_a[$k][$kk] as $kkk = $vvv){ $javascript .= ($iii != 0 ? ',' : '').'"'.$kkk.'"'; $sss = ''; $iiii = 0; foreach ($M_a[$k][$kk][$kkk] as $kkkk = $vvvv){ $sss .= ($iiii != 0 ? ',' : '').'"'.$kkkk.'"'; $iiii++; } $ss .= 'd['.$i.']['.$ii.']['.$iii.']=new Array('.$sss.');'; $iii++; } $s .= 'd['.$i.']['.$ii.']=new Array('.$ss.');'; $ii++; } $javascript .= ');d['.$i.']=new Array();'.$s; $i++; } $javascript .= ' function pop_model(){ var o ="' . $this-('Choose Model') . '"; var sv = $(\'mmn_manufacturer\').value; if(sv != "all"){ var v = a.length; while(v--) if(sv == a[v]) break; for(var i = 0; i < b[v].length; i++) o+=""+b[v][i]+""; } o+=""; $(\'model_select\').innerHTML= o; $(\'number_select\').innerHTML= "' . $this-('Choose Year') . '"; } function pop_number(){ var o ="' . $this-('Choose Year') . '"; var sv = $(\'mmn_manufacturer\').value; if(sv != "all"){ var v = a.length; while(v--) if(sv == a[v]) break; var sv2 = $(\'mmn_model\').value; if(sv2 != "all"){ var v2 = b[v].length; while(v2--) if(sv2 == b[v][v2]) break; for(var i = 0; i < c[v][v2].length; i++) o+=""+c[v][v2][i]+""; } } o+=""; $(\'number_select\').innerHTML= o; $(\'body_select\').innerHTML= "' . $this-('Choose Body Type') . '"; } function pop_body(){ var o ="' . $this-__('Choose Body Type') . '"; var sv = $(\'mmn_manufacturer\').value; if(sv != "all"){ var v = a.length; while(v--) if(sv == a[v]) break; var sv2 = $(\'mmn_model\').value; if(sv2 != "all"){ var v2 = b[v].length; while(v2--) if(sv2 == b[v][v2]) break; var sv3 = $(\'mmn_number\').value; if(sv3 != "all"){ var v3 = c[v].length; while(v3--) if(sv3 == b[v]c[v2][v3]) break; for(var i = 0; i < d[v]c[v2][v3].length; i++) o+=""+d[v]c[v2][v3][i]+""; } } } o+=""; $(\'number_select\').innerHTML= o; } //]] '; $expire = time()+60*60*24*90; if (isset($_GET['Manufacturer'])){ setcookie("Manufacturer_selected", $_GET['Manufacturer'], $expire,'/'); if ($_GET['Manufacturer'] != 'all') $Manufacturer_selected_var = $_GET['Manufacturer']; } elseif (isset($_COOKIE['Manufacturer_selected']) && $_COOKIE['Manufacturer_selected'] != 'all') $Manufacturer_selected_var = $_COOKIE['Manufacturer_selected']; if (isset($_GET['Model'])){ setcookie("Model_selected", $_GET['Model'], $expire,'/'); if ($_GET['Model'] != 'all') $Model_selected_var = $_GET['Model']; } elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all') $Model_selected_var = $_COOKIE['Model_selected']; if (isset($_GET['Number'])){ setcookie("Number_selected", $_GET['Number'], $expire,'/'); if ($_GET['Number'] != 'all') $Number_selected_var = $_GET['Number']; } elseif (isset($_COOKIE['Number_selected']) && $_COOKIE['Number_selected'] != 'all') $Number_selected_var = $_COOKIE['Number_selected']; if (isset($_GET['Body'])){ setcookie("Body_selected", $_GET['Body'], $expire,'/'); if ($_GET['Body'] != 'all') $Body_selected_var = $_GET['Body']; } elseif (isset($_COOKIE['Body_selected']) && $_COOKIE['Body_selected'] != 'all') $Body_selected_var = $_COOKIE['Body_selected']; if (isset($Manufacturer_selected_var) && isset($M_a[$Manufacturer_selected_var])) foreach ($M_a[$Manufacturer_selected_var] as $k => $v) $Model_array[] = array('id' = $k, 'text' = $k); if (isset($Manufacturer_selected_var) && isset($Model_selected_var) && isset($M_a[$Manufacturer_selected_var][$Model_selected_var])) foreach ($M_a[$Manufacturer_selected_var][$Model_selected_var] as $k = $v) $Number_array[] = array('id' = $k, 'text' = $k); if (isset($Manufacturer_selected_var) && isset($Model_selected_var) && isset($Number_selected_var) && isset($M_a[$Manufacturer_selected_var][$Model_selected_var][$Number_selected_var])) foreach ($M_a[$Manufacturer_selected_var][$Model_selected_var][$Number_selected_var] as $k = $v) $Body_array[] = array('id' = $k, 'text' = $k); echo $javascript;

    Read the article

  • How should I go about implementing a points-to analysis in Maude?

    - by reprogrammer
    I'm going to implement a points-to analysis algorithm. I'd like to implement this analysis mainly based on the algorithm by Whaley and Lam. Whaley and Lam use a BDD based implementation of Datalog to represent and compute the points-to analysis relations. The following lists some of the relations that are used in a typical points-to analysis. Note that D(w, z) :- A(w, x),B(x, y), C(y, z) means D(w, z) is true if A(w, x), B(x, y), and C(y, z) are all true. BDD is the data structure used to represent these relations. Relations input vP0 (variable : V, heap : H) input store (base : V, field : F, source : V) input load (base : V, field : F, dest : V) input assign (dest : V, source : V) output vP (variable : V, heap : H) output hP (base : H, field : F, target : H) Rules vP(v, h) :- vP0(v, h) vP(v1, h) :- assign(v1, v2), vP(v2, h) hP(h1, f,h2) :- store(v1, f, v2), vP(v1, h1), vP(v2, h2) vP(v2, h2) :- load(v1, f, v2), vP(v1, h1), hP(h1, f, h2) I need to understand if Maude is a good environment for implementing points-to analysis. I noticed that Maude uses a BDD library called BuDDy. But, it looks like that Maude uses BDDs for a different purpose, i.e. unification. So, I thought I might be able to use Maude instead of a Datalog engine to compute the relations of my points-to analysis. I assume Maude propagates independent information concurrently. And this concurrency could potentially make my points-to analysis faster than sequential processing of rules. But, I don't know the best way to represent my relations in Maude. Should I implement BDD in Maude myself, or Maude's internal unification based on BDD has the same effect?

    Read the article

  • Conversion failed when converting the varchar value to int

    - by onedaywhen
    Microsoft SQL Server 2008 (SP1), getting an unexpected 'Conversion failed' error. Not quite sure how to describe this problem, so below is a simple example. The CTE extracts the numeric portion of certain IDs using a search condition to ensure a numeric portion actually exists. The CTE is then used to find the lowest unused sequence number (kind of): CREATE TABLE IDs (ID CHAR(3) NOT NULL UNIQUE); INSERT INTO IDs (ID) VALUES ('A01'), ('A02'), ('A04'), ('ERR'); WITH ValidIDs (ID, seq) AS ( SELECT ID, CAST(RIGHT(ID, 2) AS INTEGER) FROM IDs WHERE ID LIKE 'A[0-9][0-9]' ) SELECT MIN(V1.seq) + 1 AS next_seq FROM ValidIDs AS V1 WHERE NOT EXISTS ( SELECT * FROM ValidIDs AS V2 WHERE V2.seq = V1.seq + 1 ); The error is, 'Conversion failed when converting the varchar value 'RR' to data type int.' I can't understand why the value ID = 'ERR' should be being considered for conversion because the predicate ID LIKE 'A[0-9][0-9]' should have removed the invalid row from the resultset. When the base table is substituted with an equivalent CTE the problem goes away i.e. WITH IDs (ID) AS ( SELECT 'A01' UNION ALL SELECT 'A02' UNION ALL SELECT 'A04' UNION ALL SELECT 'ERR' ), ValidIDs (ID, seq) AS ( SELECT ID, CAST(RIGHT(ID, 2) AS INTEGER) FROM IDs WHERE ID LIKE 'A[0-9][0-9]' ) SELECT MIN(V1.seq) + 1 AS next_seq FROM ValidIDs AS V1 WHERE NOT EXISTS ( SELECT * FROM ValidIDs AS V2 WHERE V2.seq = V1.seq + 1 ); Why would a base table cause this error? Is this a known issue? UPDATE @sgmoore: no, doing the filtering in one CTE and the casting in another CTE still results in the same error e.g. WITH FilteredIDs (ID) AS ( SELECT ID FROM IDs WHERE ID LIKE 'A[0-9][0-9]' ), ValidIDs (ID, seq) AS ( SELECT ID, CAST(RIGHT(ID, 2) AS INTEGER) FROM FilteredIDs ) SELECT MIN(V1.seq) + 1 AS next_seq FROM ValidIDs AS V1 WHERE NOT EXISTS ( SELECT * FROM ValidIDs AS V2 WHERE V2.seq = V1.seq + 1 );

    Read the article

  • yet another logic.

    - by Sunil
    I'm working on a research problem out of curiosity and I don't know how to program the logic that I've in mind. Let me explain it to you : I've 4 vectors say for example, v1 = 1 1 1 1 v2 = 2 2 2 2 v3 = 3 3 3 3 v4 = 4 4 4 4 Now what I want to do is to add them combination-wise. i.e v12 = v1+v2 v13 = v1+v3 v14 = v1+v4 v23 = v2+v3 v24 = v2+v4 v34 = v3+v4 Till this step it is just fine. The problem/trick is now, at the end of each iteration I give the obtained vectors into a black box function and it returns only few of the vectors say v12, v13 and v34. Now, I want to add each of these vectors one vector from v1,v2,v3,v4 which it hasn't added before. For example v3 and v4 hasn't been added to v12 so I want to create v123 and v124. similarly for all the vectors like, v12 should become : v123 = v12+v3 v124 = v12+v4 v13 should become : v132 // this should not occur because I already have v123 v134 = v13+v4; v14,v23 and v24 cannot be considered because it was deleted in the black box function so all we have in our hands to work with is v12,v13 and v34. v34 should become : v341 // cannot occur because we have 134 v342 = v34+v2 It is important that I do not do all at one step at the start like for example I can do (4 choose 3) 4C3 and finish it off but I want to do it step by step at each iteration. I've asked a modified version of this question before (without including the black box function) and got answers here. Can anybody tell me how to do it when the black box function is included ? A modification of the previous answer would also be great. Thanks in advance.

    Read the article

  • Several C# Language Questions

    - by Water Cooler v2
    1) What is int? Is it any different from the struct System.Int32? I understand that the former is a C# alias (typedef or #define equivalant) for the CLR type System.Int32. Is this understanding correct? 2) When we say: IComparable x = 10; Is that like saying: IComparable x = new System.Int32(); But we can't new a struct, right? or in C like syntax: struct System.In32 *x; x=>someThing = 10; 3) What is String with a capitalized S? I see in Reflector that it is the sealed String class, which, of course, is a reference type, unlike the System.Int32 above, which is a value type. What is string, with an uncapitalized s, though? Is that also the C# alias for this class? Why can I not see the alias definitions in Reflector? 4) Try to follow me down this subtle train of thought, if you please. We know that a storage location of a particular type can only access properties and members on its interface. That means: Person p = new Customer(); p.Name = "Water Cooler v2"; // legal because as Name is defined on Person. but // illegal without an explicit cast even though the backing // store is a Customer, the storage location is of type // Person, which doesn't support the member/method being // accessed/called. p.GetTotalValueOfOrdersMade(); Now, with that inference, consider this scenario: int i = 10; // obvious System.object defines no member to // store an integer value or any other value in. // So, my question really is, when the integer is // boxed, what is the *type* it is actually boxed to. // In other words, what is the type that forms the // backing store on the heap, for this operation? object x = i; Update Thank you for your answers, Eric Gunnerson and Aaronought. I'm afraid I haven't been able to articulate my questions well enough to attract very satisfying answers. The trouble is, I do know the answers to my questions on the surface, and I am, by no means, a newbie programmer. But I have to admit, a deeper understanding to the intricacies of how a language and its underlying platform/runtime handle storage of types has eluded me for as long as I've been a programmer, even though I write correct code.

    Read the article

  • Game ideas for a platformer

    - by user5925
    I have created a platformer which currently has the features listed below. I would greatly appreciate any further ideas which I could implement! (I don't play a lot of games which is why I require help) -- Walking/jumping/movement -- player can shoot lasers -- enemies also walk, fly, and shoot lasers -- water (you can swim in this) -- mud (slows you down on contact, and stops you from jumping) -- ladders -- damage when falling from a large height, unless falling into water -- moving platforms -- springboards (jumping on them shoot you into the air) -- growing platforms (allow you to reach new places) -- key and door system -- gem and coin collection system

    Read the article

  • How to optimise mesh data

    - by Wardy
    So i have some procedurally generated mesh data and i want to reduce it down to its minimum number of verts. In case it matters this is a unity project. Working on the basis of a simple example, lets assume a typical flat surface of points 2 by 3. The point / vertex at [1,1] is used in many triangles. I've generated mesh for a voxel type engine that adds verts to a list based on face visiblility and now I want to remove all the duplicates. Can anyone come up with an efficient way of doing this because what i have is sooo bad its not even funny (and i don't even think it's logically correct) ... private void Optimize() { Vector3 v; Vector3 v2; for (int i = 0; i < Vertices.Count; i++) { v = Vertices[i]; for (int j = i+1; j < Vertices.Count; j++) { v2 = Vertices[j]; if (v.x == v2.x && v.y == v2.y && v.z == v2.z) { for (int ind = 0; ind < Indices.Count; ind++) { if (Indices[ind] == j) { Indices[ind] = i; } else if (Indices[ind] > j && Indices[ind] > 0) Indices[ind]--; } Vertices.RemoveAt(j); Uvs.RemoveAt(j); Normals.RemoveAt(j); } } } } EDIT: Ok i managed to get this (code sample above updated) to render an "optimised" set of verts but the UV data is all wrong now, which would make sense because i'm basically just removing any UV Vector that represents a UV coord for a removed vert and not actually considering what I need to do to "fix the tri" so to speak. The code now seemingly does work but its quite time consuming, still looking to further optimise.

    Read the article

  • Accounting for waves when doing planar reflections

    - by CloseReflector
    I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending on the state of the wave's height. Naturally, after examining the brief paragraph of code: // calculating correction that shifts reflection up/down according to water wave Y position float4 projected_waveheight = mul(float4(input.positionWS.x,input.positionWS.y,input.positionWS.z,1),g_ModelViewProjectionMatrix); float waveheight_correction=-0.5*projected_waveheight.y/projected_waveheight.w; projected_waveheight = mul(float4(input.positionWS.x,-0.8,input.positionWS.z,1),g_ModelViewProjectionMatrix); waveheight_correction+=0.5*projected_waveheight.y/projected_waveheight.w; reflection_disturbance.y=max(-0.15,waveheight_correction+reflection_disturbance.y); My first guess was that it compensates for the planar reflection when it is subjected to vertical perturbation (the waves), shifting the reflected geometry to a point where is nothing and the water is just rendered as if there is nothing there or just the sky: Now, that's the sky reflecting where we should see the terrain's green/grey/yellowish reflection lerped with the water's baseline. My problem is now that I cannot really pinpoint what is the logic behind it. Projecting the actual world space position of a point of the wave/water geometry and then multiplying by -.5f, only to take another projection of the same point, this time with its y coordinate changed to -0.8 (why -0.8?). Clues in the code seem to indicate it was derived with trial and error because there is redundancy. For example, the author takes the negative half of the projected y coordinate (after the w divide): float waveheight_correction=-0.5*projected_waveheight.y/projected_waveheight.w; And then does the same for the second point (only positive, to get a difference of some sort, I presume) and combines them: waveheight_correction+=0.5*projected_waveheight.y/projected_waveheight.w; By removing the divide by 2, I see no difference in quality improvement (if someone cares to correct me, please do). The crux of it seems to be the difference in the projected y, why is that? This redundancy and the seemingly arbitrary selection of -.8f and -0.15f lead me to conclude that this might be a combination of heuristics/guess work. Is there a logical underpinning to this or is it just a desperate hack? Here is an exaggeration of the initial problem which the code fragment fixes, observe on the lowest tessellation level. Hopefully, it might spark an idea I'm missing. The -.8f might be a reference height from which to deduce how much to disturb the texture coordinate sampling the planarly reflected geometry render and -.15f might be the lower bound, a security measure.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >