Extremely Super-over-average 3D Modeller at YO' service!

Forum Archive - from http://theuniversal.net
User avatar
Knoxjoey
Posts: 98
Joined: Tue Sep 30, 2003 8:52 pm
Location: Canada
Contact:

ok this code works...

Post by Knoxjoey »

Code: Select all

#include <iostream.h> 

float converttocel(float); 
float converttofahr(float); 
int main() 
{ 
float tempFahr,tempCel; 
int input; 
cout << "Welcome to the temperature conversion program. Would you like to\n convert from Fahrenheit to Celsius [1] or Celsius to Fahrenheit? [2]\n Your choice number:"; 
cin >> input; 


if (input==1)  (input==2); // IF number is 1 OR 2 
	{ 
		if (input==1) // IF number is 1 
		{ 
			cout << "You have chosen to convert from Fahrenheit to Celsius. Please\n enter your Fahrenheit value:"; 
			cin >> tempFahr; 
			cout << "The Celsius equivalent to your Fahrenheit value is" << converttocel(tempFahr) << " degrees."; 
		} 
			else // IF number is not 1, i.e. 2 
	{ 
		cout << "You have chosen to convert from Celsius to Fahrenheit. Please \n enter your Celsius value:"; 
		cin >> tempCel; 
		cout << "The Fahrenheit equivalent to your Celsius value is " << converttofahr(tempCel) << " degrees."; 
	} 
	} 
	if (input<3) // THis is where i found the problem. there was a else here...
	{ 
	cout << "You idiot. Can't even type 1 or 2..... but i'm no better; i can't even loop the program\n so that it will ask again for the input "; 

	} 
		return 0; 
	} 

	float converttofahr(float tempCel) 
	{ 
	float tempFahr; 
	tempFahr=((tempCel*9)/5)+32; 
	return tempFahr; 
	} 

	float converttocel(float tempFahr) 
	{ 
	float tempCel; 
	tempCel=((tempFahr-32)*5)/9; 
	return tempCel; 
} 


this code work some what buggy but will complie and run :) ill leave the rest too you
User avatar
Fudrake
Posts: 244
Joined: Sat Oct 04, 2003 6:18 am
Location: UK, Europe, Northern Hemisphere, Earth, Solar System, Milky Way, the only universe we know of ;)

Post by Fudrake »

Thanks Knox :)

but i don't quite understand why the else shouldn't at all work there- I indented it so that everything makes sense (on Dev C++, not when I posted it though :D) and the else lined up with the

"if ((input==1) ¦¦ (input=2))"
line. SO IN THEORY the else really should be true for everything apart from 1 and 2, if that's the right logic.


7) and why does the main() function HAVE to end with return 0;?? Why not set main() to return void? Every single time main is set to return an interger, why? It doesn't help in any way! I don't see the point.
or is it for like "if main()==1" and then execute everything else only when main is completed? I suppose that works....


OOO and there were errors with the expressions "tempCel=((tempFahr.......blahblah" and vice versa, it was um...ISO. what is heck is ISO?

Syntax error with the braces.......

8 ) Also, how do you stop DOS closing itself immediately after the program's finished?

WHY the heck is the or gate left out, and still can work perfectly? I don't get it hehe


BAH never mind, i'll try yours and see what happens :)
User avatar
Mattizme
Posts: 615
Joined: Sat Oct 04, 2003 6:23 pm
Location: At work/school/home
Contact:

Post by Mattizme »

you could try..

Code: Select all

#include <iostream.h> 

float converttocel(float); 
float converttofahr(float);
int InputChoice(int);
int ReturnValue(int);
float tempFahr,tempCel;
int input;

int main()
{
InputChoice(0)
return(0);
}

int InputChoice(int ErrorMsg)
{
   if (ErrorMsg == 0)
       {
       cout << "Welcome to the temperature conversion program. Would you like to\n convert from Fahrenheit to Celsius [1] or Celsius to Fahrenheit? [2]\n Your choice number:";
       cin >> input;
       ReturnValue(input);
       }

   if (ErrorMsg == 1)
       {
       cout << "Eejit. One or two, it isn't that hard! /n Please enter a value again. /n [1] for Fahrenheit to Celsius, [2] For the other way round. /n Don't put the brackets in, just the number. /n Your Choice:";
       cin >> input;
       ReturnValue(input);
       }
}

