leaves

Started by
1 comment, last by yeah_right_04 20 years, 4 months ago
ok i am a beginner in OpenGL but im trying to create a couple of leaves flying around first i created a function for creating a leaf then called it several times. what i want to do now is that every leaf flies around in diffrent directions and undependable on other leaves!? i tried to change every round the glTranslate but it didnt work maybe some kind of AI is needed thx in advance
Advertisement
What you need to do is create a class/struct representing a leaf. This will contain information specific to each leaf.

In pseudocode (plus real STL code):
class Leaf{	position;	velocity;	colour;	Leaf(){		position = randomVector();		velocity = randomVector();		colour = randomColour();	}};void makeLeaves(int numberOfLeaves, std::vector<Leaf> leaves){	for each leaf {		Leaf l;		leaves.push_back(l);	}}void updateLeaves(std::vector<Leaf> leaves){	std::vector<Leaf>::iterator currentLeaf = leaves.begin();	while (currentLeaf != leaves.end()){		currentLeaf->updatePositionAndVelocity();		currentLeaf++;	}}void drawLeaves(std::vector<Leaf> leaves){	std::vector<Leaf>::iterator currentLeaf = leaves.begin();	while (currentLeaf != leaves.end()){		currentLeaf->draw();		currentLeaf++;	}}


Enigma
Maybe an amendment to nehe''s lesson 38?

This topic is closed to new replies.

Advertisement