void Cursor::onProcess(const WidgetEvents & events) { if (!isVisible()) return; sf::Vector2f pos = events.mousePosition - getPosition(); if (myCursorTransform.getPosition() != pos) { myCursorTransform.setPosition(pos); invalidateVertices(); } if (isRotatable()) { sf::Vector2f deltaVec = myBackPosition - myCursorTransform.getPosition(); sf::Vector2f normVec = vectorLength(deltaVec) < 0.0001f ? sf::Vector2f(1, 0) : deltaVec / vectorLength(deltaVec); myBackPosition = myCursorTransform.getPosition() + normVec * getRotationOffset(); float angle = radToDeg(angleBetween(myBackPosition, myCursorTransform.getPosition())) + getAngle(); myCursorTransform.setRotation(angle); /* if (myCursorTransform.getRotation() != angle) { myCursorTransform.setRotation(angle); invalidateVertices(); } */ } }
void CSObject::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) { out->addInt( "Id", getId()); out->addString( "Name", getName().c_str()); out->addBool( "Dead", getDead()); out->addBool( "DebugObject", getDebugObject()); out->addVector3d( "Position", getRelativePosition()); out->addVector3d( "PositionOffset", getPositionOffset()); out->addVector3d( "Rotation", getRelativeRotation()); out->addVector3d( "RotationOffset", getRotationOffset()); out->addVector3d( "Scale", getRelativeScale()); out->addVector3d( "ScaleOffset", getScaleOffset()); out->addVector3d( "BBOffset", getBBOffset()); out->addBool( "Shadow", getShadow()); out->addString( "ActorFileName", getActorFileName().c_str()); out->addString( "TextureFileName", getTextureFileName().c_str()); }
void CSObject::setPrimarySceneNodeRotation(vector3df rot) { CS_SAFE(getPrimarySceneNode(), setRotation(rot + getRotationOffset())); }