int ReturnValue(int Selection)
{
   if (input != 1) && (input != 2) //The bloke's an eejit
   { 
     InputChoice(1); //Whack em over an error message
   }
   else if (input == 1)
   {
     cout << "Please enter a Fahrenheit Value. /n Fahrenheit:";
     cin >> tempFahr;
     cout << "The Celsius equivalent to your Fahrenheit value is" << converttocel(tempFahr) << " degrees.";
   }
   else if (input == 2)
   {
     cout << "Please enter a Celsius Value. /n Celsius:";
     cin >> tempCel;
     cout << "The Fahrenheit equivalent to your Celsius value is " << converttofahr(tempCel) << " degrees.";
   }
   return(0);
}

   float converttofahr(float tempCel) 
   { 
   float tempFahr; 
   tempFahr=((tempCel*9)/5)+32; 
   return tempFahr; 
   } 

   float converttocel(float tempFahr) 
   { 
   float tempCel; 
   tempCel=((tempFahr-32)*5)/9; 
   return tempCel; 
} 
I think that's right. I haven't really programmed much in C++, but generally the logic for the languages are the same.

If you search for whether they're an eejit or not first it'll save program time because then it doesn't have to skip over the 1 and 2 values first. This could have been done using a switch, but I'm not overly sure on the syntax for a switch command in C++..

And if you have WAY too much time on your hands, you could look into the Windows API and make a nice little Windows program for this :)

Happy Coding!
User avatar
Fudrake
Posts: 244
Joined: Sat Oct 04, 2003 6:18 am
Location: UK, Europe, Northern Hemisphere, Earth, Solar System, Milky Way, the only universe we know of ;)

Post by Fudrake »

OMG Mattizme I do apologise
Threw that tractor thing to the back of my memory and ain't started on it.....

*sigh* I never seem to stick to one thing or another, I love programming and modelling both so much, so I'm back on modelling for a while, because it'd take me a looooooong time to digest what the heckk is being described in my book. Going onto "basic classes" now hehe

Well, I'm here to ask a mighty stupid question
9) RIIIIGHT. I'm making Chinese chess. I managed to get Chinese characters trueSpace and made some really nice looking chess pieces. I made a really cool chessboard. THE ONLY PROBLEM is......

HOW TEH F*** do you make a bmp texture on the software and not draw it elsewhere?

