[SOLVED]Bake CAKE Clothraycaster

Vineeth@nxOgre

05-04-2008 15:17:00

t->mWorldInstance = t->getWorld();\

t->mTargetCloth=t->getCloth();\

I have created a virtual function getcloth in Cake so that i can initialize mtargetCloth of Cake
Then i created a public member in Decoration class called cloth which would be initialized by the prestart of frosting method along with the mWorld by Worldinstance.
I have the cloth available in the frosting class .how can i cast into ClothRaycaster class.The constructor of clothraycaster takes only mScene

void Frosting::preStart(World* w,Cloth* c) {

mWorld = w;
mCloth=c;
Scenes* mScenes=mWorld->getScenes();
mScene=mScenes->get("myScene");
mRay = new RayCaster(mCamera->getPosition(), Vector3(0,0,0), 100, RayCaster::RCT_CLOSEST, mScene);
mClothRay = new ClothRayCaster(mScene);
//mClothRay->castCloth(mCloth,)

:wink:

the castcloth member function expects pose an dorientation which i have already defined in the sponge cake

Vineeth@nxOgre

08-04-2008 06:18:19

Nxogrecloth.cpp
..
Ogre::Vector3 ClothVertex::getGlobalPosition() const {
NxVec3* vertices = new NxVec3();
cloth->getPositions((void*) vertices);
return toVector3(vertices[vertex]);
}

nxogrecloth.h

struct NxExport ClothVertex {
Cloth* cloth;
NxU32 vertex;

Ogre::Vector3 getGlobalPosition() const;




void setGlobalPosition(const Ogre::Vector3& worldPosition);
void attachToShape(Shape*, const Ogre::Vector3& localPosition);
void attachToWorld(const Ogre::Vector3& worldPosition);
void freeVertex();
void tear(const Ogre::Vector3& normal);

// Set Velocity of a specific vertex.
// This function is quite complex. If you need to set velocities of one or more vertexes, set it within the Cloth.
void setVelocity(const Ogre::Vector3& velocity);
};


Should i implement the other functions of this structure Betajaen.Have you left it out on purpose

Vineeth@nxOgre

08-04-2008 08:44:33

if (mCake->mTargetCloth && ms.buttonDown(OIS::MB_Left)) {
//mOgreRay = mOgreRay=mCamera->getCameraToViewportRay(float(mCursor->getLeft() / mRenderer->getWindow()->getWidth()),float(mCursor->getTop() / mRenderer->getWindow()->getHeight()));

if (mClothRay) {

ClothVertex cv = mClothRay->getClothVertex()
mClothRay->castCloth(mCloth,mWorldPosition,mNormal)

instead i put the ogreray origin and direction as parameters and i got the vertex

This is the code in Frosting ,onFrame of Cake 9.38

The tear vertex function asks for a vertex and a normal,I can get the vertex from cloth ray caster class.What shall I do for the normal


:cry: