Coiote
15-05-2008 01:41:29
Here we go again
Is there a way to make power up's? For example when I pass with my shuttle over a box (imagine that is my power up) how can I make it disappear andI go through her ??
I think making two method's, once in each class of shuttle and powerup, called GetPosition and then compare the two, but I think that isn't very efficience or even work.
Thankx. one more time
Coiote
19-05-2008 20:00:30
betajaen I read some posts about the triggers, but I don't understand that very well
For example, I have two cubes and when one touch the other, then switch the color of one.
thankx
Coiote
20-05-2008 00:51:49
Well I go a little deep in my reading
And I try using triggers in Cakebox . I put:
#include "Ogre.h"
#include "NxOgre.h"
#include "Cake.h"
#include "nxogretrigger.h"
using namespace NxOgre;
using namespace Ogre;
using namespace std;
//class myCallback : public GroupCallback::InheritedCallback {
//
// public:
//
// void onStartTouch(Actor*, Actor*) {
//
// }
//
// void onEndTouch(Actor*, Actor*) {
//
// }
//
// void onTouch(Actor*, Actor*) {
//
// }
// public:
//
// void TurnRed(Actor* a , Actor* b) {
// Body* bd = static_cast<Body*>(b);
// bd->getEntity()->setMaterialName("nx.capsule");
// }
//
// void TurnYellow(Actor* a, Actor* b) {
// Body* bd = static_cast<Body*>(b);
// bd->getEntity()->setMaterialName("nx.cube");
// }
//
// void Jiggle(Actor* a, Actor* b) {
// b->addForce(Vector3(NxMath::rand(-10,10), NxMath::rand(-10,10), NxMath::rand(-10,10)) * b->getMass());
// }
//
//};
class myTrigger : public TriggerCallback::InheritedCallback
{
public :
myTrigger() { }
void onEnter(Trigger* t, Actor *a) {
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.red");
}
void onLeave(Trigger* t, Actor *a)
{
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.green");
}
void onInside(Trigger* t, Actor *a)
{
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.blue");
}
// character stuff
void onEnter(Trigger* t, Character *a) { }
void onLeave(Trigger* t, Character *a) { }
void onInside(Trigger* t, Character *a) { }
};
class Sponge_Cake : public Cake {
public:
World* mWorld;
Scene* mScene;
void start() {
/*NxOgre::Body* ball1;
NxOgre::Body* ball2;*/
NxOgre::Body* cube;
mWorld = new World("log: html");
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");
/* mKnifeGroup = mScene->createActorGroup("Knife");
mButterKnifeGroup = mScene->createActorGroup("ButterKnife");
mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1),Vector3(0,0.5f,0),"Mass: 100, Group: Knife");
mKnifeGroup->setCallback(mCallback);
mKnifeGroup->setCollisionCallback(mButterKnifeGroup, NX_NOTIFY_ALL, true);
mKnifeGroup->setCallback<myCallback>(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);
mKnifeGroup->setCollisionCallback(mButterKnifeGroup, NX_NOTIFY_ALL, true);*/
myTrigger *testTriggerCB = new myTrigger();
Trigger* testTrigger = mScene->createTrigger("testTrigger", new CubeShape(10), Vector3(0,5,0), "Static:yes");
testTrigger->setCallback(testTriggerCB);
}
The trigger code doesn't do anything. And the code for groups give an error in mCallback that I don't find where it is.
Thankx