Often chinese chess pieces are simply wood. so, I got some wood texture(BMP I got from internet) and applied it all to the pieces. They are flat cylinder shapes with a flat top and bottom. the top is where the word defining what the piece is, i.e. the name and type of the piece (e.g. Knight. yes, we don't have little fancy "every piece is a certain shape" policy for pieces.) is craved. Well, I did that alright, however when it comes to texturing and MAKING IT WORK.... BAH
the engraved word must be painted red or black, dependent on the army it's on. Anywhere else it was just wood. I used paint object, wood texture, and then paint faces tool for the black and red that. so, off I went. brilliant. nicely painted. Save as .x extension.....
Load object riiiight back. there and here it is- nicely textured. The black and red bits are in perfect order, and the thing is triangulated. The wood texture is assigned normally.(remember, it's a bmp).

NOOOOOW load it onto DarkBASIC..........
BLANK!!! stupid useless white pieces with the red and black bits still on. what I need is the wood covering the sides n stuff. I kinda expected that, but hey, what's this all about, I want a way around it!

I'm making the chess game on darkBASIC, which is only ever compatible with .x models. <brilliant> so If i load the object up on there, it'd appear a plain untextured colour plus the black bits on the words. If I apply the wood texture over it, then......eeeerrr it'd cover the black! I want both at once, it's not really that hard, is it.

I thought, hey, let's merge the texture into one, just like the tractor01.bmp- different parts of the tractor all mashed up into 1 square bmp. so.....HOW?

Alpha conversion? That takes IN a .BMP and throws a .TXR back at your face. Who needs a TXR? DarkBASIC's only compatible with BMP :D

If anything, i'd blame Darkbasic first. but there must be a way, right?

um, sorry, ain't tried that coding yet. will soon. concentrating on chess game.

EDIT: a very very little gigantic minute enormous tiny colossial change with the description of BMPS..........
Last edited by Fudrake on Fri Oct 31, 2003 10:45 pm, edited 1 time in total.
User avatar
Mattizme
Posts: 615
Joined: Sat Oct 04, 2003 6:23 pm
Location: At work/school/home
Contact:

Post by Mattizme »

My fist suggestion would be to find the part of the wood texture that covers the cylinder on the texture (put a red circle or something til it covers the bit of the cylinder) and then make one big image that is a copy of lots of them with the names of each bit on.

So you have:
- One texture of just wood.
- Another texture with all the names of the bits on - for example, circles of mood texture widh knoight, etc. on.

I suggested that tyou use part of the original texture, the right bit, then it'll look better as the wood texture will blend witht he grain.

If not, are you iusing a transparent texture? If worse, could you create inventive rollovers that show the name of the piece when you roll the mouse over?

There's always more then one way of skinning a cat ;)
User avatar
Fudrake
Posts: 244
Joined: Sat Oct 04, 2003 6:18 am
Location: UK, Europe, Northern Hemisphere, Earth, Solar System, Milky Way, the only universe we know of ;)

Post by Fudrake »

Thanks, but wasn't quite what I want- it's the .x file format that seems to be failing to browse its relative textures. I doubt that If I split the textures into different parts it'd carry the texture data over anyway. of course, if you wanna kill me by telling me to texture it via code (which I reckon is impossible..... DarkbASIC does not support texture editing very nicely)

What I want to know is how Mit (or the great annonymus creator who made Tractor01.x and tractor01.bmp) PACKED four wheels in one quarter of the bitmap, then the rest on the other three quaters. It does not fold out to cover the model. The way of doing that is really what I want- I can't see another way for doing it tbh.

Maybe I should really explore DarkBASIC's ability to deal with these things before posting hehe. I think there is a bit about it having UV texture mapping and the types of projection, but I can't see how it will help me post the red on the engraved character over the wood.

I'd not like to see rollovers :( but good idea for the very last resorts hehe (looks like there's a really big list eh? ;P)

Well, i'm not using a texture for the word(character). i'm painting onto the face, and that for sure, is stransferred from the .x file format into DarkBASIC fine. the problem is to have it make a priority overy the wood, with the wood underneath- AND STAYING on DarkBASIC.

I'll check BASIC again before analysing even further. but i'd like to know what kinda stuff is needed to make special packed images such as tractor01.bmp :) I've always been puzzled over texturing, as mentioned in first post.

<----- lookie yonder!
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

if you don't mind taking an extra step in the converting, you can use free simple program called Uvmapper from http://www.uvmapper.com.
you can fully map .obj models in the way you want them. the only real extra conversion step is make the model a .obj file for texturing, then converting it back to .x or .3ds for import into a-tractors converter.

it works by displaying all the models faces in its window, depemnding on how you want it to form the first mapping of it from a few different styles (like box, planer, spherical). the faces are really the areas that the corresponding shaped face will use from the texture. you can drag, resize, rotate, and flip the faces to arrange the texture layout as you want, including making all 4 tires come from the same area. when done, save the model, save the bitmap so you see what goes where, then color it in.
User avatar
Fudrake
Posts: 244
Joined: Sat Oct 04, 2003 6:18 am
Location: UK, Europe, Northern Hemisphere, Earth, Solar System, Milky Way, the only universe we know of ;)

Post by Fudrake »

oops don't need that now :)

the problem seems to be fixed. I just have to throw all the textures in the sme directory as the models themseleves, and they will carry the texture information.
Thanks for all the help anyway.

zar, the UV mapper only works with obj files, and as you said, it requires another conversion step. The only problem there is that truespace isn't compatible, but i'm sure it'd become of some use in the future; it is a great software.


the next problem now is how to stop .x automatically triangulateing the object so that the textures mess up- as the words of the characters are very irregular, lines are joined from random vertices (almost) and create random new faces. THAT, then of course, is textured with the same colour as the word or the wood, so the re is colour there there isn't meant to be.

When I save the object as a .x file, a window pops-up asking me for DirectX model's properties. of course, i left all the boxes blank including "triangluate object" and pressed ok. The next time I load the object back up it is all triangulated. i mean, WTF??!
Locked